# vtkMRMLScalarVolumeNode to SimpleITK image

**URL:** https://discourse.slicer.org/t/vtkmrmlscalarvolumenode-to-simpleitk-image/645
**Category:** Development
**Tags:** extensions-manager, vtk
**Created:** [July 7, 2017, 3:44pm UTC](https://discourse.slicer.org/t/vtkmrmlscalarvolumenode-to-simpleitk-image/645 "2017-07-07T15:44:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gulamhus](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gulamhus/32/390_2.png) [@gulamhus](https://discourse.slicer.org/u/gulamhus)
#### Post date: [July 7, 2017, 3:44pm UTC](https://discourse.slicer.org/t/vtkmrmlscalarvolumenode-to-simpleitk-image/645/1 "2017-07-07T15:44:32Z")

</div>

Hello all in the Slicer Forum.

I write an python Extension for Slicer and have the following Code that produces an error in the last line:

```
  for i in range(0, len(inputPlanes)):
    n = slicer.vtkMRMLScalarVolumeNode()  
    tempVolName = "tempVol_" + str(i)
    n.SetName(tempVolName)
    slicer.mrmlScene.AddNode(n)

    ### Compute the temporal volume using the CLI module brainsresample
    cliParams = {'inputVolume': inputPlane.GetID(), 'referenceVolume': referenceVolume.GetID(), 'outputVolume' : n.GetID()}
    cliNode = slicer.cli.run(slicer.modules.brainsresample, None, cliParams)

    itkImageVolume = sitkUtils.PullFromSlicer(n.GetName()) # throws error

```

for the last line I get the following intepreter error:

```
Traceback (most recent call last):
File "D:/repositories/My Slicer Extention/StVRegistration/StVRegistration/StVRegistration/StVRegistration.py", line 176, in onApplyButton
logic.run(inputPlanes, self.referenceVolumeSelector.currentNode(), self.outputVolumeSelector.currentNode())
File "D:/repositories/My Slicer Extention/StVRegistration/StVRegistration/StVRegistration/StVRegistration.py", line 296, in run
tempPlaneVol = sitkUtils.PullFromSlicer(n.GetName())
File "C:\Program Files\Slicer 4.7.0-2017-06-26\bin\Python\sitkUtils.py", line 100, in PullFromSlicer
sitkimage = sitk.ReadImage(myNodeFullITKAddress)
File "C:\Program Files\Slicer 4.7.0-2017-06-26\lib\Python\Lib\site-packages\SimpleITK\SimpleITK.py", line 8335, in ReadImage
return _SimpleITK.ReadImage(*args)
RuntimeError: Exception thrown in SimpleITK ReadImage: D:\D\N\Slicer-1-build\SimpleITK\Code\IO\src\sitkImageReaderBase.cxx:264:
sitk::ERROR: Logic error!

```

However, if I type the same last line in the interactive python console in Slicer after performing the script of the module it works just fine. Does anybody know what is going on there?

For the **CLI module brainsresample** I need _vtkMRMLScalarVolumeNodes_ as input but later I want to use **simpleITK** within the python script and therefor need _SimpleITK images_. How would I go about it?

What I try here is  
Thanks for your Reply

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)
#### Post date: [July 7, 2017, 3:47pm UTC](https://discourse.slicer.org/t/vtkmrmlscalarvolumenode-to-simpleitk-image/645/2 "2017-07-07T15:47:29Z")

</div>

Try adding `wait_for_completion=True` in the `slicer.cli.run` call.

---

<div class="post-metadata">

### Author: ![gulamhus](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gulamhus/32/390_2.png) [@gulamhus](https://discourse.slicer.org/u/gulamhus)
#### Post date: [July 7, 2017, 5:32pm UTC](https://discourse.slicer.org/t/vtkmrmlscalarvolumenode-to-simpleitk-image/645/3 "2017-07-07T17:32:03Z")

</div>

That did help thank you. =)
