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
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
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:
@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()
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()
Wow you’re right Not sure why I still have the old way in those python modules. Thanks for remembering better what I did than myself
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?
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.
Hello. I’m looking for a more compact widget for selecting multiple segments and I found this post. I was wondering if there is a more recent approach for segments selection that can easily be integrated in other modules. Thanks.
If you need to select multiple segments then I would recommend the qMRMLSegmentsTableView. This widget has filter&search capabilities that are essential if you need to work with a segmentation that contains many segments (common with automatic segmentation tools).
Alternatively, you can use the qMRMLSegmentSelectorWidget to select a segment and an “add” button to add it to a list, and “remove” button for each added segment to remove them. This may take up a bit less space, but it is more work to implement.
You can also do without any segment selection and say that you work with all visible segments; or all flagged segments (you can set status of a segment in the segment list by right-clicking and choosing “Show filter bar”).