Hi there,
I’m new to 3D Slicer and now I’m developing a Python scripting module.
Currently, I want to implement a procedure in python code of my module for calculating the volume value of the overlapping/Intersection part of two segments.
As shown in the figure below, at the beginning I have two segmentation nodes, I set their color to red and green respectively:
Go to the ‘Segmentation’ module and use ‘Export/Import Models and Labelmaps’ to export the two segments to the ‘Models’ module to create two corresponding models:
Go to the ‘segmentation’ module and create a new segmentation node, I named it ‘NEW Segmentation’, and import both of models get from the previous step into this new segmentation node using the ‘Export/Import Models and Labelmaps’:
Go to the ‘Segmentation Editor’ module, switch the Segmentation node to ‘NEW Segmentation’, and now I notice that all effects are greyed out:
According to the example given by @mikebind in this post: How to programmatically use logical operator add function, I found that in order to use the logical operator effect, which in my case is the ‘INTERSECT’ opreation, a master volume must be selected first, although I know I can create this Master Volume by clicking on the small “Specify geometry button” and selecting the ‘NEW Segmentation’ in the drop down box(the lowest option), but how to create the Master Volume for the ‘NEW Segmentation’ programmatically using python?
I’ve tried the code you provided. However, If I’m correct, this is actually the same as clicking the ‘Create new segmentation’ in the ‘Segmentations’ module, and this is how the ‘NEW segmentation’ I mentioned above with two segments was created:
Go to the ‘segmentations’ module and create a new segmentation node, I named it ‘ NEW Segmentation ’, and import both of models get from the previous step into this new segmentation node using the ‘Export/Import Models and Labelmaps’
So, how to create the Master Volume for the ‘NEW Segmentation’ programmatically using python? Because after I create this Master Volume for the ‘NEW Segmentation’, I can execute code similar to the following to use logical operator effects and the ‘INTERSECT’ operation: