I’m following the recipe for CT skull stripping (Overview | 3D Slicer segmentation recipes) which works perfectly in the GUI. I am attempting to automate this with python as I have many samples. I am new to this so sorry if any of this is trivial
Pseudocode/code steps as far as I can understand are the following:
- Import ct image into masterVolume node
masterVolumeNode = slicer.util.loadVolume(pathct)
- I have previously already thresholded out the skull (HU >300) and removed all small islands and need to load this array it into a Segmentation node.
#Create Labelmap Node
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLabelMapVolumeNode")
#set its voxels from a numpy array using slicer.util.updateVolumeFromArray
**Labelmap_Skull = slicer.util.updateVolumeFromArray(skull_seg_arr, labelmapVolumeNode)**
#Create segmentation node
segmentationNode = slicer.vtkMRMLSegmentationNode()
slicer.mrmlScene.AddNode(segmentationNode)
segmentationNode.CreateDefaultDisplayNodes() # only needed for display
segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode(masterVolumeNode)
#Convert to segmentation node
slicer.vtkSlicerSegmentationsModuleLogic.ImportLabelmapToSegmentationNode(Labelmap_Skull, segmentationNode, selectedSegmentIds)
Next, I need to implement the WrapSolidify effect with the following parameters:
#set region to Largest cavity
#Enable Split cavities and set cavity size slider to approximately 30mm
# import module
import SegmentEditorWrapSolidify
However, I’ve been looking around at the source code Slicer-SurfaceWrapSolidify/SegmentEditorWrapSolidify.py at master · sebastianandress/Slicer-SurfaceWrapSolidify · GitHub and am a little lost concerning how to actually implement this in Python. I don’t understand the difference between the 2 classes, SegmentEditorWrapSolidifyTest and SegmentEditorWrapSolidify. Nor how to invoke an instance of these classes seeing as Wrapsolidify = SegmentEditorWrapSolidify() shows the error “TypeError: ‘module’ object is not callable”
Are there any examples I could follow or anything similar?
Thanks in advance.