Using DRRGeneratorModule in a Python script

Hi all,

I would like to use the above module in a python script but am unsure how to do so. Below is something I have tried but I do not have that much experience in working in Slicer so I think I am misunderstanding the way modules are used correctly. If anyone can help me correct this It would be highly appreciated!

import slicer
import os

# Load CT volume
ct_volume = slicer.util.loadVolume(ct)

# Create DRR generator node
drr_generator = slicer.modules.drrgeneratormodule

# Set parameters
parameters = {}
parameters["InputVolume"] = ct_volume.GetID()
parameters["OutputResolution"] = [512, 512]

# Generate DRR
slicer.cli.runSync(drr_generator, None, parameters)

# Save DRR
output_path = os.path.join(output_folder, "drr.nii.gz")
slicer.util.saveNode(slicer.util.getNode('DRR'), output_path)

Thank you,

1 Like