Is there a way to add a vector for the fiducials?

Hi,
Is there a way to add a vector for the fiducial.

Regards,
Saima Safdar

Each fiducial point has a position and orientation. If the vector defines an orientation then that would be a convenient place to store it. If the vector stores an RGB value or any other signal or other property then you can add store it in the markups fiducials as a static measurement. This is used for example for storing curvatures in curves.

Example for storing a 4-component vector for each control point:

pointListNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLMarkupsFiducialNode')

myVector = vtk.vtkDoubleArray()
myVector.SetName('SomeVector')
myVector.SetNumberOfComponents(4)

pointListNode.AddControlPointWorld(vtk.vtkVector3d(40, 50, -10.2))
myVector.InsertNextTuple4(1,1,4,2)

pointListNode.AddControlPointWorld(vtk.vtkVector3d(-20, -20, -10.2))
myVector.InsertNextTuple4(1,2,4,5)

pointListNode.AddControlPointWorld(vtk.vtkVector3d(-50, -60, -10.2))
myVector.InsertNextTuple4(3,3,4,1)

pointListNode.AddControlPointWorld(vtk.vtkVector3d(90, 40, -10.2))
myVector.InsertNextTuple4(4,4,4,7)

pointListNode.AddControlPointWorld(vtk.vtkVector3d(140, 70, -10.2))
myVector.InsertNextTuple4(5,5,4,3)

someMeasurement = slicer.vtkMRMLStaticMeasurement()
someMeasurement.SetName('SomeMeasurement')
someMeasurement.SetUnits('mm')
someMeasurement.SetPrintFormat('')  # Prevent from showing up in SH Description
someMeasurement.SetControlPointValues(myVector)
pointListNode.AddMeasurement(someMeasurement)

The points can be accessed using VTK array interface as shown above but can also be accessed (read and written) as a numpy array:

print(slicer.util.arrayFromMarkupsControlPointData(pointListNode, 'SomeVector'))

The data is stored in the .mrk.json file:

{
...
    "markups": [
        {
            "type": "Fiducial",
...
            "controlPoints": [
                {
                    "id": "1",
                    "label": "MarkupsFiducial-1",
                    "position": [-40.0, -50.0, -10.2],
                    "orientation": [-1.0, -0.0, 0.0, -0.0, -1.0, 0.0, -0.0, -0.0, 1.0],
...
                },
                {
                    "id": "2",
                    "label": "MarkupsFiducial-2",
                    "description": "",
                    "position": [20.0, 20.0, -10.2],
                    "orientation": [-1.0, -0.0, 0.0, -0.0, -1.0, 0.0, -0.0, -0.0, 1.0],
...
                },
...
            ],
            "measurements": [
                {
                    "name": "SomeMeasurement",
                    "enabled": true,
                    "units": "mm",
                    "controlPointValues": [[1.0, 1.0, 4.0, 2.0], [1.0, 2.0, 4.0, 5.0], [3.0, 3.0, 4.0, 1.0], [4.0, 4.0, 4.0, 7.0], [5.0, 5.0, 4.0, 3.0]
                    ]
                }
            ],
   ...
     }
    ]
}

Hi Andras,
image

is there a way to change the orientation using user interaction with the fiducial instead of adding the values to the orientation array.

does the pointing of arrow fiducial changes with the change in the orientation matrix?

Thank you

Regards,
Saima Safdar

In the future we’ll probably have an option to orient the markups control point glyphs using the point’s orientation, but there are no concrete plans. There are many alternative options, though.

Option A: You can get the point positions and orientations from the markups node and use those as inputs for a vtkgGlyph3D filter to generate a model of oriented glyphs.

Option B: Use transform visualization features (oriented glyphs in 2D and 3D, contours, deformed grids, etc.). You can choose to display the vector field at fiducial positions only. If the vectors are already defined with a dense displacement field (bspline or grid) then those can be loaded directly as a transform. If you have the vectors computed for each fiducial only, then you can generate the displacement field using Fiducial registration wizard module (in SlicerIGT extension).

There are many other options, but to be able to give an informed advice, we would need to know what your end goal is. What would you like to visualize for what purpose?