# Perform bulk resamples with python

**URL:** <https://discourse.slicer.org/t/perform-bulk-resamples-with-python/5561>\
**Category:** Support\
**Tags:** resample\
**Created:** [January 29, 2019, 2:37pm UTC](https://discourse.slicer.org/t/perform-bulk-resamples-with-python/5561 "2019-01-29T14:37:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)\
**Post date:** [January 29, 2019, 2:37pm UTC](https://discourse.slicer.org/t/perform-bulk-resamples-with-python/5561/1 "2019-01-29T14:37:50Z")

</div>

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?

![](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/3/63065456cad1e7366b47b5c09966d867d160a30c.png)

---

<div class="post-metadata">

**Author:** ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)\
**Post date:** [January 29, 2019, 3:56pm UTC](https://discourse.slicer.org/t/perform-bulk-resamples-with-python/5561/2 "2019-01-29T15:56:15Z")

</div>

I am currently having problems with the following code

```python
    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](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/1/117828f76de0ce02ef7dd77bde5da7025c1016e2.png)

---

<div class="post-metadata">

**Author:** ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)\
**Post date:** [January 29, 2019, 4:05pm UTC](https://discourse.slicer.org/t/perform-bulk-resamples-with-python/5561/3 "2019-01-29T16:05:25Z")

</div>

Ok, my mistake, the correct parameter list is

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

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/d/5de3960de578f0e99297254ac34fdc8821d7fd29.png)
