Segmentation (Extract Skin Py)

Hi,

Thanks @lassoan for your previously answers

I’m always in troubles with ExtractSkin

I tryed to import my own CT scan but it doesn’t work as your example datas

Further I will need to load DICOM.

masterVolumeNode = slicer.util.loadVolume(’/…/myCT.nrrd’, returnNode=True)
masterVolumeNode = slicer.mrmlScene.AddNewNodeByClass(“vtkmasterVolumeNode”)

#Create segmentation
segmentationNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLSegmentationNode”)
segmentationNode.CreateDefaultDisplayNodes() # only needed for display
segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode(masterVolumeNode)
addedSegmentID = segmentationNode.GetSegmentation().AddEmptySegment(“bone”)

#Create segment editor to get access to effects
segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
segmentEditorNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLSegmentEditorNode”)
segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode)
segmentEditorWidget.setSegmentationNode(segmentationNode)
segmentEditorWidget.setMasterVolumeNode(masterVolumeNode)

Occuring errors for all effects on apply line

#Thresholding
modifierLabelmap.GetImageToWorldMatrix(originalImageToWorldMatrix)
AttributeError: ‘NoneType’ object has no attribute ‘GetImageToWorldMatrix’

#Smoothing
modifierLabelmap.DeepCopy(smoothingFilter.GetOutput())
AttributeError: ‘NoneType’ object has no attribute ‘DeepCopy’

Here you load a volume into masterVolumeNode then immediately overwrite it with an empty volume, which breaks everything else.

1 Like