Slicer Version: 5.1.0-2022-07-17
OS: Windows 10
Hi,
I’m not sure why, but when I try accessing control points from my MarkupFiducialList, it says it doesn’t have the attribute “GetNthControlPoint”.
What I’m trying to do is loop through several sequences and add a new control point onto the list “originListNode” for each iteration. The initial values of these “origin” points are the same every time, but are transformed within the loop. So basically, I want to have one list of markups with unique positions using each sequence’s unique “platformVTK” and “trackerVTk” transform values:
originalPoints = slicer.util.getNode('trackLine')
originalArray = slicer.util.arrayFromMarkupsControlPoints(originalPoints)
originListNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsFiducialNode", "originList")
directionListNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsFiducialNode", "directionList")
print('START\n')
#wireSequenceNode.GetNumberOfDataNodes()
for count in range(3): # Loops 22 times
browserNode.SetSelectedItemNumber(count) # Moves to next sequence
# Gets the current sequence's unique 'PlatformToMarker2' transform values
currentPTMNode = slicer.util.getNode('PlatformToMarker2')
currentTrackNode = slicer.util.getNode('Marker2ToTracker')
# copyArray = slicer.util.arrayFromMarkupsControlPoints(originalPoints)
platformVTK = currentPTMNode.GetMatrixTransformFromParent().Invert()
trackerVTK = currentTrackNode.GetMatrixTransformFromParent()
# The current origin point added to the list is originally just "bigHole" from the originalPoints list
newOriginIndex = originListNode.AddControlPoint([originalArray[0][0], originalArray[0][1], originalArray[0][2]])
newOrigin = originListNode.GetNthControlPoint(newOriginIndex)
originListNode.SetNthControlPointLabel(newOriginIndex, "origin" + str(count))
# Applying the current transforms onto the origin
transformedOrigin = newOrigin.ApplyTransformMatrix(platformVTK)
transformedOrigin = transformedOrigin.ApplyTransformMatrix(trackerVTK)
print(transformedOrigin)
I am able to create the list node “originListNode” (named “originList” on Slicer) and add points using “AddControlPoint”. This is outputted successfully on Slicer. I can also access each control point’s position using originListNode.GetNthControlPointPosition(newOriginIndex). But when I try accessing these control point objects in “originList” using “GetNthControlPoint(newOriginIndex)”, it says it is not an attribute of the MarkupsFiducial node:
File "C:/d/ClariusTracker/calibrationClarius/Procrustean_PTLR/PTL_Registration/PTL_Registration.py", line 259, in setup
newOrigin = originListNode.GetNthControlPoint(newOriginIndex)
AttributeError: 'vtkSlicerMarkupsModuleMRML.vtkMRMLMarkupsFiducialN' object has no attribute 'GetNthControlPoint'
On the Slicer documentation it says this is a command that exists, but it doesn’t seem to work:
https://apidocs.slicer.org/master/classvtkMRMLMarkupsNode.html
I was going to use Fiducial functions originally, but it seems they’ve been deprecated. I might also try this on a more stable version of Slicer. Also, this might just be an issue with inheritance because I’m not too familiar with Slicer classes.