# Batch resampling

**URL:** <https://discourse.slicer.org/t/batch-resampling/11748>\
**Category:** Support\
**Created:** [May 28, 2020, 2:09pm UTC](https://discourse.slicer.org/t/batch-resampling/11748 "2020-05-28T14:09:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hugotrentesaux/32/6404_2.png) [@HugoTrentesaux](https://discourse.slicer.org/u/HugoTrentesaux)\
**Post date:** [May 28, 2020, 2:09pm UTC](https://discourse.slicer.org/t/batch-resampling/11748/1 "2020-05-28T14:09:16Z")

</div>

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:

```bash
$ 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…

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [May 28, 2020, 7:06pm UTC](https://discourse.slicer.org/t/batch-resampling/11748/2 "2020-05-28T19:06:08Z")

</div>

You can do pretty much exactly that in bash using slicer CLI modules as executables using the [launcher](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Launcher).

You can also do [something similar](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python_scripting#Running_a_CLI_from_Python) in python if you would rather.

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hugotrentesaux/32/6404_2.png) [@HugoTrentesaux](https://discourse.slicer.org/u/HugoTrentesaux)\
**Post date:** [May 29, 2020, 9:19am UTC](https://discourse.slicer.org/t/batch-resampling/11748/3 "2020-05-29T09:19:26Z")

</div>

Thanks for pointing me to the relevant documentation.

The thing I needed was

```bash
Slicer --launch BRAINSResample --help

```

And the command to run

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

```

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [May 29, 2020, 11:45am UTC](https://discourse.slicer.org/t/batch-resampling/11748/4 "2020-05-29T11:45:16Z")

</div>

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