Commit 5e6e840fdf20ce64c41a5fc2493724e7d0ee6abd

Authored by Renan
Committed by Thiago Franco de Moraes
1 parent 8a54181b
Exists in master

Fix dynamic ref (#112)

* Fix dynamic Ref for polhemus and claron

* fix unicode

* Fix dynamic Ref for usb polhemus connection
invesalius/data/coordinates.py
@@ -60,16 +60,17 @@ def ClaronCoord(trck_init, trck_id, ref_mode): @@ -60,16 +60,17 @@ def ClaronCoord(trck_init, trck_id, ref_mode):
60 while k < 20: 60 while k < 20:
61 try: 61 try:
62 trck.Run() 62 trck.Run()
63 - probe = np.array([trck.PositionTooltipX1 * scale[0], trck.PositionTooltipY1 * scale[1],  
64 - trck.PositionTooltipZ1 * scale[2], trck.AngleX1, trck.AngleY1, trck.AngleZ1])  
65 - reference = np.array([trck.PositionTooltipX2 * scale[0], trck.PositionTooltipY2 * scale[1],  
66 - trck.PositionTooltipZ2 * scale[2], trck.AngleX2, trck.AngleY2, trck.AngleZ2]) 63 + probe = np.array([trck.PositionTooltipX1, trck.PositionTooltipY1,
  64 + trck.PositionTooltipZ1, trck.AngleX1, trck.AngleY1, trck.AngleZ1])
  65 + reference = np.array([trck.PositionTooltipX2, trck.PositionTooltipY2,
  66 + trck.PositionTooltipZ2, trck.AngleZ2, trck.AngleY2, trck.AngleX2])
67 k = 30 67 k = 30
68 except AttributeError: 68 except AttributeError:
69 k += 1 69 k += 1
70 print "wait, collecting coordinates ..." 70 print "wait, collecting coordinates ..."
71 if k == 30: 71 if k == 30:
72 coord = dynamic_reference(probe, reference) 72 coord = dynamic_reference(probe, reference)
  73 + coord = (coord[0] * scale[0], coord[1] * scale[1], coord[2] * scale[2], coord[3], coord[4], coord[5])
73 else: 74 else:
74 while k < 20: 75 while k < 20:
75 try: 76 try:
@@ -108,15 +109,16 @@ def PolhemusWrapperCoord(trck, trck_id, ref_mode): @@ -108,15 +109,16 @@ def PolhemusWrapperCoord(trck, trck_id, ref_mode):
108 109
109 if ref_mode: 110 if ref_mode:
110 trck.Run() 111 trck.Run()
111 - probe = np.array([float(trck.PositionTooltipX1) * scale[0], float(trck.PositionTooltipY1) * scale[1],  
112 - float(trck.PositionTooltipZ1) * scale[2], float(trck.AngleX1), float(trck.AngleY1), 112 + probe = np.array([float(trck.PositionTooltipX1), float(trck.PositionTooltipY1),
  113 + float(trck.PositionTooltipZ1), float(trck.AngleX1), float(trck.AngleY1),
113 float(trck.AngleZ1)]) 114 float(trck.AngleZ1)])
114 - reference = np.array([float(trck.PositionTooltipX2) * scale[0], float(trck.PositionTooltipY2) * scale[1],  
115 - float(trck.PositionTooltipZ2) * scale[2], float(trck.AngleX2), float(trck.AngleY2), 115 + reference = np.array([float(trck.PositionTooltipX2), float(trck.PositionTooltipY2),
  116 + float(trck.PositionTooltipZ2), float(trck.AngleX2), float(trck.AngleY2),
116 float(trck.AngleZ2)]) 117 float(trck.AngleZ2)])
117 118
118 if probe.all() and reference.all(): 119 if probe.all() and reference.all():
119 coord = dynamic_reference(probe, reference) 120 coord = dynamic_reference(probe, reference)
  121 + coord = (coord[0] * scale[0], coord[1] * scale[1], coord[2] * scale[2], coord[3], coord[4], coord[5])
120 122
121 else: 123 else:
122 trck.Run() 124 trck.Run()
@@ -148,13 +150,12 @@ def PolhemusUSBCoord(trck, trck_id, ref_mode): @@ -148,13 +150,12 @@ def PolhemusUSBCoord(trck, trck_id, ref_mode):
148 150
149 # six coordinates of first and second sensor: x, y, z and alfa, beta and gama 151 # six coordinates of first and second sensor: x, y, z and alfa, beta and gama
150 # jump one element for reference to avoid the sensor ID returned by Polhemus 152 # jump one element for reference to avoid the sensor ID returned by Polhemus
151 - probe = data[0] * scale[0], data[1] * scale[1], data[2] * scale[2], \  
152 - data[3], data[4], data[5], data[6]  
153 - reference = data[7] * scale[0], data[8] * scale[1], data[9] * scale[2], data[10], \  
154 - data[11], data[12], data[13] 153 + probe = data[0], data[1], data[2], data[3], data[4], data[5], data[6]
  154 + reference = data[7], data[8], data[9], data[10], data[11], data[12], data[13]
155 155
156 if probe.all() and reference.all(): 156 if probe.all() and reference.all():
157 coord = dynamic_reference(probe, reference) 157 coord = dynamic_reference(probe, reference)
  158 + coord = (coord[0] * scale[0], coord[1] * scale[1], coord[2] * scale[2], coord[3], coord[4], coord[5])
158 159
159 return coord 160 return coord
160 161
invesalius/data/trackers.py
@@ -67,8 +67,8 @@ def ClaronTracker(tracker_id): @@ -67,8 +67,8 @@ def ClaronTracker(tracker_id):
67 67
68 lib_mode = 'wrapper' 68 lib_mode = 'wrapper'
69 trck_init = pyclaron.pyclaron() 69 trck_init = pyclaron.pyclaron()
70 - trck_init.CalibrationDir = const.CAL_DIR  
71 - trck_init.MarkerDir = const.MAR_DIR 70 + trck_init.CalibrationDir = const.CAL_DIR.encode(const.FS_ENCODE)
  71 + trck_init.MarkerDir = const.MAR_DIR.encode(const.FS_ENCODE)
72 trck_init.NumberFramesProcessed = 10 72 trck_init.NumberFramesProcessed = 10
73 trck_init.FramesExtrapolated = 0 73 trck_init.FramesExtrapolated = 0
74 trck_init.PROBE_NAME = "1Probe" 74 trck_init.PROBE_NAME = "1Probe"