# saveNode doesn't work properly

**URL:** <https://discourse.slicer.org/t/savenode-doesnt-work-properly/16308>\
**Category:** Support\
**Tags:** python, nifti, resample\
**Created:** [March 2, 2021, 3:00pm UTC](https://discourse.slicer.org/t/savenode-doesnt-work-properly/16308 "2021-03-02T15:00:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![user20s](https://avatars.discourse-cdn.com/v4/letter/u/da6949/32.png) [@user20s](https://discourse.slicer.org/u/user20s)\
**Post date:** [March 2, 2021, 3:00pm UTC](https://discourse.slicer.org/t/savenode-doesnt-work-properly/16308/1 "2021-03-02T15:00:59Z")

</div>

Operating system: Linux Ubuntu 18.04.5 LTS  
Slicer version: 4.11.20210226-linux-amd64  
Expected behavior: saving a nifti file using saveNode  
Actual behavior: not saving

Hi all, I have a code written in python which should load some volumes and a transform and use the module brain resample.

It seems to work fine and when I run it using the command:

> ./Slicer --no-main-window --python-script /home/user/Desktop/test\_3D\_slicer.py

it outputs a table with standard output and at the end the line: "Resample Image (BRAINS) completed without errors. The problem is that it doesn’t save the new resampled image. I attach part of the code I use below. This is within a for loop where I change all parameters each iteration.

> ```
> resampledNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode')
> parameters = {'inputVolume': itemCT, 'referenceVolume': itemMR, 'outputVolume': resampledNode,
> 'warpTransform': itemTransform, 'interpolationMode': 'Linear'}
> 
> slicer.cli.run(slicer.modules.brainsresample, None, parameters)
> slicer.util.saveNode(resampledNode, output_filename)
> 
> ```

It seems to run fine except for not saving the new nifti. But if I copy paste each line of my code in the python interactor (CTRL+3) for just one iteration, it saves it and also in the right folder so surely output\_filename is defined correctly.

Any ideas why this happens?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 2, 2021, 3:04pm UTC](https://discourse.slicer.org/t/savenode-doesnt-work-properly/16308/2 "2021-03-02T15:04:11Z")

</div>

A post was merged into an existing topic: [saveNode not working properly](https://discourse.slicer.org/t/savenode-not-working-properly/16309)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 2, 2021, 3:04pm UTC](https://discourse.slicer.org/t/savenode-doesnt-work-properly/16308/3 "2021-03-02T15:04:11Z")

</div>


