Commit af5e7366872af822374031de72ec54714439617b
Committed by
Thiago Franco de Moraes
1 parent
811f7ad5
Exists in
master
Navigator updates (#170)
* Remove set button from navigation tab * Reduce panel size and cleaning * More cleaning * Updates to code standards * Support to the fourth FTsensor
Showing
4 changed files
with
49 additions
and
52 deletions
Show diff stats
invesalius/constants.py
@@ -708,6 +708,7 @@ STATIC_REF = 0 | @@ -708,6 +708,7 @@ STATIC_REF = 0 | ||
708 | DYNAMIC_REF = 1 | 708 | DYNAMIC_REF = 1 |
709 | DEFAULT_REF_MODE = DYNAMIC_REF | 709 | DEFAULT_REF_MODE = DYNAMIC_REF |
710 | REF_MODE = [_("Static ref."), _("Dynamic ref.")] | 710 | REF_MODE = [_("Static ref."), _("Dynamic ref.")] |
711 | +FT_SENSOR_MODE = [_("Sensor 3"), _("Sensor 4")] | ||
711 | 712 | ||
712 | DEFAULT_COIL = SELECT | 713 | DEFAULT_COIL = SELECT |
713 | COIL = [_("Select coil:"), _("Neurosoft Figure-8"), | 714 | COIL = [_("Select coil:"), _("Neurosoft Figure-8"), |
@@ -735,13 +736,11 @@ TIPS_IMG = [_("Select left ear in image"), | @@ -735,13 +736,11 @@ TIPS_IMG = [_("Select left ear in image"), | ||
735 | 736 | ||
736 | BTNS_TRK = {TR1: {3: _('LET')}, | 737 | BTNS_TRK = {TR1: {3: _('LET')}, |
737 | TR2: {4: _('RET')}, | 738 | TR2: {4: _('RET')}, |
738 | - TR3: {5: _('NAT')}, | ||
739 | - SET: {6: _('SET')}} | 739 | + TR3: {5: _('NAT')}} |
740 | 740 | ||
741 | TIPS_TRK = [_("Select left ear with spatial tracker"), | 741 | TIPS_TRK = [_("Select left ear with spatial tracker"), |
742 | _("Select right ear with spatial tracker"), | 742 | _("Select right ear with spatial tracker"), |
743 | - _("Select nasion with spatial tracker"), | ||
744 | - _("Show set coordinates in image")] | 743 | + _("Select nasion with spatial tracker")] |
745 | 744 | ||
746 | OBJL = wx.NewId() | 745 | OBJL = wx.NewId() |
747 | OBJR = wx.NewId() | 746 | OBJR = wx.NewId() |
invesalius/data/coordinates.py
@@ -109,7 +109,10 @@ def PolhemusWrapperCoord(trck, trck_id, ref_mode): | @@ -109,7 +109,10 @@ def PolhemusWrapperCoord(trck, trck_id, ref_mode): | ||
109 | coord3 = np.array([float(trck.PositionTooltipX3) * scale[0], float(trck.PositionTooltipY3) * scale[1], | 109 | coord3 = np.array([float(trck.PositionTooltipX3) * scale[0], float(trck.PositionTooltipY3) * scale[1], |
110 | float(trck.PositionTooltipZ3) * scale[2], | 110 | float(trck.PositionTooltipZ3) * scale[2], |
111 | float(trck.AngleX3), float(trck.AngleY3), float(trck.AngleZ3)]) | 111 | float(trck.AngleX3), float(trck.AngleY3), float(trck.AngleZ3)]) |
112 | - coord = np.vstack([coord, coord3]) | 112 | + coord4 = np.array([float(trck.PositionTooltipX4) * scale[0], float(trck.PositionTooltipY4) * scale[1], |
113 | + float(trck.PositionTooltipZ4) * scale[2], | ||
114 | + float(trck.AngleX4), float(trck.AngleY4), float(trck.AngleZ4)]) | ||
115 | + coord = np.vstack([coord, coord3, coord4]) | ||
113 | 116 | ||
114 | if trck.StylusButton: | 117 | if trck.StylusButton: |
115 | Publisher.sendMessage('PLH Stylus Button On') | 118 | Publisher.sendMessage('PLH Stylus Button On') |
@@ -208,9 +211,12 @@ def DebugCoord(trk_init, trck_id, ref_mode): | @@ -208,9 +211,12 @@ def DebugCoord(trk_init, trck_id, ref_mode): | ||
208 | coord3 = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), | 211 | coord3 = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), |
209 | uniform(-180.0, 180.0), uniform(-180.0, 180.0), uniform(-180.0, 180.0)]) | 212 | uniform(-180.0, 180.0), uniform(-180.0, 180.0), uniform(-180.0, 180.0)]) |
210 | 213 | ||
214 | + coord4 = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), | ||
215 | + uniform(-180.0, 180.0), uniform(-180.0, 180.0), uniform(-180.0, 180.0)]) | ||
216 | + | ||
211 | Publisher.sendMessage('Sensors ID', probe_id=int(uniform(0, 5)), ref_id=int(uniform(0, 5))) | 217 | Publisher.sendMessage('Sensors ID', probe_id=int(uniform(0, 5)), ref_id=int(uniform(0, 5))) |
212 | 218 | ||
213 | - return np.vstack([coord1, coord2, coord3]) | 219 | + return np.vstack([coord1, coord2, coord3, coord4]) |
214 | 220 | ||
215 | 221 | ||
216 | def dynamic_reference(probe, reference): | 222 | def dynamic_reference(probe, reference): |
invesalius/gui/dialogs.py
@@ -3487,8 +3487,19 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3487,8 +3487,19 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3487 | choice_ref.SetSelection(self.obj_ref_id) | 3487 | choice_ref.SetSelection(self.obj_ref_id) |
3488 | choice_ref.SetToolTip(tooltip) | 3488 | choice_ref.SetToolTip(tooltip) |
3489 | choice_ref.Bind(wx.EVT_COMBOBOX, self.OnChoiceRefMode) | 3489 | choice_ref.Bind(wx.EVT_COMBOBOX, self.OnChoiceRefMode) |
3490 | - if self.tracker_id != const.MTC: | ||
3491 | - choice_ref.Enable(0) | 3490 | + choice_ref.Enable(0) |
3491 | + if self.tracker_id == const.MTC or self.tracker_id == const.FASTRAK or self.tracker_id == const.DEBUGTRACK: | ||
3492 | + choice_ref.Enable(1) | ||
3493 | + | ||
3494 | + # ComboBox for sensor selection for FASTRAK | ||
3495 | + tooltip = wx.ToolTip(_(u"Choose the FASTRAK sensor port")) | ||
3496 | + choice_sensor = wx.ComboBox(self, -1, "", size=wx.Size(90, 23), | ||
3497 | + choices=const.FT_SENSOR_MODE, style=wx.CB_DROPDOWN | wx.CB_READONLY) | ||
3498 | + choice_sensor.SetSelection(0) | ||
3499 | + choice_sensor.SetToolTip(tooltip) | ||
3500 | + choice_sensor.Bind(wx.EVT_COMBOBOX, self.OnChoiceFTSensor) | ||
3501 | + choice_sensor.Show(False) | ||
3502 | + self.choice_sensor = choice_sensor | ||
3492 | 3503 | ||
3493 | # Buttons to finish or cancel object registration | 3504 | # Buttons to finish or cancel object registration |
3494 | tooltip = wx.ToolTip(_(u"Registration done")) | 3505 | tooltip = wx.ToolTip(_(u"Registration done")) |
@@ -3496,9 +3507,10 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3496,9 +3507,10 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3496 | btn_ok = wx.Button(self, wx.ID_OK, _(u"Done"), size=wx.Size(90, 30)) | 3507 | btn_ok = wx.Button(self, wx.ID_OK, _(u"Done"), size=wx.Size(90, 30)) |
3497 | btn_ok.SetToolTip(tooltip) | 3508 | btn_ok.SetToolTip(tooltip) |
3498 | 3509 | ||
3499 | - extra_sizer = wx.FlexGridSizer(rows=2, cols=1, hgap=5, vgap=30) | 3510 | + extra_sizer = wx.FlexGridSizer(rows=3, cols=1, hgap=5, vgap=30) |
3500 | extra_sizer.AddMany([choice_ref, | 3511 | extra_sizer.AddMany([choice_ref, |
3501 | - btn_ok]) | 3512 | + btn_ok, |
3513 | + choice_sensor]) | ||
3502 | 3514 | ||
3503 | # Push buttons for object fiducials | 3515 | # Push buttons for object fiducials |
3504 | btns_obj = const.BTNS_OBJ | 3516 | btns_obj = const.BTNS_OBJ |
@@ -3651,7 +3663,7 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3651,7 +3663,7 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3651 | if self.trk_init and self.tracker_id: | 3663 | if self.trk_init and self.tracker_id: |
3652 | coord_raw = dco.GetCoordinates(self.trk_init, self.tracker_id, self.obj_ref_id) | 3664 | coord_raw = dco.GetCoordinates(self.trk_init, self.tracker_id, self.obj_ref_id) |
3653 | if self.obj_ref_id and btn_id == 4: | 3665 | if self.obj_ref_id and btn_id == 4: |
3654 | - coord = coord_raw[2, :] | 3666 | + coord = coord_raw[self.obj_ref_id, :] |
3655 | else: | 3667 | else: |
3656 | coord = coord_raw[0, :] | 3668 | coord = coord_raw[0, :] |
3657 | else: | 3669 | else: |
@@ -3680,6 +3692,9 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3680,6 +3692,9 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3680 | 3692 | ||
3681 | if evt.GetSelection(): | 3693 | if evt.GetSelection(): |
3682 | self.obj_ref_id = 2 | 3694 | self.obj_ref_id = 2 |
3695 | + if self.tracker_id == const.FASTRAK or self.tracker_id == const.DEBUGTRACK: | ||
3696 | + self.choice_sensor.Show(True) | ||
3697 | + self.Layout() | ||
3683 | else: | 3698 | else: |
3684 | self.obj_ref_id = 0 | 3699 | self.obj_ref_id = 0 |
3685 | for m in range(0, 5): | 3700 | for m in range(0, 5): |
@@ -3688,6 +3703,12 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3688,6 +3703,12 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3688 | for n in range(0, 3): | 3703 | for n in range(0, 3): |
3689 | self.txt_coord[m][n].SetLabel('-') | 3704 | self.txt_coord[m][n].SetLabel('-') |
3690 | 3705 | ||
3706 | + def OnChoiceFTSensor(self, evt): | ||
3707 | + if evt.GetSelection(): | ||
3708 | + self.obj_ref_id = 3 | ||
3709 | + else: | ||
3710 | + self.obj_ref_id = 0 | ||
3711 | + | ||
3691 | def GetValue(self): | 3712 | def GetValue(self): |
3692 | return self.obj_fiducials, self.obj_orients, self.obj_ref_id, self.obj_name | 3713 | return self.obj_fiducials, self.obj_orients, self.obj_ref_id, self.obj_name |
3693 | 3714 |
invesalius/gui/task_navigator.py
@@ -134,13 +134,9 @@ class InnerFoldPanel(wx.Panel): | @@ -134,13 +134,9 @@ class InnerFoldPanel(wx.Panel): | ||
134 | # is not working properly in this panel. It might be on some child or | 134 | # is not working properly in this panel. It might be on some child or |
135 | # parent panel. Perhaps we need to insert the item into the sizer also... | 135 | # parent panel. Perhaps we need to insert the item into the sizer also... |
136 | # Study this. | 136 | # Study this. |
137 | - displaySize = wx.DisplaySize() | ||
138 | - if displaySize[1] > 768: | ||
139 | - fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, | ||
140 | - (10, 350), 0, fpb.FPB_SINGLE_FOLD) | ||
141 | - else: | ||
142 | - fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, | ||
143 | - (10, 320), 0, fpb.FPB_SINGLE_FOLD) | 137 | + |
138 | + fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, | ||
139 | + (10, 290), 0, fpb.FPB_SINGLE_FOLD) | ||
144 | # Fold panel style | 140 | # Fold panel style |
145 | style = fpb.CaptionBarStyle() | 141 | style = fpb.CaptionBarStyle() |
146 | style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V) | 142 | style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V) |
@@ -305,8 +301,8 @@ class NeuronavigationPanel(wx.Panel): | @@ -305,8 +301,8 @@ class NeuronavigationPanel(wx.Panel): | ||
305 | self.ref_mode_id = const.DEFAULT_REF_MODE | 301 | self.ref_mode_id = const.DEFAULT_REF_MODE |
306 | 302 | ||
307 | # Initialize list of buttons and numctrls for wx objects | 303 | # Initialize list of buttons and numctrls for wx objects |
308 | - self.btns_coord = [None] * 7 | ||
309 | - self.numctrls_coord = [list(), list(), list(), list(), list(), list(), list()] | 304 | + self.btns_coord = [None, None, None, None, None, None] |
305 | + self.numctrls_coord = [[], [], [], [], [], []] | ||
310 | 306 | ||
311 | # ComboBox for spatial tracker device selection | 307 | # ComboBox for spatial tracker device selection |
312 | tooltip = wx.ToolTip(_("Choose the tracking device")) | 308 | tooltip = wx.ToolTip(_("Choose the tracking device")) |
@@ -345,11 +341,7 @@ class NeuronavigationPanel(wx.Panel): | @@ -345,11 +341,7 @@ class NeuronavigationPanel(wx.Panel): | ||
345 | lab = list(btns_trk[k].values())[0] | 341 | lab = list(btns_trk[k].values())[0] |
346 | self.btns_coord[n] = wx.Button(self, k, label=lab, size=wx.Size(45, 23)) | 342 | self.btns_coord[n] = wx.Button(self, k, label=lab, size=wx.Size(45, 23)) |
347 | self.btns_coord[n].SetToolTip(wx.ToolTip(tips_trk[n-3])) | 343 | self.btns_coord[n].SetToolTip(wx.ToolTip(tips_trk[n-3])) |
348 | - # Exception for event of button that set image coordinates | ||
349 | - if n == 6: | ||
350 | - self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnSetImageCoordinates) | ||
351 | - else: | ||
352 | - self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnTrackerFiducials) | 344 | + self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnTrackerFiducials) |
353 | 345 | ||
354 | # TODO: Find a better allignment between FRE, text and navigate button | 346 | # TODO: Find a better allignment between FRE, text and navigate button |
355 | txt_fre = wx.StaticText(self, -1, _('FRE:')) | 347 | txt_fre = wx.StaticText(self, -1, _('FRE:')) |
@@ -370,8 +362,8 @@ class NeuronavigationPanel(wx.Panel): | @@ -370,8 +362,8 @@ class NeuronavigationPanel(wx.Panel): | ||
370 | btn_nav.Bind(wx.EVT_TOGGLEBUTTON, partial(self.OnNavigate, btn=(btn_nav, choice_trck, choice_ref))) | 362 | btn_nav.Bind(wx.EVT_TOGGLEBUTTON, partial(self.OnNavigate, btn=(btn_nav, choice_trck, choice_ref))) |
371 | 363 | ||
372 | # Image and tracker coordinates number controls | 364 | # Image and tracker coordinates number controls |
373 | - for m in range(0, 7): | ||
374 | - for n in range(0, 3): | 365 | + for m in range(len(self.btns_coord)): |
366 | + for n in range(3): | ||
375 | self.numctrls_coord[m].append( | 367 | self.numctrls_coord[m].append( |
376 | wx.lib.masked.numctrl.NumCtrl(parent=self, integerWidth=4, fractionWidth=1)) | 368 | wx.lib.masked.numctrl.NumCtrl(parent=self, integerWidth=4, fractionWidth=1)) |
377 | 369 | ||
@@ -382,9 +374,9 @@ class NeuronavigationPanel(wx.Panel): | @@ -382,9 +374,9 @@ class NeuronavigationPanel(wx.Panel): | ||
382 | 374 | ||
383 | coord_sizer = wx.GridBagSizer(hgap=5, vgap=5) | 375 | coord_sizer = wx.GridBagSizer(hgap=5, vgap=5) |
384 | 376 | ||
385 | - for m in range(0, 7): | 377 | + for m in range(len(self.btns_coord)): |
386 | coord_sizer.Add(self.btns_coord[m], pos=wx.GBPosition(m, 0)) | 378 | coord_sizer.Add(self.btns_coord[m], pos=wx.GBPosition(m, 0)) |
387 | - for n in range(0, 3): | 379 | + for n in range(3): |
388 | coord_sizer.Add(self.numctrls_coord[m][n], pos=wx.GBPosition(m, n+1)) | 380 | coord_sizer.Add(self.numctrls_coord[m][n], pos=wx.GBPosition(m, n+1)) |
389 | if m in range(1, 6): | 381 | if m in range(1, 6): |
390 | self.numctrls_coord[m][n].SetEditable(False) | 382 | self.numctrls_coord[m][n].SetEditable(False) |
@@ -432,13 +424,8 @@ class NeuronavigationPanel(wx.Panel): | @@ -432,13 +424,8 @@ class NeuronavigationPanel(wx.Panel): | ||
432 | def UpdateImageCoordinates(self, position): | 424 | def UpdateImageCoordinates(self, position): |
433 | # TODO: Change from world coordinates to matrix coordinates. They are better for multi software communication. | 425 | # TODO: Change from world coordinates to matrix coordinates. They are better for multi software communication. |
434 | self.current_coord = position | 426 | self.current_coord = position |
435 | - for m in [0, 1, 2, 6]: | ||
436 | - if m == 6 and self.btns_coord[m].IsEnabled(): | ||
437 | - for n in [0, 1, 2]: | ||
438 | - self.numctrls_coord[m][n].SetValue(float(self.current_coord[n])) | ||
439 | - elif m != 6 and not self.btns_coord[m].GetValue(): | ||
440 | - # btn_state = self.btns_coord[m].GetValue() | ||
441 | - # if not btn_state: | 427 | + for m in [0, 1, 2]: |
428 | + if not self.btns_coord[m].GetValue(): | ||
442 | for n in [0, 1, 2]: | 429 | for n in [0, 1, 2]: |
443 | self.numctrls_coord[m][n].SetValue(float(self.current_coord[n])) | 430 | self.numctrls_coord[m][n].SetValue(float(self.current_coord[n])) |
444 | 431 | ||
@@ -544,19 +531,6 @@ class NeuronavigationPanel(wx.Panel): | @@ -544,19 +531,6 @@ class NeuronavigationPanel(wx.Panel): | ||
544 | nav_prop=(self.tracker_id, self.trk_init, self.ref_mode_id)) | 531 | nav_prop=(self.tracker_id, self.trk_init, self.ref_mode_id)) |
545 | print("Reference mode changed!") | 532 | print("Reference mode changed!") |
546 | 533 | ||
547 | - def OnSetImageCoordinates(self, evt): | ||
548 | - # FIXME: Cross does not update in last clicked slice, only on the other two | ||
549 | - btn_id = list(const.BTNS_TRK[evt.GetId()].keys())[0] | ||
550 | - | ||
551 | - ux, uy, uz = self.numctrls_coord[btn_id][0].GetValue(),\ | ||
552 | - self.numctrls_coord[btn_id][1].GetValue(),\ | ||
553 | - self.numctrls_coord[btn_id][2].GetValue() | ||
554 | - | ||
555 | - Publisher.sendMessage('Set ball reference position', position=(ux, uy, uz)) | ||
556 | - # Publisher.sendMessage('Set camera in volume', (ux, uy, uz)) | ||
557 | - Publisher.sendMessage('Co-registered points', arg=(ux, uy, uz), position=(0., 0., 0.)) | ||
558 | - Publisher.sendMessage('Update cross position', position=(ux, uy, uz)) | ||
559 | - | ||
560 | def OnImageFiducials(self, evt): | 534 | def OnImageFiducials(self, evt): |
561 | btn_id = list(const.BTNS_IMG_MKS[evt.GetId()].keys())[0] | 535 | btn_id = list(const.BTNS_IMG_MKS[evt.GetId()].keys())[0] |
562 | marker_id = list(const.BTNS_IMG_MKS[evt.GetId()].values())[0] | 536 | marker_id = list(const.BTNS_IMG_MKS[evt.GetId()].values())[0] |
@@ -714,9 +688,6 @@ class NeuronavigationPanel(wx.Panel): | @@ -714,9 +688,6 @@ class NeuronavigationPanel(wx.Panel): | ||
714 | for n in range(0, 3): | 688 | for n in range(0, 3): |
715 | self.numctrls_coord[m][n].SetValue(0.0) | 689 | self.numctrls_coord[m][n].SetValue(0.0) |
716 | 690 | ||
717 | - for n in range(0, 3): | ||
718 | - self.numctrls_coord[6][n].SetValue(0.0) | ||
719 | - | ||
720 | def ResetTrackerFiducials(self): | 691 | def ResetTrackerFiducials(self): |
721 | for m in range(3, 6): | 692 | for m in range(3, 6): |
722 | self.fiducials[m, :] = [np.nan, np.nan, np.nan] | 693 | self.fiducials[m, :] = [np.nan, np.nan, np.nan] |