Hello everyone,
I’d like to create a DICOM serie from a MR-PET fusion.
I have coregistred the two volumes.
I’d like to create a new volume with “add scalar volumes” module, using specific color and opacity settings for the two previous volumes (used in the general scene, cf image)
- Volume 1 “MR”, color “Grey”, auto level, opacity 1
- Volume 2 “PET”, color “PET-Rainbow2” with window/level w: 8000 L: 5000, opacity 0.4
I tried the command downhere in python console but it doesn’t work.
Any help ?
I’m using 3Dslicer 5.6.2.
# Import necessary modules
import slicer
# Load volumes (replace with the paths to your actual volume files if needed)
volume1 = slicer.util.getNode('MR') # Load MR volume
volume2 = slicer.util.getNode('PET') # Load PET volume
# Set display parameters for MR volume
mr_display = volume1.GetDisplayNode()
mr_display.SetAndObserveColorNodeID('vtkMRMLColorTableNodeGrey')
mr_display.SetAutoWindowLevel(True)
mr_display.SetOpacity(1.0)
# Set display parameters for PET volume
pet_display = volume2.GetDisplayNode()
pet_display.SetAndObserveColorNodeID('vtkMRMLColorTableNodePET-Rainbow2')
pet_display.SetWindow(8000)
pet_display.SetLevel(5000)
pet_display.SetOpacity(0.4)
# Use Add Scalar Volumes module to create a fused volume
fused_volume = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLScalarVolumeNode', 'FusedVolume')
parameters = {
'inputVolume1': volume1,
'inputVolume2': volume2,
'outputVolume': fused_volume,
'scaleFactor1': 1.0, # Weight for MR
'scaleFactor2': 1.0, # Weight for PET
}
slicer.cli.run(slicer.modules.addscalarvolumes, None, parameters, wait_for_completion=True)
# Visualize the fused volume
fused_display = fused_volume.GetDisplayNode()
fused_display.SetAndObserveColorNodeID('vtkMRMLColorTableNodeGrey') # Adjust color as needed
slicer.util.setSliceViewerLayers(background=fused_volume, foreground=volume2, foregroundOpacity=0.4)