Commit c3fdcee7d95c4f4a1bf3267c085bd19005f7ba47

Authored by rmatsuda
1 parent ac7360f9
Exists in master

Fixed for new thread management

invesalius/data/coregistration.py
@@ -140,7 +140,7 @@ def compute_marker_transformation(coord_raw, obj_ref_mode): @@ -140,7 +140,7 @@ def compute_marker_transformation(coord_raw, obj_ref_mode):
140 return m_probe 140 return m_probe
141 141
142 142
143 -def corregistrate_dynamic(inp, coord_raw, ref_mode_id): 143 +def corregistrate_dynamic(inp, coord_raw, ref_mode_id, icp):
144 144
145 m_change, obj_ref_mode = inp 145 m_change, obj_ref_mode = inp
146 146
@@ -157,8 +157,8 @@ def corregistrate_dynamic(inp, coord_raw, ref_mode_id): @@ -157,8 +157,8 @@ def corregistrate_dynamic(inp, coord_raw, ref_mode_id):
157 m_probe_ref[2, -1] = -m_probe_ref[2, -1] 157 m_probe_ref[2, -1] = -m_probe_ref[2, -1]
158 # corregistrate from tracker to image space 158 # corregistrate from tracker to image space
159 m_img = m_change @ m_probe_ref 159 m_img = m_change @ m_probe_ref
160 - if self.icp:  
161 - m_img = bases.transform_icp(m_img, self.m_icp) 160 + if icp[0]:
  161 + m_img = bases.transform_icp(m_img, icp[1])
162 # compute rotation angles 162 # compute rotation angles
163 _, _, angles, _, _ = tr.decompose_matrix(m_img) 163 _, _, angles, _, _ = tr.decompose_matrix(m_img)
164 # create output coordiante list 164 # create output coordiante list
@@ -247,7 +247,7 @@ class CoordinateCorregistrateNoObject(threading.Thread): @@ -247,7 +247,7 @@ class CoordinateCorregistrateNoObject(threading.Thread):
247 try: 247 try:
248 # print(f"Set the coordinate") 248 # print(f"Set the coordinate")
249 coord_raw = dco.GetCoordinates(trck_init, trck_id, trck_mode) 249 coord_raw = dco.GetCoordinates(trck_init, trck_id, trck_mode)
250 - coord, m_img = corregistrate_dynamic(coreg_data, coord_raw, self.ref_mode_id) 250 + coord, m_img = corregistrate_dynamic(coreg_data, coord_raw, self.ref_mode_id, [self.icp, self.m_icp])
251 # print("Coord: ", coord) 251 # print("Coord: ", coord)
252 m_img_flip = m_img.copy() 252 m_img_flip = m_img.copy()
253 m_img_flip[1, -1] = -m_img_flip[1, -1] 253 m_img_flip[1, -1] = -m_img_flip[1, -1]
invesalius/gui/dialogs.py
@@ -3486,7 +3486,7 @@ class ICPCorregistrationDialog(wx.Dialog): @@ -3486,7 +3486,7 @@ class ICPCorregistrationDialog(wx.Dialog):
3486 self._init_gui() 3486 self._init_gui()
3487 3487
3488 def __bind_events(self): 3488 def __bind_events(self):
3489 - Publisher.subscribe(self.UpdateCurrentCoord, 'Co-registered points') 3489 + Publisher.subscribe(self.UpdateCurrentCoord, 'Update cross position')
3490 3490
3491 def UpdateCurrentCoord(self, arg, position): 3491 def UpdateCurrentCoord(self, arg, position):
3492 self.current_coord = position[:] 3492 self.current_coord = position[:]
@@ -3612,7 +3612,7 @@ class ICPCorregistrationDialog(wx.Dialog): @@ -3612,7 +3612,7 @@ class ICPCorregistrationDialog(wx.Dialog):
3612 Markers created by navigation tools and rendered in volume viewer. 3612 Markers created by navigation tools and rendered in volume viewer.
3613 """ 3613 """
3614 3614
3615 - x, y, z = bases.flip_x(coord) 3615 + x, y, z = bases.flip_x_m(coord)[:3, 0]
3616 3616
3617 ball_ref = vtk.vtkSphereSource() 3617 ball_ref = vtk.vtkSphereSource()
3618 ball_ref.SetRadius(size) 3618 ball_ref.SetRadius(size)
@@ -3724,7 +3724,7 @@ class ICPCorregistrationDialog(wx.Dialog): @@ -3724,7 +3724,7 @@ class ICPCorregistrationDialog(wx.Dialog):
3724 self.Refresh() 3724 self.Refresh()
3725 3725
3726 def SetCameraVolume(self, position): 3726 def SetCameraVolume(self, position):
3727 - cam_focus = np.array(bases.flip_x(position[:3])) 3727 + cam_focus = np.array(bases.flip_x_m(position[:3])[:3, 0])
3728 cam = self.ren.GetActiveCamera() 3728 cam = self.ren.GetActiveCamera()
3729 3729
3730 if self.initial_focus is None: 3730 if self.initial_focus is None:
invesalius/gui/task_navigator.py
@@ -471,14 +471,14 @@ class NeuronavigationPanel(wx.Panel): @@ -471,14 +471,14 @@ class NeuronavigationPanel(wx.Panel):
471 for m in [0, 1, 2]: 471 for m in [0, 1, 2]:
472 self.numctrls_coord[btn_id][m].SetValue(coord[m]) 472 self.numctrls_coord[btn_id][m].SetValue(coord[m])
473 473
474 - def UpdateNavigationStatus(self, status):  
475 - self.nav_status = status  
476 - if status: 474 + def UpdateNavigationStatus(self, nav_status, vis_status):
  475 + self.nav_status = nav_status
  476 + if nav_status:
477 self.checkicp.Enable(True) 477 self.checkicp.Enable(True)
478 else: 478 else:
479 self.checkicp.Enable(False) 479 self.checkicp.Enable(False)
480 480
481 - def UpdateImageCoordinates(self, position): 481 + #def UpdateImageCoordinates(self, position):
482 def UpdateFRE(self, fre): 482 def UpdateFRE(self, fre):
483 # TODO: Exhibit FRE in a warning dialog and only starts navigation after user clicks ok 483 # TODO: Exhibit FRE in a warning dialog and only starts navigation after user clicks ok
484 self.txtctrl_fre.SetValue(str(round(fre, 2))) 484 self.txtctrl_fre.SetValue(str(round(fre, 2)))