How to have the XYZ coordinates of a Markut

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to have the XYZ coordinates of a Markut

Christophe Pauly
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How to have the XYZ coordinates of a Markut

Steve Pieper-2
Hi Christophe -

What coordinate system do you want them in?  A particular image pixel coordinates?  If so you need to look at the RASToIJK transform associated with any volume node (including any parent transforms). 

https://www.slicer.org/wiki/Coordinate_systems

Let us know you use case and we can give you more specific advice.

Best,
Steve

On Fri, Jan 20, 2017 at 11:24 AM, Christophe Pauly <[hidden email]> wrote:
I am creating a module with 3D slicer in python and I would like to retrieve
the coordinates of my points.
How I can have the XYZ coordinates instead of the coordinates in mm?

Here is my code:


    fidList = slicer.util.getNode('F')
    numFids = fidList.GetNumberOfFiducials()
    res = " "
    for i in range(numFids):
      ras = [0,0,0]
      fidList.GetNthFiducialPosition(i,ras)
      # the world position is the RAS position with any transform matrices
applied
      world = [0,0,0,0]
      fidList.GetNthFiducialWorldCoordinates(i,world)
      #print i,": RAS =",ras,", world =",world
      res += str(world[0]) + " "+str(world[1])+" "+str(world[2])+" "


      # Get the volume for the first data point
      volumeID = fidList.GetNthFiducialAssociatedNodeID(0)

      # Set up coordinates
      coordsRAS = [0,0,0,0]
      coordsXYZ = [0,0,0]

      # Get RAS coordinates (saved in list coordsRAS)
      fidList.GetNthFiducialWorldCoordinates(i, coordsRAS)

      # Don't need the last data point for our purposes
      del coordsRAS[-1]

      # This bit here is taken and modified from the dataprobe.py slicer
module.
      sliceNode = slicer.mrmlScene.GetNthNodeByClass(0, 'vtkMRMLSliceNode')
      appLogic = slicer.app.applicationLogic()
      sliceLogic = appLogic.GetSliceLogic(sliceNode)
      layerLogic = sliceLogic.GetLabelLayer()

      # Get the xyz coordinates

slicer.vtkMRMLAbstractSliceViewDisplayableManager.ConvertRASToXYZ(sliceNode,coordsRAS,coordsXYZ)

      # Get the IJK coordinates
      xyToIJK = layerLogic.GetXYToIJKTransform()
      coordsIJK = xyToIJK.TransformDoublePoint(coordsXYZ)

      # Make into int
      coordsIJK = map(int, coordsIJK)

      print "coordsRAS"
      print coordsRAS
      print "coordsXYZ"
      print coordsXYZ
      print "coordsIJK"
      print coordsIJK
      print "."





--
View this message in context: http://slicer-users.65878.n3.nabble.com/How-to-have-the-XYZ-coordinates-of-a-Markut-tp4031640.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ