# N4ITKBiasFieldCorrection using nipype error

**URL:** https://discourse.slicer.org/t/n4itkbiasfieldcorrection-using-nipype-error/32880
**Category:** Support
**Created:** [November 17, 2023, 4:09pm UTC](https://discourse.slicer.org/t/n4itkbiasfieldcorrection-using-nipype-error/32880 "2023-11-17T16:09:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![georgek](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/georgek/32/68360_2.png) [@georgek](https://discourse.slicer.org/u/georgek)
#### Post date: [November 17, 2023, 4:09pm UTC](https://discourse.slicer.org/t/n4itkbiasfieldcorrection-using-nipype-error/32880/1 "2023-11-17T16:09:57Z")

</div>

Hi all,

I am just getting started with nipype and trying to perform N4 bias field correction on MR images. Here is the relevant code:

import nipype  
import nipype.interfaces.slicer as Slicer

BFC=Slicer.N4ITKBiasFieldCorrection()

BFC.inputs.inputimage= ‘T1.nii.gz’  
BFC.inputs.maskimage = ‘mask.nii.gz’  
BFC.inputs.outputimage= ‘T1\_slicer\_n4BFC.nii.gz’  
BFC.run()

and I am getting the following error:  
231117-11:56:45,217 nipype.interface INFO:  
stderr 2023-11-17T11:56:45.217168:terminate called after throwing an instance of ‘slicer\_itk::ImageFileReaderException’  
231117-11:56:45,218 nipype.interface INFO:  
stderr 2023-11-17T11:56:45.217168: what(): /work/Stable/Slicer-0-build/ITK/Modules/IO/ImageBase/include/itkImageFileReader.hxx:132:  
231117-11:56:45,218 nipype.interface INFO:  
stderr 2023-11-17T11:56:45.217168: Could not create IO object for reading file --inputimage  
231117-11:56:45,219 nipype.interface INFO:  
stderr 2023-11-17T11:56:45.217168:The file doesn’t exist.  
231117-11:56:45,219 nipype.interface INFO:  
stderr 2023-11-17T11:56:45.217168:Filename = --inputimage  
231117-11:56:45,220 nipype.interface INFO:  
stderr 2023-11-17T11:56:45.217168:  
231117-11:56:45,331 nipype.interface INFO:  
stderr 2023-11-17T11:56:45.331166:Aborted (core dumped)

Just to point out that I have been able to just use the background masking tool successfully just before that code so I presume it is not an installation or PATH issue  
masking =Slicer.BRAINSROIAuto()  
masking.inputs.inputVolume= ‘T1.nii.gz’  
masking.inputs.outputROIMaskVolume= ‘mask.nii.gz’  
masking.run()

Moreover, I can open the image using sitk.ReadImage (‘T1.nii.gz’) without any issues.

I am currently out of ideas. Has anyone got any ideas?
