예제 #1
0
    def UpdateFiducialRegistrationError(self, tracker):
        tracker_fiducials, tracker_fiducials_raw = tracker.GetTrackerFiducials(
        )

        self.all_fiducials = np.vstack(
            [self.image_fiducials, tracker_fiducials])

        self.fre = db.calculate_fre(tracker_fiducials_raw, self.all_fiducials,
                                    self.ref_mode_id, self.m_change)
예제 #2
0
    def OnNavigate(self, evt, btn):
        btn_nav = btn[0]
        choice_trck = btn[1]
        choice_ref = btn[2]
        txtctrl_fre = btn[3]

        nav_id = btn_nav.GetValue()
        if nav_id:
            if np.isnan(self.fiducials).any():
                dlg.InvalidFiducials()
                btn_nav.SetValue(False)

            else:
                tooltip = wx.ToolTip(_("Stop neuronavigation"))
                btn_nav.SetToolTip(tooltip)

                # Disable all navigation buttons
                choice_ref.Enable(False)
                choice_trck.Enable(False)
                for btn_c in self.btns_coord:
                    btn_c.Enable(False)

                m, q1, minv = db.base_creation(self.fiducials[0:3, :])
                n, q2, ninv = db.base_creation(self.fiducials[3::, :])

                tracker_mode = self.trk_init, self.tracker_id, self.ref_mode_id
                # FIXME: FRE is taking long to calculate so it updates on GUI delayed to navigation - I think its fixed
                # TODO: Exhibit FRE in a warning dialog and only starts navigation after user clicks ok
                fre = db.calculate_fre(self.fiducials, minv, n, q1, q2)

                txtctrl_fre.SetValue(str(round(fre, 2)))
                if fre <= 3:
                    txtctrl_fre.SetBackgroundColour('GREEN')
                else:
                    txtctrl_fre.SetBackgroundColour('RED')

                if self.trigger_state:
                    self.trigger = trig.Trigger(nav_id)

                self.correg = dcr.Coregistration((minv, n, q1, q2), nav_id,
                                                 tracker_mode)

        else:
            tooltip = wx.ToolTip(_("Start neuronavigation"))
            btn_nav.SetToolTip(tooltip)

            # Enable all navigation buttons
            choice_ref.Enable(True)
            choice_trck.Enable(True)
            for btn_c in self.btns_coord:
                btn_c.Enable(True)

            if self.trigger_state:
                self.trigger.stop()

            self.correg.stop()
예제 #3
0
    def StartICP(self, navigation, tracker):
        ref_mode_id = navigation.GetReferenceMode()

        if not self.use_icp:
            if dlg.ICPcorregistration(navigation.fre):
                use_icp, self.m_icp = self.OnICP(navigation, tracker, navigation.m_change)
                if use_icp:
                    self.icp_fre = db.calculate_fre(tracker.tracker_fiducials_raw, navigation.all_fiducials,
                                                    ref_mode_id, navigation.m_change, self.m_icp)
                    self.SetICP(navigation, use_icp)
                else:
                    print("ICP canceled")