Change size and color of markups fiducials

I’m loading a list of fiducials programmatically using:
slicer.util.loadMarkupsFiducialList(file.fcsv)

Then, I’m trying to change their color and size using the following:

defaultMarkupsFiducialDisplayNode = slicer.vtkMRMLMarkupsFiducialDisplayNode()
defaultMarkupsFiducialDisplayNode.SetColor(255,255,255) #Color of fiducials on simulation slice
defaultMarkupsFiducialDisplayNode.SetGlyphScale(1.5)
slicer.mrmlScene.AddDefaultNode(defaultMarkupsFiducialDisplayNode)

But it doesn’t work. Any ideas on why is not working?
Thanks,

JJ

AddDefaultNode changes the default for new nodes. If you want to change it for a specific node then modify the display node of that particular markups node:

markupsNode = slicer.util.loadMarkupsFiducialList('file.fcsv')
markupsNode.GetDisplayNode().SetSelectedColor(0.3, 0.6, 0.1)

Alternatively, you can save your markups in a json file (something.mrk.json) and define both point positions and display properties in this file:

{
    "@schema": "https://raw.githubusercontent.com/slicer/slicer/master/Modules/Loadable/Markups/Resources/Schema/markups-schema-v1.0.0.json#",
    "markups": [
        {
            "type": "Fiducial",
            "coordinateSystem": "LPS",
            "controlPoints": [
                { "label": "F-1", "position": [-53.388409961685827, -73.33572796934868, 0.0] },
                { "label": "F-2", "position": [49.8682950191571, -88.58955938697324, 0.0] },
                { "label": "F-3", "position": [-25.22749042145594, 59.255268199233729, 0.0] }
            ],
            "display": {
                "color": [0.4, 1.0, 1.0],
                "selectedColor": [1.0, 0.2196078431372549, 0.9215686274509803],
                "glyphType": "Sphere3D",
                "glyphScale": 16.2,
                "useGlyphScale": true
            }
        }
    ]
}
1 Like