Skip to content

Commit

Permalink
ENH: Extracted module VolumeClipToLabel from SliceTracker (issue Slic…
Browse files Browse the repository at this point in the history
…erProstate#115)

TODO: remove code from SliceTracker and adapt to new module
  • Loading branch information
che85 committed Oct 4, 2016
1 parent 6c10009 commit cafcef3
Show file tree
Hide file tree
Showing 3 changed files with 426 additions and 28 deletions.
7 changes: 7 additions & 0 deletions SliceTracker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,10 @@ slicerMacroBuildScriptedModule(
RESOURCES ""
WITH_GENERIC_TESTS
)

slicerMacroBuildScriptedModule(
NAME VolumeClipToLabel
SCRIPTS VolumeClipToLabel.py
RESOURCES ${MODULE_PYTHON_RESOURCES}
WITH_GENERIC_TESTS
)
31 changes: 3 additions & 28 deletions SliceTracker/SliceTracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,19 +464,6 @@ def setupSliceWidgets(self):
self.createSliceWidgetClassMembers("Green")
self.layoutManager.setLayout(self.LAYOUT_RED_SLICE_ONLY)

def createSliceWidgetClassMembers(self, name):
widget = self.layoutManager.sliceWidget(name)
setattr(self, name.lower()+"Widget", widget)
setattr(self, name.lower()+"CompositeNode", widget.mrmlSliceCompositeNode())
setattr(self, name.lower()+"SliceView", widget.sliceView())
setattr(self, name.lower()+"SliceViewInteractor", widget.sliceView().interactorStyle().GetInteractor())
logic = widget.sliceLogic()
setattr(self, name.lower()+"SliceLogic", logic)
setattr(self, name.lower()+"SliceNode", logic.GetSliceNode())
setattr(self, name.lower()+"FOV", [])
if widget not in self.sliceWidgets:
self.sliceWidgets.append(widget)

def setDefaultOrientation(self):
self.redSliceNode.SetOrientationToAxial()
self.yellowSliceNode.SetOrientationToSagittal()
Expand Down Expand Up @@ -3134,13 +3121,6 @@ def makeSeriesNumberDescription(self, dicomFile):
seriesDescription))
return "{}: {}".format(seriesNumber, seriesDescription)

def getTargetPositions(self, targets):
target_positions = []
for index in range(targets.GetNumberOfFiducials()):
target_positions.append(self.getTargetPosition(index, targets))
logging.debug('target_positions are ' + str(target_positions))
return target_positions

def run(self):
return True

Expand All @@ -3162,7 +3142,7 @@ def validPointsForQuickModeSet(self):

def getMarkupSlicePositions(self):
nOfControlPoints = self.inputMarkupNode.GetNumberOfFiducials()
return [self.getTargetPosition(index, self.inputMarkupNode)[2] for index in range(nOfControlPoints)]
return [self.getTargetPosition(self.inputMarkupNode, index)[2] for index in range(nOfControlPoints)]

def deleteClippingData(self):
slicer.mrmlScene.RemoveNode(self.clippingModelNode)
Expand Down Expand Up @@ -3472,11 +3452,6 @@ def getNeedleStartEndPointFromPathOrigins(self, index):
end = start + l * n
return start, end

def getTargetPosition(self, index, targetList):
position = [0.0, 0.0, 0.0]
targetList.GetNthFiducialPosition(index, position)
return position


class SliceTrackerTest(ScriptedLoadableModuleTest):
"""
Expand Down Expand Up @@ -3613,7 +3588,7 @@ def data(self, index, role):
return self.targetList.GetNthFiducialLabel(row)

if col == 1 and self.cursorPosition and self.computeCursorDistances and self.currentTargetIndex == row:
targetPosition = self.logic.getTargetPosition(row, self.targetList)
targetPosition = self.logic.getTargetPosition(self.targetList, row)
distance2D = self.logic.get3DDistance(targetPosition, self.cursorPosition)
distance2D = [str(round(distance2D[0]/10, 1)), str(round(distance2D[1]/10, 1)), str(round(distance2D[2]/10, 1))]
distance3D = self.logic.get3DEuclideanDistance(targetPosition, self.cursorPosition)
Expand Down Expand Up @@ -3710,7 +3685,7 @@ def getZFrameDepthInRange(self, index):
return self.computedDepth[index][0]

def calculateZFrameHoleAndDepth(self, index):
targetPosition = self.logic.getTargetPosition(index, self.targetList)
targetPosition = self.logic.getTargetPosition(self.targetList, index)
(start, end, indexX, indexY, depth, inRange) = self.logic.computeNearestPath(targetPosition)
self.needleStartEndPositions[index] = (start, end)
self.computedHoles[index] = [indexX, indexY]
Expand Down
Loading

0 comments on commit cafcef3

Please sign in to comment.