Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDepthPerception.py
More file actions
Latest commit
51 lines (37 loc) · 1.47 KB
/
Copy pathDepthPerception.py
File metadata and controls
51 lines (37 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
importmath
importvtk
fromPythonMetricsCalculatorimportPerkEvaluatorMetric
classDepthPerception( PerkEvaluatorMetric ):
# Static methods
@staticmethod
defGetMetricName():
return"Depth Perception"
@staticmethod
defGetMetricUnit():
return"mm"
@staticmethod
defGetTransformRoles():
return [ "Needle" ]
# Instance methods
def__init__( self ):
PerkEvaluatorMetric.__init__( self )
self.depthPerception=0
self.pointPrev=None
defAddTimestamp( self, time, matrix, point, role ):
if ( self.pointPrev==None ):
self.pointPrev=point[:]
# Find the prev to current vector
prevToCurrentVector= [ 0, 0, 0 ]
vtk.vtkMath().Subtract( point[0:3], self.pointPrev[0:3], prevToCurrentVector )
prevToCurrentVector= [ prevToCurrentVector[ 0 ], prevToCurrentVector[ 1 ], prevToCurrentVector[ 2 ] ]
# Compute the direction vector of the needle in RAS, using the needle orientation protocol
needleOrientation=self.NeedleOrientation[:]
needleOrientation.append( 0 )
needleVector_RAS= [ 0, 0, 0, 0 ]
matrix.MultiplyPoint( needleOrientation, needleVector_RAS )
# Find the movement in the needle direction
needleAxisMovement=vtk.vtkMath().Dot( prevToCurrentVector, needleVector_RAS[ 0:3 ] )
self.depthPerception+=math.fabs( needleAxisMovement )
self.pointPrev=point[:]
defGetMetric( self ):
returnself.depthPerception