Retrieving Transform Matrix From Transforms Module

Hi,

I have 3D images that I need to rotate and to do this I am using the transforms module. I want to do the rotation in the gui with sliders and retrieve the transform matrix via python code to apply the transform with ITK later. However, in transform node I couldn’t find any function that returns this information. Is there any way to get the transform matrix?
Here is the code I use to create transform node and visualize the transform

        slicer.util.mainWindow().moduleSelector().selectModule('Transforms')
        transformNode = slicer.vtkMRMLTransformNode()
        slicer.mrmlScene.AddNode(transformNode)
        
        volumeNode = slicer.util.loadVolume(filePath)
        volRenLogic = slicer.modules.volumerendering.logic()
        
        #Display the volume
        displayNode = volRenLogic.CreateDefaultVolumeRenderingNodes(volumeNode)
        displayNode.SetVisibility(True)
        
        #Center 3d Volume
        layoutManager = slicer.app.layoutManager()
        threeDWidget = layoutManager.threeDWidget(0)
        threeDView = threeDWidget.threeDView()
        threeDView.resetFocalPoint()
        
        volumeNode.SetAndObserveTransformNodeID(transformNode.GetID())

Transform’s module developer documentation should answer all the above questions: https://www.slicer.org/wiki/Documentation/Nightly/Modules/Transforms#Information_for_Developers

Let us know if you have any remaining questions.

1 Like