Loading dicom directory into scene and obtaining master volume node

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))
  1. 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)
  1. 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")
1 Like