pieper
(Steve Pieper (Isomics, Inc.))
July 19, 2018, 2:00pm
8
Glad to know this is progress for you
Once you know how you want things to work via the GUI, you can make them work via python scripting too. If you search this forum for keywords segmentation and python and labelmap you’ll find lots of snippets.
This might be what you need:
There were a couple of problems:
It is not enough to create the segmentation node but you need to also add to the scene. You can use slicer.mrmlScene.AddNewNodeByClass to create a node and add it to the scene in one step.
slicer.util.loadVolume loads file as scalar volume, while ImportLabelmapToSegmentationNode expects a labelmap volume; you need to use slicer.util.loadLabelVolume instead
Relative path was used for the input image. I’m not sure what is the working directory of Slicer. It is s…
1 Like