Commit 96989be92f00bcf52490d63b6316dd88d4c89176
Committed by
GitHub
1 parent
75b09af5
Exists in
master
CLP: Move ICP class to its own file (icp.py) (#356)
* CLP: Move ICP class to its own file (icp.py) * CLP: Remove unused imports from task_navigator.py
Showing
2 changed files
with
81 additions
and
67 deletions
Show diff stats
invesalius/gui/task_navigator.py
... | ... | @@ -19,11 +19,7 @@ |
19 | 19 | |
20 | 20 | from functools import partial |
21 | 21 | import csv |
22 | -import os | |
23 | -import queue | |
24 | -import sys | |
25 | 22 | import time |
26 | -import threading | |
27 | 23 | |
28 | 24 | import nibabel as nb |
29 | 25 | import numpy as np |
... | ... | @@ -35,10 +31,8 @@ except ImportError: |
35 | 31 | import wx |
36 | 32 | |
37 | 33 | try: |
38 | - import wx.lib.agw.hyperlink as hl | |
39 | 34 | import wx.lib.agw.foldpanelbar as fpb |
40 | 35 | except ImportError: |
41 | - import wx.lib.hyperlink as hl | |
42 | 36 | import wx.lib.foldpanelbar as fpb |
43 | 37 | |
44 | 38 | import wx.lib.colourselect as csel |
... | ... | @@ -47,24 +41,19 @@ from invesalius.pubsub import pub as Publisher |
47 | 41 | from time import sleep |
48 | 42 | |
49 | 43 | import invesalius.constants as const |
50 | -import invesalius.data.bases as db | |
51 | 44 | |
52 | 45 | if has_trekker: |
53 | 46 | import invesalius.data.brainmesh_handler as brain |
54 | 47 | |
55 | -import invesalius.data.coordinates as dco | |
56 | -import invesalius.data.coregistration as dcr | |
57 | -import invesalius.data.serial_port_connection as spc | |
58 | 48 | import invesalius.data.slice_ as sl |
59 | -import invesalius.data.trackers as dt | |
60 | 49 | import invesalius.data.tractography as dti |
61 | -import invesalius.data.transformations as tr | |
62 | 50 | import invesalius.data.record_coords as rec |
63 | 51 | import invesalius.data.vtk_utils as vtk_utils |
64 | 52 | import invesalius.gui.dialogs as dlg |
65 | 53 | import invesalius.project as prj |
66 | 54 | from invesalius import utils |
67 | 55 | from invesalius.gui import utils as gui_utils |
56 | +from invesalius.navigation.icp import ICP | |
68 | 57 | from invesalius.navigation.navigation import Navigation |
69 | 58 | from invesalius.navigation.tracker import Tracker |
70 | 59 | |
... | ... | @@ -317,61 +306,6 @@ class InnerFoldPanel(wx.Panel): |
317 | 306 | Publisher.sendMessage('Update volume camera state', camera_state=self.checkcamera.GetValue()) |
318 | 307 | |
319 | 308 | |
320 | -class ICP(): | |
321 | - def __init__(self): | |
322 | - self.use_icp = False | |
323 | - self.m_icp = None | |
324 | - self.icp_fre = None | |
325 | - | |
326 | - def StartICP(self, navigation, tracker): | |
327 | - ref_mode_id = navigation.GetReferenceMode() | |
328 | - | |
329 | - if not self.use_icp: | |
330 | - if dlg.ICPcorregistration(navigation.fre): | |
331 | - Publisher.sendMessage('Stop navigation') | |
332 | - use_icp, self.m_icp = self.OnICP(navigation, tracker, navigation.m_change) | |
333 | - if use_icp: | |
334 | - self.icp_fre = db.calculate_fre(tracker.tracker_fiducials_raw, navigation.all_fiducials, | |
335 | - ref_mode_id, navigation.m_change, self.m_icp) | |
336 | - self.SetICP(navigation, use_icp) | |
337 | - else: | |
338 | - print("ICP canceled") | |
339 | - Publisher.sendMessage('Start navigation') | |
340 | - | |
341 | - def OnICP(self, navigation, tracker, m_change): | |
342 | - ref_mode_id = navigation.GetReferenceMode() | |
343 | - | |
344 | - dialog = dlg.ICPCorregistrationDialog(nav_prop=(m_change, tracker.tracker_id, tracker.trk_init, ref_mode_id)) | |
345 | - | |
346 | - if dialog.ShowModal() == wx.ID_OK: | |
347 | - m_icp, point_coord, transformed_points, prev_error, final_error = dialog.GetValue() | |
348 | - # TODO: checkbox in the dialog to transfer the icp points to 3D viewer | |
349 | - #create markers | |
350 | - # for i in range(len(point_coord)): | |
351 | - # img_coord = point_coord[i][0],-point_coord[i][1],point_coord[i][2], 0, 0, 0 | |
352 | - # transf_coord = transformed_points[i][0],-transformed_points[i][1],transformed_points[i][2], 0, 0, 0 | |
353 | - # Publisher.sendMessage('Create marker', coord=img_coord, marker_id=None, colour=(1,0,0)) | |
354 | - # Publisher.sendMessage('Create marker', coord=transf_coord, marker_id=None, colour=(0,0,1)) | |
355 | - if m_icp is not None: | |
356 | - dlg.ReportICPerror(prev_error, final_error) | |
357 | - use_icp = True | |
358 | - else: | |
359 | - use_icp = False | |
360 | - | |
361 | - return use_icp, m_icp | |
362 | - | |
363 | - else: | |
364 | - return self.use_icp, self.m_icp | |
365 | - | |
366 | - def SetICP(self, navigation, use_icp): | |
367 | - self.use_icp = use_icp | |
368 | - navigation.icp_queue.put_nowait([self.use_icp, self.m_icp]) | |
369 | - | |
370 | - def ResetICP(self): | |
371 | - self.use_icp = False | |
372 | - self.m_icp = None | |
373 | - self.icp_fre = None | |
374 | - | |
375 | 309 | class NeuronavigationPanel(wx.Panel): |
376 | 310 | def __init__(self, parent, tracker, pedal_connection): |
377 | 311 | wx.Panel.__init__(self, parent) | ... | ... |
... | ... | @@ -0,0 +1,80 @@ |
1 | +#-------------------------------------------------------------------------- | |
2 | +# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas | |
3 | +# Copyright: (C) 2001 Centro de Pesquisas Renato Archer | |
4 | +# Homepage: http://www.softwarepublico.gov.br | |
5 | +# Contact: invesalius@cti.gov.br | |
6 | +# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) | |
7 | +#-------------------------------------------------------------------------- | |
8 | +# Este programa e software livre; voce pode redistribui-lo e/ou | |
9 | +# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme | |
10 | +# publicada pela Free Software Foundation; de acordo com a versao 2 | |
11 | +# da Licenca. | |
12 | +# | |
13 | +# Este programa eh distribuido na expectativa de ser util, mas SEM | |
14 | +# QUALQUER GARANTIA; sem mesmo a garantia implicita de | |
15 | +# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | |
16 | +# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | |
17 | +# detalhes. | |
18 | +#-------------------------------------------------------------------------- | |
19 | + | |
20 | +import wx | |
21 | + | |
22 | +import invesalius.data.bases as db | |
23 | +import invesalius.gui.dialogs as dlg | |
24 | +from invesalius.pubsub import pub as Publisher | |
25 | + | |
26 | + | |
27 | +class ICP(): | |
28 | + def __init__(self): | |
29 | + self.use_icp = False | |
30 | + self.m_icp = None | |
31 | + self.icp_fre = None | |
32 | + | |
33 | + def StartICP(self, navigation, tracker): | |
34 | + ref_mode_id = navigation.GetReferenceMode() | |
35 | + | |
36 | + if not self.use_icp: | |
37 | + if dlg.ICPcorregistration(navigation.fre): | |
38 | + Publisher.sendMessage('Stop navigation') | |
39 | + use_icp, self.m_icp = self.OnICP(navigation, tracker, navigation.m_change) | |
40 | + if use_icp: | |
41 | + self.icp_fre = db.calculate_fre(tracker.tracker_fiducials_raw, navigation.all_fiducials, | |
42 | + ref_mode_id, navigation.m_change, self.m_icp) | |
43 | + self.SetICP(navigation, use_icp) | |
44 | + else: | |
45 | + print("ICP canceled") | |
46 | + Publisher.sendMessage('Start navigation') | |
47 | + | |
48 | + def OnICP(self, navigation, tracker, m_change): | |
49 | + ref_mode_id = navigation.GetReferenceMode() | |
50 | + | |
51 | + dialog = dlg.ICPCorregistrationDialog(nav_prop=(m_change, tracker.tracker_id, tracker.trk_init, ref_mode_id)) | |
52 | + | |
53 | + if dialog.ShowModal() == wx.ID_OK: | |
54 | + m_icp, point_coord, transformed_points, prev_error, final_error = dialog.GetValue() | |
55 | + # TODO: checkbox in the dialog to transfer the icp points to 3D viewer | |
56 | + #create markers | |
57 | + # for i in range(len(point_coord)): | |
58 | + # img_coord = point_coord[i][0],-point_coord[i][1],point_coord[i][2], 0, 0, 0 | |
59 | + # transf_coord = transformed_points[i][0],-transformed_points[i][1],transformed_points[i][2], 0, 0, 0 | |
60 | + # Publisher.sendMessage('Create marker', coord=img_coord, marker_id=None, colour=(1,0,0)) | |
61 | + # Publisher.sendMessage('Create marker', coord=transf_coord, marker_id=None, colour=(0,0,1)) | |
62 | + if m_icp is not None: | |
63 | + dlg.ReportICPerror(prev_error, final_error) | |
64 | + use_icp = True | |
65 | + else: | |
66 | + use_icp = False | |
67 | + | |
68 | + return use_icp, m_icp | |
69 | + | |
70 | + else: | |
71 | + return self.use_icp, self.m_icp | |
72 | + | |
73 | + def SetICP(self, navigation, use_icp): | |
74 | + self.use_icp = use_icp | |
75 | + navigation.icp_queue.put_nowait([self.use_icp, self.m_icp]) | |
76 | + | |
77 | + def ResetICP(self): | |
78 | + self.use_icp = False | |
79 | + self.m_icp = None | |
80 | + self.icp_fre = None | ... | ... |