# How to programmatically add control points in slicer from a numpy array

**URL:** <https://discourse.slicer.org/t/how-to-programmatically-add-control-points-in-slicer-from-a-numpy-array/28342>\
**Category:** Development\
**Tags:** python\
**Created:** [March 13, 2023, 12:55pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-control-points-in-slicer-from-a-numpy-array/28342 "2023-03-13T12:55:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mukund\_shah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mukund_shah/32/18282_2.png) [@mukund\_shah](https://discourse.slicer.org/u/mukund_shah)\
**Post date:** [March 13, 2023, 12:55pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-control-points-in-slicer-from-a-numpy-array/28342/1 "2023-03-13T12:55:23Z")

</div>

In slicer documentation following example

```auto
curveNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsCurveNode")
slicer.util.updateMarkupsControlPointsFromArray(curveNode, pointPositions)

```

where pointPositions is a numpy array but this gives a open markup curve ,what I want to do is just add markup points so I did this

```auto
markup_node = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsNode")
slicer.util.updateMarkupsControlPointsFromArray(markup_node, pointPositions)

```

But this is not adding any points as markup points

---

<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:** [March 13, 2023, 2:04pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-control-points-in-slicer-from-a-numpy-array/28342/2 "2023-03-13T14:04:33Z")

</div>

> [@mukund\_shah](#):
>
> `markup_node = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsNode")`

`vtkMRMLMarkupsNode` is an abstract base class. You cannot instantiate it, but only a concrete child class. See the list of child classes in the [inheritance diagram](https://apidocs.slicer.org/master/classvtkMRMLMarkupsNode.html).

---

<div class="post-metadata">

**Author:** ![mukund\_shah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mukund_shah/32/18282_2.png) [@mukund\_shah](https://discourse.slicer.org/u/mukund_shah)\
**Post date:** [March 13, 2023, 4:39pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-control-points-in-slicer-from-a-numpy-array/28342/3 "2023-03-13T16:39:47Z")

</div>

Thanks ,solution to this problem is to use **vtkMRMLMarkupsFiducialNode** class

---

<div class="post-metadata">

**Author:** ![mukund\_shah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mukund_shah/32/18282_2.png) [@mukund\_shah](https://discourse.slicer.org/u/mukund_shah)\
**Post date:** [March 13, 2023, 5:15pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-control-points-in-slicer-from-a-numpy-array/28342/4 "2023-03-13T17:15:57Z")

</div>

@lassoan i am now able to put markup points programmatically but since the number of points I am displaying is too large I have to rename them manually from eg **Markuppoint\_1** to 1 for better visibility,is there a way to show the points without their names?

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [March 13, 2023, 6:05pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-control-points-in-slicer-from-a-numpy-array/28342/5 "2023-03-13T18:05:57Z")

</div>

@mukund_shah I haven’t found a way to turn off the label completely with fiducials but you can set the text scale to zero with `markup_node.GetDisplayNode().SetTextScale(0)`. Example:

```py
import numpy as np
markup_node = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsFiducialNode")
slicer.util.updateMarkupsControlPointsFromArray(markup_node, np.random.rand(10,3))
markup_node.GetDisplayNode().SetTextScale(0)

```

---

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [March 13, 2023, 6:27pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-control-points-in-slicer-from-a-numpy-array/28342/6 "2023-03-13T18:27:20Z")

</div>

> [@ebrahim](#):
>
> I haven’t found a way to turn off the label completely with fiducials

This can be done using:  
`markup_node.GetDisplayNode().SetPointLabelsVisibility(False)`
