15
15
"project" : "M246930_Scnn1a_4_f1" ,
16
16
"client_scripts" : "/pipeline/render/render-ws-java-client/src/main/scripts"
17
17
},
18
- "dst_stack" : "FA_STI_DCV_FF_Session1 " ,
19
- "src_stack" : "REG_STI_DCV_FF_Session3 " ,
20
- "output_stack" : "FA_REG_STI_DCV_FF_Session3 " ,
21
- "matchcollection" : "M246930_Scnn1a_4_f1_DAPI3_TO_DAPI1 " ,
18
+ "dst_stack" : "EMSite2_take2_EMA " ,
19
+ "src_stack" : "Session1_DRP_STI_DCV_FF " ,
20
+ "output_stack" : "TEST_Site2_take2_EMA_STI_DCV_FF_allSession_1 " ,
21
+ "matchcollection" : "M246930_Scnn1a_4_f1_DAPI1_EMsite2_ptMatch " ,
22
22
"num_local_transforms" : 0 ,
23
23
"transform_type" : "affine"
24
24
}
@@ -41,22 +41,22 @@ class FitTransformsByPointMatchParameters(RenderParameters):
41
41
num_local_transforms = Int (required = True ,
42
42
description = "number of local transforms to preserver, \
43
43
assumes point matches written down after such local transforms" )
44
- setz = Boolean (required = False , default = True ,
45
- description = "whether to change z's to the destination stack" )
46
44
transform_type = Str (required = False , default = 'affine' ,
47
45
validate = mm .validate .OneOf (["affine" ,"rigid" ]),
48
46
description = "type of transformation to fit" )
49
47
pool_size = Int (required = False , default = 20 ,
50
48
description = 'degree of parallelism (default 20)' )
51
-
49
+ setz = Boolean (required = False , default = True ,
50
+ description = "whether to change z's to the destination stack" )
51
+
52
52
logger = logging .getLogger (__name__ )
53
53
54
54
def fit_transforms_by_pointmatch (render ,
55
55
src_stack ,
56
56
dst_stack ,
57
57
matchcollection ,
58
58
num_local_transforms ,
59
- setz ,
59
+ setz ,
60
60
Transform ):
61
61
print src_stack ,dst_stack ,matchcollection ,num_local_transforms
62
62
tilespecs_p = renderapi .tilespec .get_tile_specs_from_stack (src_stack , render = render )
@@ -66,29 +66,44 @@ def fit_transforms_by_pointmatch(render,
66
66
for k ,tsp in enumerate (tilespecs_p ):
67
67
pid = tsp .tileId
68
68
pgroup = tsp .layout .sectionId
69
- match = renderapi .pointmatch .get_matches_involving_tile (matchcollection ,pgroup ,pid ,render = render )[0 ]
70
- if match ['qId' ]== pid :
71
- pid = match ['qId' ]
72
- qid = match ['pId' ]
73
- p_pts = np .array (match ['matches' ]['q' ]).T
74
- q_pts = np .array (match ['matches' ]['p' ]).T
75
- else :
76
- pid = match ['pId' ]
77
- qid = match ['qId' ]
78
- p_pts = np .array (match ['matches' ]['p' ]).T
79
- q_pts = np .array (match ['matches' ]['q' ]).T
80
-
81
- tsq = next (ts for ts in tilespecs_q if ts .tileId == qid )
82
- tforms = tsq .tforms [num_local_transforms :]
83
- dst_pts = renderapi .transform .estimate_dstpts (tforms ,q_pts )
84
- p_pts_global = renderapi .transform .estimate_dstpts (tsp .tforms [num_local_transforms :],p_pts )
85
- final_tform = Transform ()
86
- final_tform .estimate (p_pts ,dst_pts )
87
- tsp .tforms = tsp .tforms [0 :num_local_transforms ]+ [final_tform ]
88
-
89
- if setz == True :
90
- tsp .z = tsq .z
91
-
69
+ try :
70
+ matches = renderapi .pointmatch .get_matches_involving_tile (matchcollection ,pgroup ,pid ,render = render )
71
+ dst_pts_list = []
72
+ p_pts_list = []
73
+ for match in matches :
74
+ if match ['qId' ]== pid :
75
+ pid = match ['qId' ]
76
+ qid = match ['pId' ]
77
+ p_pts = np .array (match ['matches' ]['q' ]).T
78
+ q_pts = np .array (match ['matches' ]['p' ]).T
79
+ else :
80
+ pid = match ['pId' ]
81
+ qid = match ['qId' ]
82
+ p_pts = np .array (match ['matches' ]['p' ]).T
83
+ q_pts = np .array (match ['matches' ]['q' ]).T
84
+ try :
85
+ tsq = next (ts for ts in tilespecs_q if ts .tileId == qid )
86
+ tforms = tsq .tforms [num_local_transforms :]
87
+ dst_pts = renderapi .transform .estimate_dstpts (tforms ,q_pts )
88
+ dst_pts_list .append (dst_pts )
89
+ p_pts_list .append (p_pts )
90
+ except :
91
+ pass
92
+ #p_pts_global = renderapi.transform.estimate_dstpts(tsp.tforms[num_local_transforms:],p_pts)
93
+ if len (dst_pts_list )> 0 :
94
+ dst_pts = np .vstack (dst_pts_list )
95
+ p_pts = np .vstack (p_pts_list )
96
+ final_tform = Transform ()
97
+ final_tform .estimate (p_pts ,dst_pts )
98
+ tsp .tforms = tsp .tforms [0 :num_local_transforms ]+ [final_tform ]
99
+ if setz == True :
100
+ tsp .z = tsq .z
101
+ tilespecs_out .append (tsp )
102
+
103
+ except IndexError as e :
104
+ pass
105
+ except StopIteration as e :
106
+ pass
92
107
# print pid,qid
93
108
# print "p_pts"
94
109
# print p_pts
@@ -98,8 +113,9 @@ def fit_transforms_by_pointmatch(render,
98
113
# print p_pts_global
99
114
# if k==1:
100
115
# break
116
+
101
117
102
- return tilespecs_p
118
+ return tilespecs_out
103
119
104
120
105
121
class FitTransformsByPointMatch (RenderModule ):
@@ -122,17 +138,18 @@ def run(self):
122
138
self .args ['matchcollection' ],
123
139
self .args ['num_local_transforms' ],
124
140
self .args ['setz' ],
125
- Transform )
141
+ Transform )
126
142
127
143
outstack = self .args ['output_stack' ]
128
144
129
145
self .render .run (renderapi .stack .delete_stack , outstack )
130
146
self .render .run (renderapi .stack .create_stack , outstack )
131
-
147
+ sv = self .render .run (renderapi .stack .get_stack_metadata , self .args ['dst_stack' ])
148
+
132
149
renderapi .client .import_tilespecs_parallel (outstack ,tilespecs ,
133
150
render = self .render ,
134
151
close_stack = True )
135
-
152
+ self . render . run ( renderapi . stack . set_stack_metadata , outstack , sv )
136
153
self .render .run (renderapi .stack .set_stack_state ,
137
154
outstack , state = 'COMPLETE' )
138
155
0 commit comments