 # How to transform fiducial coordinates into image space

Thanks a lot @lassoan

One last (and kind of dumb) question : If I want to transform my fiducials points to my image space, (rather than rotating my slice view), can I do that by using this transform matrix ? I have some other models, which I don’t know how to rotate. Therefore I don’t want to rotate my image(s), but just adjust fiducial RAS’s, so that they are not cut through multiple slices. Is this doable ?

Thanks a lot.

You can find complete examples of transforming between world (RAS) and voxel (IJK) coordinates (even if the volume and fiducials are under arbitrary, even warping transforms) in the script repository:

https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_volume_voxel_coordinates_from_markup_fiducial_RAS_coordinates

If I understand correctly, I need the following step to solve my problem (the rest is for mapping from RAS to IJK). However, when I applied the following code to my fiducials, their coordinates do not change (i.e., point_VolumeRas = point_Ras) . Why would that be ? Should I change the first argument of GetTransformBetweenNodes from None to something else ?

``````# If volume node is transformed, apply that transform to get volume's RAS coordinates
transformRasToVolumeRas = vtk.vtkGeneralTransform()
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(None, volumeNode.GetParentTransformNode(), transformRasToVolumeRas)
point_VolumeRas = transformRasToVolumeRas.TransformPoint(point_Ras[0:3])
``````

If my question is not clear enough, here is what I am doing :

``````fidList = slicer.util.getNode(nodeName)
numFids = fidList.GetNumberOfFiducials()
markupsNode = getNode(nodeName)
for i in range(numFids):
ras = [0,0,0]
fidList.GetNthFiducialPosition(i,ras)
point_Ras = [ras, ras, ras, 1]
markupsIndex = i
markupsNode.GetNthFiducialWorldCoordinates(markupsIndex, point_Ras)
transformRasToVolumeRas = vtk.vtkGeneralTransform()
slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(None, volumeNode.GetParentTransformNode(), transformRasToVolumeRas)
point_VolumeRas = transformRasToVolumeRas.TransformPoint(point_Ras[0:3])
``````

But point_VolumeRas is the same as point_Ras

Thanks a lot.

`point_VolumeRas` is expected to be the same as `point_Ras`, unless the volume is transformed.

If you want to compute voxel coordinates (IJK) then use the complete example code that I linked above.