Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neuronavigation GUI revamp #643

Merged
merged 109 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
fbd60a2
Revert "MOD: Add status icons for tracker"
mahanshul Jun 27, 2023
288b4fd
Merge branch 'invesalius:master' into master
mahansh564 Jun 27, 2023
77d1420
Merge branch 'invesalius:master' into master
mahansh564 Jun 28, 2023
e6bfb4a
Merge branch 'invesalius:master' into master
mahansh564 Jul 2, 2023
7a084d5
Merge branch 'invesalius:master' into master
mahansh564 Jul 2, 2023
993b10f
ADD: New menu for imports section in NAV mode
mahanshul Jul 3, 2023
4319bac
MOD: Change current menu items based on new menu
mahanshul Jul 3, 2023
6dc9e82
FIX: Load data for new menu
mahanshul Jul 3, 2023
6ba7836
FIX: Remove duplicate markers on update
mahanshul Jul 3, 2023
8db6e89
ADD: head icon for fiducial panel
mahansh564 Jul 7, 2023
12abe81
ADD: new task panels for import secton
mahansh564 Jul 7, 2023
e07c26b
MOD: Button labels &ADD: New labels
mahansh564 Jul 7, 2023
de5c450
ADD: New function to check if individual tracker fiducials are set
mahansh564 Jul 7, 2023
5ef2ec4
MOD: Minor UI changes
mahansh564 Jul 7, 2023
cda5d77
MOD: Navigation Section
mahansh564 Jul 7, 2023
37c172d
REM: Unfinished code
mahansh564 Jul 7, 2023
6ff0c9d
MOD: Combine 2D and 3D visualization preferences into one tab
mahansh564 Jul 10, 2023
e02f608
MOD: Separate robot from tracker
mahansh564 Jul 11, 2023
47b88a9
ADD: tracker and robot in preferences
mahansh564 Jul 11, 2023
8042bb2
FIX: robot connection
okahilak Jul 12, 2023
47d6d83
ADD: Object preferences
mahansh564 Jul 13, 2023
5b1267c
Merge branch 'invesalius:master' into master
mahansh564 Jul 13, 2023
743e4dd
Merge branch 'master' into neuronavigation-GUI-revamp
mahansh564 Jul 13, 2023
846df53
MOD: Make controller classes singleton
mahansh564 Jul 18, 2023
0c181ff
FIX: Navigation bug fix
mahansh564 Jul 18, 2023
47c084e
FIX: minor fixes
mahansh564 Jul 18, 2023
141a43b
MOD: move object settings to config
mahansh564 Jul 18, 2023
8916fe5
MOD: move tracker to config
mahansh564 Jul 18, 2023
072fd1c
FIX: Navigation bug fixes
mahansh564 Jul 18, 2023
70c5c09
ADD: stimulator preferences
mahansh564 Jul 18, 2023
3d95c2a
ADD: External trigger for prefences
mahansh564 Jul 18, 2023
31e77a8
MOD: Stimulator page
mahansh564 Jul 18, 2023
b45720a
FIX: minor UI changes
mahansh564 Jul 19, 2023
d437781
ADD: Minor UI changes
mahansh564 Jul 19, 2023
71aadcd
ADD: FOD progress window
mahansh564 Jul 19, 2023
7054231
ADD: progress functionality in FOD
mahansh564 Jul 19, 2023
4eb1e0d
FIX: bug fix
mahansh564 Jul 19, 2023
d4922f3
FIX: pedal bug fixes
mahansh564 Jul 20, 2023
3fbd923
FIX: pedal bug fix
mahansh564 Jul 20, 2023
c43bb70
FIX: Trekker progress bug fix
mahansh564 Jul 20, 2023
e2f9e83
Merge branch 'invesalius:master' into master
mahansh564 Jul 24, 2023
212d185
ADD: Tool bar in navigation
mahansh564 Jul 26, 2023
e877b37
FIX: bug fix
mahansh564 Jul 26, 2023
ba222ad
REM: Robot tracker
mahansh564 Jul 26, 2023
b84bb2e
ADD: native robot connection from preferences
mahansh564 Jul 26, 2023
0968974
FIX: Bug Fix
mahansh564 Jul 27, 2023
71311d0
FIX: Tracker fiducial recording
mahansh564 Aug 1, 2023
17aceac
FIX: robot bugs
mahansh564 Aug 3, 2023
4c36580
ADD: Robot saving to config
mahansh564 Aug 4, 2023
70fb1d2
FIX: Robot connection
mahansh564 Aug 4, 2023
d8afe6e
FIX: UI bug fix
mahansh564 Aug 4, 2023
2188c6f
ADD: External setting of robot IP
mahansh564 Aug 4, 2023
e82d227
FIX: robot connection bug fix
mahansh564 Aug 4, 2023
d83cfa9
FIX: Undesired error message
mahansh564 Aug 4, 2023
806ca20
ADD: busy cursor for tracker setup
mahansh564 Aug 4, 2023
8b9e1f7
FIX: Minor UI Bug Fix
mahansh564 Aug 4, 2023
3419c6e
ADD: Target Mode in icon bar
mahansh564 Aug 4, 2023
0d50a77
CLP: clean tracker
mahansh564 Aug 9, 2023
84958ec
CLP: clean robot
mahansh564 Aug 9, 2023
a6fc770
CLP: clean navigation
mahansh564 Aug 9, 2023
54e2a5e
CLP: clean tractography
mahansh564 Aug 9, 2023
4ea834d
CLP: clean navigator task
mahansh564 Aug 9, 2023
4938f4d
CLP: clean preferences
mahansh564 Aug 9, 2023
fddd7c6
FIX: convert state to config
mahansh564 Aug 9, 2023
95acf73
CLP: clean tracker connection
mahansh564 Aug 9, 2023
8893367
Merge branch 'invesalius:master' into master
mahansh564 Aug 9, 2023
5ea45e8
FIX: bug fix
mahansh564 Aug 10, 2023
e3014d2
FIX: bug fix
mahansh564 Aug 10, 2023
979dbec
FIX: bug fix
mahansh564 Aug 10, 2023
7758202
FIX: bug fix
mahansh564 Aug 10, 2023
045f366
FIX: bug fix
mahansh564 Aug 10, 2023
9eb391f
FIX: bug fix
mahansh564 Aug 10, 2023
40c3e94
Merge branch 'invesalius:master' into master
mahansh564 Aug 11, 2023
b15dedc
Merge branch 'master' into neuronavigation-GUI-revamp
mahansh564 Aug 11, 2023
cdbc01b
FIX: merging bugs
mahansh564 Aug 11, 2023
3f2b941
FIX: Bug Fix
mahansh564 Aug 14, 2023
fb87e6c
FIX: Target mode
mahansh564 Aug 14, 2023
f437870
FIX: Object registration
mahansh564 Aug 14, 2023
23bc039
UPD: Minor update to object in preferences
mahansh564 Aug 15, 2023
5ffe220
ADD: Sleep Time configuration
mahansh564 Aug 15, 2023
9d3106c
ADD: Sleep time configuration
mahansh564 Aug 15, 2023
436efc7
FIX: Live Tractography
mahansh564 Aug 15, 2023
b900c84
FIX: Minor bug fix
mahansh564 Aug 15, 2023
05800d6
FIX: Tracker fiducials saved in config
mahansh564 Aug 15, 2023
5623ea7
FIX: Bug fix for busy cursor
mahansh564 Aug 15, 2023
d014502
REM: Sleep time from tractography
mahansh564 Aug 15, 2023
5dd0f6e
ADD: Custom page fold in preferences
mahansh564 Aug 15, 2023
e57d9d4
ADD: Progress bars for ACT, Brain
mahansh564 Aug 15, 2023
e25d545
ADD: New icons
mahansh564 Aug 15, 2023
afcb5ce
ADD: New icons to GUI
mahansh564 Aug 15, 2023
2054981
FIX: Bug fix for cross tool
mahansh564 Aug 16, 2023
b3b7ab2
ADD: Disable tabs when project not loaded
mahansh564 Aug 16, 2023
67c65de
FIX: Minor bug fix
mahansh564 Aug 16, 2023
d479fdc
FIX: SIze fixing
mahansh564 Aug 16, 2023
10a4e18
FIX: Minor bug fix
mahansh564 Aug 16, 2023
8a00127
FIX: Size bug for imports section
mahansh564 Aug 16, 2023
b326768
FIX: robot transformation dialog
rmatsuda Aug 16, 2023
aa0b4ac
FIX: Nav sleep times
mahansh564 Aug 16, 2023
0497699
UPD: Show coil enabled with nav
mahansh564 Aug 17, 2023
6e1c4d3
Fix: Panel Sizing
mahansh564 Aug 17, 2023
09c27f2
FIx: Bug fix tracker disconnection
mahansh564 Aug 17, 2023
a7880fd
FIX: Nav panel undesired behaviour
mahansh564 Aug 17, 2023
7def8aa
ADD: Reset image fiducials function
mahansh564 Aug 17, 2023
dc64b58
FIX: Close Project fixes
mahansh564 Aug 17, 2023
522d2bd
MISC: Some fixes
mahansh564 Aug 17, 2023
e868c2f
FIX: Minor Bug fix
mahansh564 Aug 17, 2023
f223f74
MOD: Make status colors color-blind friendly
mahansh564 Aug 18, 2023
69fb27b
FIX: Editable numctrl bug fix
mahansh564 Aug 18, 2023
f6bd270
FIX: Minor edits
mahansh564 Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added icons/camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/coil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/coil_eye.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/efield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/field.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/head.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/lock_to_target.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/orbit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/port.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/target.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/target_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/track.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/wave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 16 additions & 10 deletions invesalius/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@
_("Inverse Gray"):(256, (0, 0), (0, 0), (1,0)),
}

#Colors for errors and positives
RED_COLOR_FLOAT = (0.99, 0.55, 0.38)
GREEN_COLOR_FLOAT = (0.40, 0.76, 0.65)
RED_COLOR_RGB = (252, 141, 98)
GREEN_COLOR_RGB = (102, 194, 165)

# Volume view angle
VOL_FRONT = wx.NewId()
VOL_BACK = wx.NewId()
Expand Down Expand Up @@ -684,9 +690,8 @@
POLARIS = 6
POLARISP4 = 7
OPTITRACK = 8
ROBOT = 9
DEBUGTRACKRANDOM = 10
DEBUGTRACKAPPROACH = 11
DEBUGTRACKRANDOM = 9
DEBUGTRACKAPPROACH = 10
DEFAULT_TRACKER = SELECT

NDICOMPORT = b'COM1'
Expand All @@ -696,7 +701,7 @@
_("Polhemus FASTRAK"), _("Polhemus ISOTRAK II"),
_("Polhemus PATRIOT"), _("Camera tracker"),
_("NDI Polaris"), _("NDI Polaris P4"),
_("Optitrack"), _("Robot tracker"),
_("Optitrack"),
_("Debug tracker (random)"), _("Debug tracker (approach)")]

STATIC_REF = 0
Expand All @@ -717,24 +722,25 @@
TR3 = wx.NewId()
SET = wx.NewId()

FIDUCIAL_LABELS = ["Left Ear: ", "Right Ear: ", "Nose: "]
IMAGE_FIDUCIALS = [
{
'button_id': IR1,
'label': 'LEI',
'label': 'Left Ear',
'fiducial_name': 'LE',
'fiducial_index': 0,
'tip': _("Select left ear in image"),
},
{
'button_id': IR2,
'label': 'REI',
'label': 'Right Ear',
'fiducial_name': 'RE',
'fiducial_index': 1,
'tip': _("Select right ear in image"),
},
{
'button_id': IR3,
'label': 'NAI',
'label': 'Nasion',
'fiducial_name': 'NA',
'fiducial_index': 2,
'tip': _("Select nasion in image"),
Expand All @@ -744,21 +750,21 @@
TRACKER_FIDUCIALS = [
{
'button_id': TR1,
'label': 'LET',
'label': 'Left Ear',
'fiducial_name': 'LE',
'fiducial_index': 0,
'tip': _("Select left ear with spatial tracker"),
},
{
'button_id': TR2,
'label': 'RET',
'label': 'Right Ear',
'fiducial_name': 'RE',
'fiducial_index': 1,
'tip': _("Select right ear with spatial tracker"),
},
{
'button_id': TR3,
'label': 'NAT',
'label': 'Nasion',
'fiducial_name': 'NA',
'fiducial_index': 2,
'tip': _("Select nasion with spatial tracker"),
Expand Down
2 changes: 2 additions & 0 deletions invesalius/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def __bind_events(self):
Publisher.subscribe(self.enable_mask_preview, 'Enable mask 3D preview')
Publisher.subscribe(self.disable_mask_preview, 'Disable mask 3D preview')
Publisher.subscribe(self.update_mask_preview, 'Update mask 3D preview')

Publisher.subscribe(self.LoadProject, 'Load project data')

def SetBitmapSpacing(self, spacing):
proj = prj.Project()
Expand Down
12 changes: 9 additions & 3 deletions invesalius/data/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def GetCoordinatesForThread(tracker_connection, tracker_id, ref_mode):
const.POLARIS: PolarisCoord,
const.POLARISP4: PolarisP4Coord,
const.OPTITRACK: OptitrackCoord,
const.ROBOT: RobotCoord,
const.DEBUGTRACKRANDOM: DebugCoordRandom,
const.DEBUGTRACKAPPROACH: DebugCoordRandom}
coord, markers_flag = getcoord[tracker_id](tracker_connection, tracker_id, ref_mode)
Expand Down Expand Up @@ -577,14 +576,21 @@ def offset_coordinate(p_old, norm_vec, offset):
class ReceiveCoordinates(threading.Thread):
def __init__(self, tracker_connection, tracker_id, TrackerCoordinates, event):
threading.Thread.__init__(self, name='ReceiveCoordinates')

self.__bind_events()
self.sleep_coord = const.SLEEP_COORDINATES
self.tracker_connection = tracker_connection
self.tracker_id = tracker_id
self.event = event
self.TrackerCoordinates = TrackerCoordinates

def __bind_events(self):
Publisher.subscribe(self.UpdateCoordSleep, 'Update coord sleep')

def UpdateCoordSleep(self, data):
self.sleep_coord = data

def run(self):
while not self.event.is_set():
coord_raw, markers_flag = GetCoordinatesForThread(self.tracker_connection, self.tracker_id, const.DEFAULT_REF_MODE)
self.TrackerCoordinates.SetCoordinates(coord_raw, markers_flag)
sleep(const.SLEEP_COORDINATES)
sleep(self.sleep_coord)
161 changes: 83 additions & 78 deletions invesalius/data/tracker_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,88 @@ def Disconnect(self):
super().Disconnect()


class DebugTrackerRandomConnection(TrackerConnection):
def __init__(self, model=None):
super().__init__(model)

def Configure(self):
return True

def Connect(self):
self.connection = True
self.lib_mode = 'debug'
print('Debug device (random) started.')

def Disconnect(self):
self.connection = False
self.lib_mode = 'debug'
print('Debug tracker (random) disconnected.')


class DebugTrackerApproachConnection(TrackerConnection):
def __init__(self, model=None):
super().__init__(model)

def Configure(self):
return True

def Connect(self):
self.connection = True
self.lib_mode = 'debug'
print('Debug device (approach) started.')

def Disconnect(self):
self.connection = False
self.lib_mode = 'debug'
print('Debug tracker (approach) disconnected.')


TRACKER_CONNECTION_CLASSES = {
const.MTC: ClaronTrackerConnection,
const.FASTRAK: PolhemusTrackerConnection,
const.ISOTRAKII: PolhemusTrackerConnection,
const.PATRIOT: PolhemusTrackerConnection,
const.CAMERA: CameraTrackerConnection,
const.POLARIS: PolarisTrackerConnection,
const.POLARISP4: PolarisP4TrackerConnection,
const.OPTITRACK: OptitrackTrackerConnection,
const.DEBUGTRACKRANDOM: DebugTrackerRandomConnection,
const.DEBUGTRACKAPPROACH: DebugTrackerApproachConnection,
}


def CreateTrackerConnection(tracker_id):
"""
Initialize spatial tracker connection for coordinate detection during navigation.

:param tracker_id: ID of tracking device.
:return spatial tracker connection instance or None if could not open device.
"""
tracker_connection_class = TRACKER_CONNECTION_CLASSES[tracker_id]

# XXX: A better solution than to pass a 'model' parameter to the constructor of tracker
# connection would be to have separate class for each model, possibly inheriting
# the same base class, e.g., in this case, PolhemusTrackerConnection base class, which
# would be inherited by FastrakTrackerConnection class, etc.
if tracker_id == const.FASTRAK:
model = 'fastrak'
elif tracker_id == const.ISOTRAKII:
model = 'isotrak'
elif tracker_id == const.PATRIOT:
model = 'patriot'
else:
model = None

tracker_connection = tracker_connection_class(
model=model
)
return tracker_connection



'''
Deprecated Code

class RobotTrackerConnection(TrackerConnection):
def __init__(self, model=None):
super().__init__(model)
Expand Down Expand Up @@ -590,81 +672,4 @@ def SetConfiguration(self, configuration):
self.configuration = configuration
return True


class DebugTrackerRandomConnection(TrackerConnection):
def __init__(self, model=None):
super().__init__(model)

def Configure(self):
return True

def Connect(self):
self.connection = True
self.lib_mode = 'debug'
print('Debug device (random) started.')

def Disconnect(self):
self.connection = False
self.lib_mode = 'debug'
print('Debug tracker (random) disconnected.')


class DebugTrackerApproachConnection(TrackerConnection):
def __init__(self, model=None):
super().__init__(model)

def Configure(self):
return True

def Connect(self):
self.connection = True
self.lib_mode = 'debug'
print('Debug device (approach) started.')

def Disconnect(self):
self.connection = False
self.lib_mode = 'debug'
print('Debug tracker (approach) disconnected.')


TRACKER_CONNECTION_CLASSES = {
const.MTC: ClaronTrackerConnection,
const.FASTRAK: PolhemusTrackerConnection,
const.ISOTRAKII: PolhemusTrackerConnection,
const.PATRIOT: PolhemusTrackerConnection,
const.CAMERA: CameraTrackerConnection,
const.POLARIS: PolarisTrackerConnection,
const.POLARISP4: PolarisP4TrackerConnection,
const.OPTITRACK: OptitrackTrackerConnection,
const.ROBOT: RobotTrackerConnection,
const.DEBUGTRACKRANDOM: DebugTrackerRandomConnection,
const.DEBUGTRACKAPPROACH: DebugTrackerApproachConnection,
}


def CreateTrackerConnection(tracker_id):
"""
Initialize spatial tracker connection for coordinate detection during navigation.

:param tracker_id: ID of tracking device.
:return spatial tracker connection instance or None if could not open device.
"""
tracker_connection_class = TRACKER_CONNECTION_CLASSES[tracker_id]

# XXX: A better solution than to pass a 'model' parameter to the constructor of tracker
# connection would be to have separate class for each model, possibly inheriting
# the same base class, e.g., in this case, PolhemusTrackerConnection base class, which
# would be inherited by FastrakTrackerConnection class, etc.
if tracker_id == const.FASTRAK:
model = 'fastrak'
elif tracker_id == const.ISOTRAKII:
model = 'isotrak'
elif tracker_id == const.PATRIOT:
model = 'patriot'
else:
model = None

tracker_connection = tracker_connection_class(
model=model
)
return tracker_connection
'''
Loading