Skip to content

Commit

Permalink
MAINT #42: get tumor center coordinates using transform matrix instea…
Browse files Browse the repository at this point in the history
…d of markups node
  • Loading branch information
chriscyyeung committed Nov 24, 2022
1 parent a25612f commit 93efe50
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions LumpNav2/LumpNav2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2430,6 +2430,10 @@ def setRASMarkups(self, observer, eventid):
centerOfMassFilter.SetUseScalarsAsWeights(False)
centerOfMassFilter.Update()
center = centerOfMassFilter.GetCenter()
needleToReference = parameterNode.GetNodeReference(self.NEEDLE_TO_REFERENCE)
needleToRASMatrix = vtk.vtkMatrix4x4()
needleToReference.GetMatrixTransformToWorld(needleToRASMatrix)
centerWorld = needleToRASMatrix.MultiplyFloatPoint(np.append(center, 1))

# Calculate how far from center to put markups
bounds = [0, 0, 0, 0, 0, 0]
Expand All @@ -2440,9 +2444,6 @@ def setRASMarkups(self, observer, eventid):
# Update RAS markup points
RASMarkups = parameterNode.GetNodeReference(self.RAS_MARKUPS)
RASMarkups.RemoveAllMarkups()
RASMarkups.AddControlPoint(center, "")
centerWorld = RASMarkups.GetNthControlPointPositionWorld(0)
RASMarkups.RemoveAllMarkups()
RASMarkups.AddControlPointWorld(centerWorld[0] + distanceFromCenter, centerWorld[1], centerWorld[2], "R")
RASMarkups.AddControlPointWorld(centerWorld[0], centerWorld[1] + distanceFromCenter, centerWorld[2], "A")
RASMarkups.AddControlPointWorld(centerWorld[0], centerWorld[1], centerWorld[2] + distanceFromCenter, "S")
Expand Down

0 comments on commit 93efe50

Please sign in to comment.