Batch resampling

Is there a way to use the transform.h5 file from a script to apply the same transform on a batch of volumes? The easiest way would be directly from bash script like:

$ for i in $list;
do Slicer resample \
--transform transform${i}.h5 \
--fixed source${i}.nrrd \
--moving target${i}.nrrd;
done;

A python call would also make it, but I can not find documentation about that…

You can do pretty much exactly that in bash using slicer CLI modules as executables using the launcher.

You can also do something similar in python if you would rather.

1 Like

Thanks for pointing me to the relevant documentation.

The thing I needed was

Slicer --launch BRAINSResample --help

And the command to run

Slicer --launch BRAINSResample \
--inputVolume source_1.nrrd \
--outputVolume reformated_1.nrrd \
--referenceVolume target_1.nrrd \
--warpTransform transform_1.h5

cool - let us know what you find. The log file will show the parameters used when you invoke the cli module via the gui.