Error when applying N4ITKBiasFieldCorrection with nipype

31 views Asked by At

I am just getting started with nipype and trying to perform N4 bias field correction on MR images using Slicer. However, I am getting an error that seems to be related to slicer_itk not being able to load the image. I am doing the task on an Ubuntu machine with Jupyter notebook.

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)

I have also tried the masking function to generate the mask image using the following which worked fine, 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.

If anyone has any ideas to try I'd really appreciate it.

0

There are 0 answers