Skip to content

Commit

Permalink
Now works with tracker coordinate system where stylus points in x-axi…
Browse files Browse the repository at this point in the history
…s as opposed to y-axis. Also, removed unnecessary disabling of 'Track coil' button before navigation.
  • Loading branch information
Tolonen Luka committed Jul 25, 2024
1 parent 62ed00e commit c036972
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion invesalius/data/coregistration.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,11 @@ def corregistrate_probe(m_change, r_stylus, coord_raw, ref_mode_id, icp=[None, N
m_img = m_change @ m_probe_ref
m_img = apply_icp(m_img, icp)

# Rotate from trk system where stylus points in x-axis to vtk-system where stylus points in y-axis
R = tr.euler_matrix(*np.radians([0, 0, -90]), axes="rxyz")[:3, :3]

# rotate m_probe_ref from tracker to image space
r_img = r_stylus @ m_probe_ref[:3, :3]
r_img = r_stylus @ R @ m_probe_ref[:3, :3] @ np.linalg.inv(R)
m_img[:3, :3] = r_img[:3, :3]

# compute rotation angles
Expand Down
2 changes: 0 additions & 2 deletions invesalius/gui/task_navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,8 +1304,6 @@ def __init__(self, parent, nav_hub):
track_object_button.SetBackgroundColour(GREY_COLOR)
track_object_button.SetBitmap(BMP_TRACK)
track_object_button.SetValue(False)
if not self.track_obj:
track_object_button.Enable(False)
track_object_button.SetToolTip(tooltip)
track_object_button.Bind(
wx.EVT_TOGGLEBUTTON, partial(self.OnTrackObjectButton, ctrl=track_object_button)
Expand Down
7 changes: 5 additions & 2 deletions invesalius/navigation/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,12 @@ def SetStylusOrientation(self, coord_raw):
# up_vtk: orientation 'stylus pointing up along head' in vtk space
up_vtk = tr.euler_matrix(*np.radians([90.0, 0.0, 0.0]), axes="rxyz")[:3, :3]

# Rotation from tracker to VTK coordinate system
self.r_stylus = up_vtk @ np.linalg.inv(up_trk)
# Rotate 90 degrees around z-axis from trk system where stylus points in x-axis
# to vtk-system where stylus points in y-axis
R = tr.euler_matrix(*np.radians([0, 0, -90]), axes="rxyz")[:3, :3]

# Rotation from tracker to VTK coordinate system
self.r_stylus = up_vtk @ np.linalg.inv(R @ up_trk @ np.linalg.inv(R))
# Save r_stylus to config file
session = ses.Session()
if (nav_config := session.GetConfig("navigation")) is not None:
Expand Down

0 comments on commit c036972

Please sign in to comment.