How to get boundary coordinate of the markup plane in IJK

Hi,

I would like to know how to get coordinates for the boundaries of a markup plane in IJK.
In fiducial point case, my understanding is that we can get the following codes:
world = [0, 0, 0, 0]
fiducialNode.GetNthFiducialWorldCoordinates(index, world)
then something like this
p_Ras = [coord[0], coord[1], coord[2], 1.0]
p_Ijk = RasToIjkMatrix.MultiplyDoublePoint(p_Ras)

but I am wondering how to get the coordinates of plane nodes. I couldn’t find the function for it in the vtkMRMLMarkupsPlaneNode class.

Thank you for your help!

Markups plane coordinate system is described in the documentation: “Origin of plane at 0,0,0, XYZ axis aligned to XYZ unit vectors”. For example, homogeneous coordinate of one of the corners is [planeBounds[0], planeBounds[2], 0, 1].

Thank you so much for your comment!

I was able to get the rectangle points by the following codes.

    planeMarkup = slicer.mrmlScene.GetFirstNodeByClass("vtkMRMLMarkupsPlaneNode")
    vol=slicer.util.getNode('MR*')

    planeBounds = [0, 0, 0, 0, 0, 0]
    planeMarkup.GetPlaneBounds(planeBounds)
    planeToWorldMatrix = vtk.vtkMatrix4x4()
    planeMarkup.GetPlaneToWorldMatrix(planeToWorldMatrix)

    ras_p1 = planeToWorldMatrix.MultiplyPoint([planeBounds[0], planeBounds[2], 0, 1])
    ras_p2 = planeToWorldMatrix.MultiplyPoint([planeBounds[1], planeBounds[3], 0, 1])
    RasToIjkMatrix = vtk.vtkMatrix4x4()
    vol.GetRASToIJKMatrix(RasToIjkMatrix)

    p1 = RasToIjkMatrix.MultiplyDoublePoint(ras_p1)
    p2 = RasToIjkMatrix.MultiplyDoublePoint(ras_p2)
    print('p1:{}'.format(p1))
    print('p2:{}'.format(p2))

Thanks for your help!

1 Like