Perform bulk resamples with python

I would like to perform a bulk resampling on several volumes, each volume has another associated who is the reference. I can use the module Resample Image (BRAINS) to do this, but since they are several ones and it is just a matter of defining Image to warp, Reference image, Output image, interpolation mode and default value and apply, I want to automatize this step.

How can I call recursively the Resample module from within python?

//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/slicer/original/2X/b/b67cb997987cc54136842164a0dc3cd48db8dce9.png

I am currently having problems with the following code

    parameters = {'ImageToWarp':itemCT, 'ReferenceImage':itemSPECT, 'OutputImage':clonedNode, 
                          'InterpolationMode':'Lanczos', 'DefaultValue':minCT}
    slicer.cli.run(slicer.modules.brainsresample, None, parameters)

the output has no data

image

Ok, my mistake, the correct parameter list is

    parameters = {'inputVolume':itemCT, 'referenceVolume':itemSPECT, 'outputVolume':clonedNode, 
                          'interpolationMode':'Lanczos', 'defaultValue':minCT}

image

1 Like