Input segments in new module

Hi,

I’m trying to create a new module.

I can select differents nodes like Volume and Segmentation node as input.

But how can I select my different segments in Segmentation as input before running the analyse with apply button ?

Thanks for all

1 Like

Is your module C++ or Python?

Only in Python for the moment

Thanks

We don’t have a widget for that just yet. But we have examples. Please follow this variable through this code and you can easily replicate it:

1 Like

@cpinter you’ve implemented a segment selector widget - qMRMLSegmentSelectorWidget - which includes a segmentation node selector and a segment selector combobox:

sw=slicer.qMRMLSegmentSelectorWidget()
sw.setMRMLScene(slicer.mrmlScene)
sw.setCurrentNode(getNode('Segmentation'))
sw.show()

image

For selecting multiple segments, you can use qMRMLSegmentsTableView (you need to add a segmentation node selector separately):

st=slicer.qMRMLSegmentsTableView()
st.setMRMLScene(slicer.mrmlScene)
st.setSegmentationNode(getNode('Segmentation'))
st.show()

image

4 Likes

Wow you’re right :slight_smile: Not sure why I still have the old way in those python modules. Thanks for remembering better what I did than myself :slight_smile:

Hi Andras,
How can I get the selected segment using the selectorwidgot using python script.

I get the segmentationNode but how can I get the selected segment from the qmrmlsegmentselectorwidget

regards,

Saima Safdar

Have you tried to use the selectedSegmentIDs method?

1 Like

no I cannot use it with segmentationNode.

Do you have any example where the qMRMLsegmentselectorwidget is used.

Thankyou for sharing

regards,
Saima Safdar

Hi Andras,
Thank you for the feedback. I found how to connect the widget in scripted module.

Reagrds,
Saima Safdar

If you find out anything non-obvious then please share it here so that others who run into this can find the solution (and we may also use the information to improve the documentation).

Yes I will share on github and provide link here.