Dear Kyle,
Okay, many thanks.
I’m getting started with the Pyhton Interactor now to get this going, but i’m having the following issue.
I was able to get several distances (ATFD_R, …) from several points (TibAntR, …) and put them into a table which can be viewed in the table module:
ATFD_R = np.linalg.norm(TibAntR - FibAntR)
PTFD_R = np.linalg.norm(TibPostR - FibPostR)
ATFD_L = np.linalg.norm(TibAntL - FibAntL)
PTFD_L = np.linalg.norm(TibPostL - FibPostL)
#Make Table
Coltitle = vtk.vtkStringArray()
Coltitle.SetName(“”)
ColRight = vtk.vtkDoubleArray()
ColRight.SetName(“Right”)
ColLeft = vtk.vtkDoubleArray()
ColLeft.SetName(“Left”)
ColDiff = vtk.vtkDoubleArray()
ColDiff.SetName(“Difference R-L”)
Coltitle.InsertNextValue(‘ATFD’)
Coltitle.InsertNextValue(‘PTFD’)
ColRight.InsertNextValue(ATFD_R)
ColRight.InsertNextValue(PTFD_R)
ColLeft.InsertNextValue(ATFD_L)
ColLeft.InsertNextValue(PTFD_L)
ColDiff.InsertNextValue(ATFD_R - ATFD_L)
ColDiff.InsertNextValue(PTFD_R - PTFD_L)
resultTableNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLTableNode”, “Syndesmotic Distances”)
resultTableNode.AddColumn(Coltitle)
resultTableNode.AddColumn(ColRight)
resultTableNode.AddColumn(ColLeft)
resultTableNode.AddColumn(ColDiff)
This gives the following table:
which is exxactly what i was looking for!
Then, I created a new point (FibAntRight, which was the same as FibAntR), from which I can get the updated position.
#Get updated position of FibAnt
def onMarkupChanged(caller,event):
markupsNode = caller
sliceView = markupsNode.GetAttribute(“Markups.MovingInSliceView”)
movingMarkupIndex = markupsNode.GetDisplayNode().GetActiveControlPoint()
if movingMarkupIndex >= 0:
pos = [0,0,0]
markupsNode.GetNthControlPointPosition(movingMarkupIndex, pos)
isPreview = markupsNode.GetNthControlPointPositionStatus(movingMarkupIndex) == slicer.vtkMRMLMarkupsNode.PositionPreview
if isPreview:
logging.info(“Point {0} is previewed at {1} in slice view {2}”.format(movingMarkupIndex, pos, sliceView))
else:
logging.info(“Point {0} was moved {1} in slice view {2}”.format(movingMarkupIndex, pos, sliceView))
else:
logging.info(“Points modified: slice view = {0}”.format(sliceView))
def onMarkupStartInteraction(caller, event):
markupsNode = caller
sliceView = markupsNode.GetAttribute(“Markups.MovingInSliceView”)
movingMarkupIndex = markupsNode.GetDisplayNode().GetActiveControlPoint()
logging.info(“Start interaction: point ID = {0}, slice view = {1}”.format(movingMarkupIndex, sliceView))
def onMarkupEndInteraction(caller, event):
markupsNode = caller
sliceView = markupsNode.GetAttribute(“Markups.MovingInSliceView”)
movingMarkupIndex = markupsNode.GetDisplayNode().GetActiveControlPoint()
logging.info(“End interaction: point ID = {0}, slice view = {1}”.format(movingMarkupIndex, sliceView))
FibAntRight = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLMarkupsFiducialNode”)
FibAntRight.AddControlPoint(FibAntR[0],FibAntR[1],FibAntR[2])
FibAntRight.AddObserver(slicer.vtkMRMLMarkupsNode.PointModifiedEvent, onMarkupChanged)
FibAntRight.AddObserver(slicer.vtkMRMLMarkupsNode.PointStartInteractionEvent, onMarkupStartInteraction)
FibAntRight.AddObserver(slicer.vtkMRMLMarkupsNode.PointEndInteractionEvent, onMarkupEndInteraction)
If I can calculate the updated distance from the new position of the point, is there a way I could automatically update this value in the table I previously created?
Thank you!
Matthias