3D Slicer show nrrd file

Hello! I’m rewriting the DICOMWebBrowser extension to display a model from VolumeRendering with a selected study when starting 3D Slicer from console. How can I achieve this display? Currently, an MRMLNode is added, but I have to press a display button (I’ve attached a screenshot). How can I make it so that I don’t have to press the display button? I’ve attached the source code.


MySourceCode for this task:

import slicer

logic = slicer.modules.volumerendering.logic()

scene = slicer.mrmlScene

volumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLScalarVolumeNode', 'VolumeTest_1')

slicer.util.loadVolume('/home/danil/Документы/SlicerDICOMDatabase/DICOMwebLocal/7867c209a99ade387bac05b4999d78cd/1.3.6.1.4.1.5962.99.1.2786334768.1849416866.1385765836848.729.0.2TSE5512512.nrrd', {'name': 'VolumeTest_1'})

slicer.mrmlScene.AddNode(volumeNode)

displayNode = logic.CreateVolumeRenderingDisplayNode()
displayNode.UnRegister(logic)
slicer.mrmlScene.AddNode(displayNode)
volumeNode.AddAndObserveDisplayNodeID(displayNode.GetID())
logic.UpdateDisplayNodeFromVolumeNode(displayNode, volumeNode)

import slicer

logic = slicer.modules.volumerendering.logic()

scene = slicer.mrmlScene

volumeNode = slicer.mrmlScene.AddNewNodeByClass(‘vtkMRMLScalarVolumeNode’, ‘VolumeTest_1’)

slicer.util.loadVolume(‘/home/danil/Документы/SlicerDICOMDatabase/DICOMwebLocal/7867c209a99ade387bac05b4999d78cd/1.3.6.1.4.1.5962.99.1.2786334768.1849416866.1385765836848.729.0.2TSE5512512.nrrd’, {‘name’: ‘VolumeTest_1’})

slicer.mrmlScene.AddNode(volumeNode)

displayNode = logic.CreateVolumeRenderingDisplayNode()
displayNode.UnRegister(logic)
slicer.mrmlScene.AddNode(displayNode)
volumeNode.AddAndObserveDisplayNodeID(displayNode.GetID())
logic.UpdateDisplayNodeFromVolumeNode(displayNode, volumeNode)

Make with help VolumeNode from module “Data” with help Volume rendering — 3D Slicer documentation

1 Like

Help this source code:

data_display = slicer.util.loadVolume('/home/danil/test_dicom/1.nrrd')
logic = slicer.modules.volumerendering.logic()
volumeNode = slicer.mrmlScene.GetNodeByID(data_display.GetID())
displayNode = logic.CreateVolumeRenderingDisplayNode()
displayNode.UnRegister(logic)
slicer.mrmlScene.AddNode(displayNode)
volumeNode.AddAndObserveDisplayNodeID(displayNode.GetID())
logic.UpdateDisplayNodeFromVolumeNode(displayNode, volumeNode)
1 Like