# How to get the IJK coordinate of a fiducial node in 3d slicer development

**URL:** https://discourse.slicer.org/t/how-to-get-the-ijk-coordinate-of-a-fiducial-node-in-3d-slicer-development/45362
**Category:** Development
**Created:** [December 4, 2025, 2:38am UTC](https://discourse.slicer.org/t/how-to-get-the-ijk-coordinate-of-a-fiducial-node-in-3d-slicer-development/45362 "2025-12-04T02:38:25Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![zhutouzjq](https://avatars.discourse-cdn.com/v4/letter/z/8797f3/32.png) [@zhutouzjq](https://discourse.slicer.org/u/zhutouzjq)
#### Post date: [December 4, 2025, 3:13am UTC](https://discourse.slicer.org/t/how-to-get-the-ijk-coordinate-of-a-fiducial-node-in-3d-slicer-development/45362/3 "2025-12-04T03:13:46Z")

</div>

thank the discussion in “[RAS to IJK conversion issues](https://discourse.slicer.org/t/ras-to-ijk-conversion-issues/41863)“. the reply by muratmaga help me a lot.

in the script repository of 3D slicer, they suggest use the follow code to transform the ras to ijk:

```auto
# Inputs
volumeNode = getNode("MRHead")
pointListNode = getNode("F")
markupsIndex = 0

# Get point coordinate in RAS
point_Ras = [0, 0, 0]
pointListNode.GetNthControlPointPositionWorld(markupsIndex, point_Ras)

# 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)

# Get voxel coordinates from physical coordinates
volumeRasToIjk = vtk.vtkMatrix4x4()
volumeNode.GetRASToIJKMatrix(volumeRasToIjk)
point_Ijk = [0, 0, 0, 1]
volumeRasToIjk.MultiplyPoint(np.append(point_VolumeRas,1.0), point_Ijk)
point_Ijk = [int(round(c)) for c in point_Ijk[0:3] ]

# Print output
print(point_Ijk)

```

but what i didn’t know is that in my code, the second line “volumeNode = getNode(“MRHead”)” should be change into “volumeNode = slicer.util.getNode(“5: CTA 0.5 CE”)“.

“MRHead“ or “5: CTA 0.5 CE“ is the name of volume which could be found here.

 ![无标题](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/5/757124617e2ec162960d71567ac1c32d398beb95.png)

and use the python code like this in Logic class, i can print the IJK coordinate in console now.

```
def process(self,

            inputVolume: vtkMRMLScalarVolumeNode,

            imageThreshold: float,

            inputlowerpoint,

            inputupperpoint,

            showResult: bool = True) -> None:

    """

    Run the processing algorithm.

    Can be used without GUI widget.

    :param inputVolume: volume to be thresholded

    :param outputVolume: thresholding result

    :param imageThreshold: values above/below this threshold will be set to 0

    :param invert: if True then values above the threshold will be set to 0, otherwise values below are set to 0

    :param showResult: show output volume in slice viewers

    """

    if not inputVolume:

        raise ValueError("Input volume is invalid")

    import time

    startTime = time.time()

    logging.info("Processing started")

    volumeNode = slicer.util.getNode("5: CTA 0.5 CE")

    markupsIndex = 0

    point_Ras = \[0, 0, 0\]

    inputlowerpoint.GetNthControlPointPositionWorld(markupsIndex, point_Ras)

    

    transformRasToVolumeRas = vtk.vtkGeneralTransform()

    slicer.vtkMRMLTransformNode.GetTransformBetweenNodes(None, volumeNode.GetParentTransformNode(), transformRasToVolumeRas)

    point_VolumeRas = transformRasToVolumeRas.TransformPoint(point_Ras)

    \# Get voxel coordinates from physical coordinates

    volumeRasToIjk = vtk.vtkMatrix4x4()

    volumeNode.GetRASToIJKMatrix(volumeRasToIjk)

    point_Ijk = \[0, 0, 0, 1\]

    volumeRasToIjk.MultiplyPoint(np.append(point_VolumeRas,1.0), point_Ijk)

    point_Ijk = \[int(round(c)) for c in point_Ijk\[0:3\] \]

    print('lowerpoint : RAS =',point_Ras)

    print('lowerpoint : IJK =',point_Ijk)

    stopTime = time.time()

    logging.info(f"Processing completed in {stopTime-startTime:.2f} seconds")

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/f/6fd4f99f5d519128e5ecd605e4d8ee52379097ef.png)

---

_[View the full topic](https://discourse.slicer.org/t/how-to-get-the-ijk-coordinate-of-a-fiducial-node-in-3d-slicer-development/45362)._
