Programmatically setting a TransformProcessorNode

I’m currently writing a module that handles two tracked markers (one attached to a phantom and one attached to a pointer i.e. a stylus).
In a effort to obtain the pointer coordinates in the referential of the phantom, I would like to use a TransformProcessorNode (which I successfully used in the GUI).
Here is what I wrote:

transfoProcNode = slicer.vtkMRMLTransformProcessorNode()
phtToPtrTransfoNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLinearTransformNode', 'PointerToPhantom')

But, looking at the resulting transform ‘PointerToPhantom’ in the Transforms module, it appears as the identity and does not change.
Thank you for any input

Normally you would just write into the Plus configuration file to send “PointerToPhantom”. Plus toolkit can automatically compute transforms between any coordinate systems, by parsing the name and concatenating and inverting transforms as needed.

1 Like

Despite the proposed solution (deferring the transforms multiplication to Plus) being satisfactory at first, I now also need to have access to both transforms separately for other purposes.
What would be better in terms of performance:

  • keep the actual PointerToPhantom channel from Plus and add two other channels for Pointer and Phantom (which would be kind of redundant)
  • do what I tried to do in my original post: set a TransformProcessorNode
    Thank you for your feedback

Both solutions are fine.

Probably the transform in your script does not update because you did not add the transform processor node to the scene. You can fix it by changing the first line to transfoProcNode = slicer.mrmlScene. AddNewNodeByClass('vtkMRMLTransformProcessorNode').

1 Like