1 and 2) Here’s what I do (when I know the seriesInstanceUID)
seriesNodeIDs = DICOMUtils.loadSeriesByUID([seriesInstanceUID,])
seriesVolumeNode = slicer.util.getNode(seriesNodeIDs[0])
storageNode = seriesVolumeNode.CreateDefaultStorageNode()
slicer.mrmlScene.AddNode(storageNode)
seriesVolumeNode.SetAndObserveStorageNodeID(storageNode.GetID())
storageNode.SetFileName(slicer.dicomDatabase.fileForInstance(sopInstanceUID))
- This uses the series volume as master
segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
# To show segment editor widget (useful for debugging): segmentEditorWidget.show()
segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
segmentEditorNode = slicer.vtkMRMLSegmentEditorNode()
slicer.mrmlScene.AddNode(segmentEditorNode)
segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode)
segmentEditorWidget.setSegmentationNode(segmentationNode)
segmentEditorWidget.setMasterVolumeNode(seriesVolumeNode)
- this add a segment with a custom color
lesionSegment = slicer.vtkSegment()
lesionSegment.SetName("Lesion Seeds")
lesionSegment.SetColor([0.0,1.0,0.0])
segmentationNode.GetSegmentation().AddSegment(lesionSegment,"lesionSeeds")