# How to create a fiducial though the pixel not the mouse event

**URL:** <https://discourse.slicer.org/t/how-to-create-a-fiducial-though-the-pixel-not-the-mouse-event/11410>\
**Category:** Development\
**Created:** [May 5, 2020, 1:23am UTC](https://discourse.slicer.org/t/how-to-create-a-fiducial-though-the-pixel-not-the-mouse-event/11410 "2020-05-05T01:23:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [May 5, 2020, 1:23am UTC](https://discourse.slicer.org/t/how-to-create-a-fiducial-though-the-pixel-not-the-mouse-event/11410/1 "2020-05-05T01:23:22Z")

</div>

I went creat fiducial in the 3d view just give the x,y coordinate, and I found some information maybe help for me. But I don’t know how to use it.

```auto
virtual int vtkSlicerMarkupsWidget::AddNodeOnWidget ( const int *displayPos* [2] ) virtual

```

Given a specific X, Y pixel location, add a new node on the widget at this location.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 5, 2020, 3:59am UTC](https://discourse.slicer.org/t/how-to-create-a-fiducial-though-the-pixel-not-the-mouse-event/11410/2 "2020-05-05T03:59:19Z")

</div>

This operation is called point picking. Model displayable manager has a point picker that you can use:

```python
displayPosition = [100,120]

# Get model displayable manager
modelDisplayableManager = None
threeDViewWidget = slicer.app.layoutManager().threeDWidget(0)
managers = vtk.vtkCollection()
threeDViewWidget.getDisplayableManagers(managers)
for i in range(managers.GetNumberOfItems()):
  obj = managers.GetItemAsObject(i)
  if obj.IsA('vtkMRMLModelDisplayableManager'):
    modelDisplayableManager = obj
    break

# Use model displayable manager's point picker
pickedPosition = []
if modelDisplayableManager.Pick(displayPosition[0], displayPosition[1]):
    rasPositionArray = vtk.vtkDoubleArray()
    rasPositionArray.SetVoidArray(modelDisplayableManager.GetPickedRAS(),3,1)
    rasPosition = [rasPositionArray.GetValue(i) for i in range(3)]

print(rasPosition)

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 16, 2023, 7:14pm UTC](https://discourse.slicer.org/t/how-to-create-a-fiducial-though-the-pixel-not-the-mouse-event/11410/3 "2023-06-16T19:14:15Z")

</div>

In current Slicer version, the code snippet is much simpler - [see in the script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-3d-coordinates-from-2d-display-coordinates).
