I am trying to place fiducial markers down, but not with the widget or GUI. I am wondering how I can do this in my python code. I have a text file with a list of coordinates, and I want to place the markers at those coordinates. Any help would be appreciated. Thanks.
Here’s one way to do it: Read your text file into a Nx3 numpy array (here:
arr), then create or get the desired fiducial node (here:
slicer.vtkMRMLMarkupsFiducialNode). With these two, you can use the following function to place fiducials into that node (with or without names):
def fiducialListFromArray(nfids, arr, listFidNames=None): nrfids = arr.shape if listFidNames is None: listFidNames = ['%s-%d'%(nfids.GetName(),i+1) for i in range(nrfids)] for i in range(nrfids): nfids.AddFiducial(arr[i,0], arr[i,1], arr[i,2], listFidNames[i]) return nfids
slicer.modules.markups.logic().AddFiducial(x, y, z)
I think this will work right?
@mxtt Reading the
Markups section of the “Script Repository” should help you move forward:
place fiducial markers down, but not with the widget or GUI. […] do this in my python code
More specifically, the entry Adding control points Programmatically