# Extract RAS coordinates by clicking

**URL:** <https://discourse.slicer.org/t/extract-ras-coordinates-by-clicking/33531>\
**Category:** Support\
**Tags:** markups-fiducials\
**Created:** [December 27, 2023, 11:42am UTC](https://discourse.slicer.org/t/extract-ras-coordinates-by-clicking/33531 "2023-12-27T11:42:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SANTIAGO\_PENDON\_MING](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/santiago_pendon_ming/32/66060_2.png) [@SANTIAGO\_PENDON\_MING](https://discourse.slicer.org/u/SANTIAGO_PENDON_MING)\
**Post date:** [December 27, 2023, 11:42am UTC](https://discourse.slicer.org/t/extract-ras-coordinates-by-clicking/33531/1 "2023-12-27T11:42:44Z")

</div>

Hi to everyone 🙂  
Today I want to extract RAS coordinates to 3d markups/curves to click.

My goal is interact with 3d view (if is not possible, interact with 2d views would great too). Processing the click I would like to know the ID of the selected point and RAS coordinates.

 ![Captura de pantalla 2023-12-27 123747](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/f/ff66f340893da98cc156652262a75b2643a6c67b.jpeg)  
Is there a way to do it by python code → Run some lines which allows the user to select one point and then he can retrieve the coordinates?

I’m interested in obtain info from centerlines created by extractCenterlines module

---

<div class="post-metadata">

**Author:** ![bserrano](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bserrano/32/17034_2.png) [@bserrano](https://discourse.slicer.org/u/bserrano)\
**Post date:** [February 5, 2024, 3:46pm UTC](https://discourse.slicer.org/t/extract-ras-coordinates-by-clicking/33531/2 "2024-02-05T15:46:59Z")

</div>

Also interested in having a callback function when clicking on a markups. Any solution for this?

Thanks

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [February 7, 2024, 11:53am UTC](https://discourse.slicer.org/t/extract-ras-coordinates-by-clicking/33531/3 "2024-02-07T11:53:26Z")

</div>

This worked for me for adding new points:

```auto
@vtk.calldata_type(vtk.VTK_INT)
def onPointDefined(caller, eventid, callData):
    fiducialNode = caller
    fiducialIndex = callData
    print(f'Defined: {fiducialNode.GetName()}, Fiducial index: {fiducialIndex}')

fiducialsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointPositionDefinedEvent, onPointDefined)

```

For clicking this could be the solution:

```auto
@vtk.calldata_type(vtk.VTK_OBJECT)
def onPointClicked(caller, eventid):
    fiducialNode = caller
    fiducialIndex = int(fiducialNode.GetAttribute('Markups.MovingMarkupIndex'))
    print(f'Moved: {fiducialNode.GetName()}, Fiducial index: {fiducialIndex}')

fiducialsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointStartInteractionEvent, onPointClicked)

```
