# Using qMRMLNodeAttributeTableWidget with qMRMLSegmentEditorWidget

**URL:** <https://discourse.slicer.org/t/using-qmrmlnodeattributetablewidget-with-qmrmlsegmenteditorwidget/31904>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [September 26, 2023, 4:18am UTC](https://discourse.slicer.org/t/using-qmrmlnodeattributetablewidget-with-qmrmlsegmenteditorwidget/31904 "2023-09-26T04:18:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NguyenVuHoaBinh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nguyenvuhoabinh/32/67523_2.png) [@NguyenVuHoaBinh](https://discourse.slicer.org/u/NguyenVuHoaBinh)\
**Post date:** [September 26, 2023, 4:18am UTC](https://discourse.slicer.org/t/using-qmrmlnodeattributetablewidget-with-qmrmlsegmenteditorwidget/31904/1 "2023-09-26T04:18:46Z")

</div>

Hello everyone! I am new to 3D Slicer.  
I am currently creating a sample extension that allow user add additional information about the segmentation when using segment editor, but i got stuck. I dont know how to mapping the qMRMLNodeAttributeTableWidget with qMRMLSegmentEditorWidget. I will really appreaciate any help.

Sorry if my bad English make you confuse to understand. Have a nice day!

 ![Screenshot 2023-09-26 111053](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/f/9f90f9b84d461de05357ace6fa388fd00b511578.png)

Operating system: Window 11  
Slicer version: 5.2.2  
Expected behavior: Can perform add/remove attribute name and value for the selected segmentation node from segment editor widget  
Actual behavior: Failed to instantiate module

---

<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:** [September 26, 2023, 11:24am UTC](https://discourse.slicer.org/t/using-qmrmlnodeattributetablewidget-with-qmrmlsegmenteditorwidget/31904/2 "2023-09-26T11:24:47Z")

</div>

What you describe that you want to do seems quite unusual. To my understanding you want to change node attributes visually for the segment editor node. However, that’s kind of halfway between UI and programming, and would be very error-prone and would require continual lookup of attributes in the source code etc.

Can you please describe what you actually want to achieve from the user’s perspective?

---

<div class="post-metadata">

**Author:** ![NguyenVuHoaBinh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nguyenvuhoabinh/32/67523_2.png) [@NguyenVuHoaBinh](https://discourse.slicer.org/u/NguyenVuHoaBinh)\
**Post date:** [September 26, 2023, 1:04pm UTC](https://discourse.slicer.org/t/using-qmrmlnodeattributetablewidget-with-qmrmlsegmenteditorwidget/31904/3 "2023-09-26T13:04:55Z")

</div>

Thank you for your support. I will provide detail what i want to achieve.  
Assume that i am a radiologist using 3D slicer to annotate multiple segmentations like this.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/8/8830133e9f058a434445cea6e95ea9d36f4fecbb.png)

However, i want to make more comment for each segmentation label i made by using the [qMRMLNodeAttributeTableWidget], giving some fixed attribute and add the value for them so whenever i re-open the file, i can review it or modify the attribute value i created before. Here is the [qMRMLNodeAttributeTableWidget]

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/9/c961546dceba03a9df37f59aed05ec17dffd02f4.png)

My desired output is like this

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/0/20d2dc0a8892cc9aa0751c001f9dfcfa7d5656a5.png)

Hope you will understand what i am trying to achieve.  
Thank you.

---

<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:** [September 26, 2023, 1:56pm UTC](https://discourse.slicer.org/t/using-qmrmlnodeattributetablewidget-with-qmrmlsegmenteditorwidget/31904/4 "2023-09-26T13:56:44Z")

</div>

Segments are not nodes, so this idea won’t work for individual segments. See this part of the documentation:  
[https://slicer.readthedocs.io/en/latest/user\_guide/image\_segmentation.html](https://slicer.readthedocs.io/en/latest/user_guide/image_segmentation.html)

The segments do not have attributes, but they have “tags” that can be used for this purpose, see

> <https://github.com/Slicer/Slicer/blob/d9485819db2e8e71a4cf0e4d914946f704bbcb39/Libs/vtkSegmentationCore/vtkSegment.h#L94-L110>

But there is no table for the tags. Maybe you can look at this class as inspiration:

> <https://github.com/Slicer/Slicer/blob/main/Modules/Loadable/Segmentations/Widgets/qMRMLSegmentationConversionParametersWidget.h>

---

<div class="post-metadata">

**Author:** ![NguyenVuHoaBinh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nguyenvuhoabinh/32/67523_2.png) [@NguyenVuHoaBinh](https://discourse.slicer.org/u/NguyenVuHoaBinh)\
**Post date:** [September 26, 2023, 3:08pm UTC](https://discourse.slicer.org/t/using-qmrmlnodeattributetablewidget-with-qmrmlsegmenteditorwidget/31904/5 "2023-09-26T15:08:43Z")

</div>

Wonderful! I will check that out. By the way, is it possible to create separate tables like that for each segmentation label map like the sample image below?  
P/s: The image is a sample and does not contain any confidential information.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/9/a9a64158b4bcf5b32e676b245a355c2656d1a0bd.jpeg)

---

<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:** [September 26, 2023, 8:27pm UTC](https://discourse.slicer.org/t/using-qmrmlnodeattributetablewidget-with-qmrmlsegmenteditorwidget/31904/6 "2023-09-26T20:27:15Z")

</div>

I think you should use split islands and separate these into a segment each. In the default terminology you can specify the same type with left/right modifiers, so you can uniquely identify the structures.
