# Select contour from the mrml scene

**URL:** <https://discourse.slicer.org/t/select-contour-from-the-mrml-scene/14222>\
**Category:** Support\
**Created:** [October 24, 2020, 1:25pm UTC](https://discourse.slicer.org/t/select-contour-from-the-mrml-scene/14222 "2020-10-24T13:25:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)\
**Post date:** [October 24, 2020, 1:25pm UTC](https://discourse.slicer.org/t/select-contour-from-the-mrml-scene/14222/1 "2020-10-24T13:25:13Z")

</div>

Hello everyone,

I’m using the 3D slicer version 4.10.0 and I want to select a specific contour in my module:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/a/5ab305ab9126da17318c83da0ed9d5346dc5e2ca.png)

However, in the mrml scene I can’t get any ID for the contours:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/e/dedcd9224cf55817567fbfacfdca430e4ec8e630.png)

So, the following code doesn’t work:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/4/b4aca1082c0294e28970ee92ca8f5b1b1028fb64.png)

Any idea how to fix this?

Thank you in advance.

---

<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:** [October 24, 2020, 2:23pm UTC](https://discourse.slicer.org/t/select-contour-from-the-mrml-scene/14222/2 "2020-10-24T14:23:00Z")

</div>

There is a specific widget for segment selection: [qMRMLSegmentSelectorWidget](https://apidocs.slicer.org/master/classqMRMLSegmentSelectorWidget.html).

---

<div class="post-metadata">

**Author:** ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)\
**Post date:** [October 25, 2020, 2:23pm UTC](https://discourse.slicer.org/t/select-contour-from-the-mrml-scene/14222/3 "2020-10-25T14:23:11Z")

</div>

Thanks a lot!

I used the connection: self.inputSegmentationSelector.connect(“currentSegmentChanged(QString)”, self.onContourChange)

And now I want to calculate the center of mass of the selected contour. So I used the following code:

modelNode = slicer.mrmlScene.GetNodesByName((str(targetContour)))  
pointCoordinates = slicer.util.arrayFromModelPoints(modelNode) # point coordinates of targetContour

but I’m having the error:

File “C:\Program Files\Slicer 4.10.0\bin\Python\slicer\util.py”, line 795, in arrayFromModelPoints  
pointData = modelNode.GetPolyData().GetPoints().GetData()  
AttributeError: ‘vtkCommonCorePython.vtkCollection’ object has no attribute ‘GetPolyData’

---

<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:** [October 25, 2020, 2:48pm UTC](https://discourse.slicer.org/t/select-contour-from-the-mrml-scene/14222/4 "2020-10-25T14:48:17Z")

</div>

You get the error because you pass a segmentation node to a function that requires a model node.

What you are tryibg to achieve? Jumping to selected fiducial feature is already implemented. See for example in segment list widget ([https://github.com/Slicer/Slicer/blob/a4017472d6220903f7f85c5e49b547f1f6830f39/Modules/Loadable/Segmentations/Widgets/qMRMLSegmentsTableView.h#L65](https://github.com/Slicer/Slicer/blob/a4017472d6220903f7f85c5e49b547f1f6830f39/Modules/Loadable/Segmentations/Widgets/qMRMLSegmentsTableView.h#L65)).

---

<div class="post-metadata">

**Author:** ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)\
**Post date:** [October 25, 2020, 3:45pm UTC](https://discourse.slicer.org/t/select-contour-from-the-mrml-scene/14222/5 "2020-10-25T15:45:38Z")

</div>

I would like to select a specific segment in 3D slicer like this:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/1/71217c00fcdf3fe312373989e0c76696eb9b9983.png)

And then I want to calculate the center of mass of the CTV1. So in order to use the function: getCenterOfMass(contour)

what I need to do?
