MRI PET fusion "add scalar volumes" new volume with color & opacity settings

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)

How do you intend to use the result? If you make a color image the typical DICOM container would be a SecondaryCapture (screen grab) but this is really just for display. Do you plan to send this to some other system?

Actually, I’d like to be able to export the images to another viewer to share the results of 3DSlicer more easily.

Similarly, is there a solution to export labelled markups to DICOM series?
(in order to compare the maxima of several intensity maps)

Thank you,

You should check what the other viewer supports, but if it’s a typical radiology system it probably only supports secondary capture for this kind of image.

In Slicer you can use the ScreenCapture module to acquire sweeps, or you can get them easily programmatically. This will capture the rendered composite image plus whatever markups you have.

For whatever reason I don’t think we’ve ever hooked this up to make dicom secondary captures, but this would be a very reasonable thing to do using something like DCMTK: img2dcm: Convert standard image formats into DICOM format.