Commit e2f228d400ee5f53e893678e82155f42def18136
1 parent
121e33b4
Exists in
master
Fixed for obj correg
Showing
3 changed files
with
17 additions
and
8 deletions
Show diff stats
invesalius/data/coregistration.py
... | ... | @@ -105,7 +105,7 @@ def tracker_to_image(m_change, m_probe_ref, r_obj_img, m_obj_raw, s0_dyn): |
105 | 105 | return m_img |
106 | 106 | |
107 | 107 | |
108 | -def corregistrate_object_dynamic(inp, coord_raw, ref_mode_id): | |
108 | +def corregistrate_object_dynamic(inp, coord_raw, ref_mode_id, icp): | |
109 | 109 | |
110 | 110 | m_change, obj_ref_mode, t_obj_raw, s0_raw, r_s0_raw, s0_dyn, m_obj_raw, r_obj_img = inp |
111 | 111 | |
... | ... | @@ -120,6 +120,8 @@ def corregistrate_object_dynamic(inp, coord_raw, ref_mode_id): |
120 | 120 | m_probe_ref[2, -1] = -m_probe_ref[2, -1] |
121 | 121 | # corregistrate from tracker to image space |
122 | 122 | m_img = tracker_to_image(m_change, m_probe_ref, r_obj_img, m_obj_raw, s0_dyn) |
123 | + if icp[0]: | |
124 | + m_img = bases.transform_icp(m_img, icp[1]) | |
123 | 125 | # compute rotation angles |
124 | 126 | _, _, angles, _, _ = tr.decompose_matrix(m_img) |
125 | 127 | # create output coordiante list |
... | ... | @@ -169,7 +171,7 @@ def corregistrate_dynamic(inp, coord_raw, ref_mode_id, icp): |
169 | 171 | |
170 | 172 | |
171 | 173 | class CoordinateCorregistrate(threading.Thread): |
172 | - def __init__(self, ref_mode_id, trck_info, coreg_data, coord_queue, view_tracts, coord_tracts_queue, event, sle): | |
174 | + def __init__(self, ref_mode_id, trck_info, coreg_data, coord_queue, view_tracts, coord_tracts_queue, event, sle, icp_queue): | |
173 | 175 | threading.Thread.__init__(self, name='CoordCoregObject') |
174 | 176 | self.ref_mode_id = ref_mode_id |
175 | 177 | self.trck_info = trck_info |
... | ... | @@ -179,8 +181,9 @@ class CoordinateCorregistrate(threading.Thread): |
179 | 181 | self.coord_tracts_queue = coord_tracts_queue |
180 | 182 | self.event = event |
181 | 183 | self.sle = sle |
184 | + self.icp_queue = icp_queue | |
185 | + self.icp = None | |
182 | 186 | self.m_icp = None |
183 | - self.icp = False | |
184 | 187 | |
185 | 188 | def run(self): |
186 | 189 | trck_info = self.trck_info |
... | ... | @@ -191,9 +194,13 @@ class CoordinateCorregistrate(threading.Thread): |
191 | 194 | # print('CoordCoreg: event {}'.format(self.event.is_set())) |
192 | 195 | while not self.event.is_set(): |
193 | 196 | try: |
197 | + if self.icp_queue.empty(): | |
198 | + None | |
199 | + else: | |
200 | + self.icp, self.m_icp = self.icp_queue.get_nowait() | |
194 | 201 | # print(f"Set the coordinate") |
195 | 202 | coord_raw = dco.GetCoordinates(trck_init, trck_id, trck_mode) |
196 | - coord, m_img = corregistrate_object_dynamic(coreg_data, coord_raw, self.ref_mode_id) | |
203 | + coord, m_img = corregistrate_object_dynamic(coreg_data, coord_raw, self.ref_mode_id, [self.icp, self.m_icp]) | |
197 | 204 | m_img_flip = m_img.copy() |
198 | 205 | m_img_flip[1, -1] = -m_img_flip[1, -1] |
199 | 206 | # self.pipeline.set_message(m_img_flip) |
... | ... | @@ -209,6 +216,9 @@ class CoordinateCorregistrate(threading.Thread): |
209 | 216 | if self.view_tracts: |
210 | 217 | self.coord_tracts_queue.put_nowait(m_img_flip) |
211 | 218 | |
219 | + if not self.icp_queue.empty(): | |
220 | + self.icp_queue.task_done() | |
221 | + | |
212 | 222 | # The sleep has to be in both threads |
213 | 223 | sleep(self.sle) |
214 | 224 | except queue.Full: |
... | ... | @@ -244,14 +254,13 @@ class CoordinateCorregistrateNoObject(threading.Thread): |
244 | 254 | else: |
245 | 255 | self.icp, self.m_icp = self.icp_queue.get_nowait() |
246 | 256 | # print(f"Set the coordinate") |
247 | - print(self.icp, self.m_icp) | |
257 | + #print(self.icp, self.m_icp) | |
248 | 258 | coord_raw = dco.GetCoordinates(trck_init, trck_id, trck_mode) |
249 | 259 | coord, m_img = corregistrate_dynamic(coreg_data, coord_raw, self.ref_mode_id, [self.icp, self.m_icp]) |
250 | 260 | # print("Coord: ", coord) |
251 | 261 | m_img_flip = m_img.copy() |
252 | 262 | m_img_flip[1, -1] = -m_img_flip[1, -1] |
253 | 263 | |
254 | - #print(icp) | |
255 | 264 | if self.icp: |
256 | 265 | m_img = bases.transform_icp(m_img, self.m_icp) |
257 | 266 | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -850,7 +850,7 @@ def ShowNavigationTrackerWarning(trck_id, lib_mode): |
850 | 850 | dlg.Destroy() |
851 | 851 | |
852 | 852 | def ICPcorregistration(fre): |
853 | - msg = _("The fiducial registration error is: ") + str(round(fre, 2)) + '\n' + \ | |
853 | + msg = _("The fiducial registration error is: ") + str(round(fre, 2)) + '\n\n' + \ | |
854 | 854 | _("Would you like to improve accuracy?") |
855 | 855 | if sys.platform == 'darwin': |
856 | 856 | dlg = wx.MessageDialog(None, "", msg, | ... | ... |
invesalius/gui/task_navigator.py
... | ... | @@ -809,7 +809,7 @@ class NeuronavigationPanel(wx.Panel): |
809 | 809 | |
810 | 810 | jobs_list.append(dcr.CoordinateCorregistrate(self.ref_mode_id, tracker_mode, coreg_data, self.coord_queue, |
811 | 811 | self.view_tracts, self.coord_tracts_queue, |
812 | - self.event, self.sleep_nav)) | |
812 | + self.event, self.sleep_nav, self.icp_queue)) | |
813 | 813 | |
814 | 814 | else: |
815 | 815 | coreg_data = (m_change, 0) | ... | ... |