nipype.interfaces.spm.preprocess.ApplyDeformations crash

Hi everyone,
I am having a bit of a problem with the ApplyDeformations object in the SPM interfaces of nipype.
I want to apply an inverse deformation field calculated using segmentation to some image. To do so, I do the following:

from nipype.interfaces.spm.preprocess import ApplyDeformations
apply_def = ApplyDeformations()
apply_def.inputs.in_files = “/mnt/brain/my_temp/JHU-ICBM-labels-2mm.nii”
apply_def.inputs.deformation_field = “/mnt/brain/iy_my_subj.nii”
apply_def.inputs.reference_volume = “/mnt/brain/my_subj_T1.nii”
apply_def.inputs.interp = 0

Note that all the files are existing (double checked myself and in any case ApplyDeformations wouldn’t accept them if they weren’t).
I got the following spm error:

Item ‘Image to base Id on’, field ‘val’: Number of matching files (0) less than required (1).
Item defs: No field(s) named

I can’t really wrap my head around this: in the manual, it is said that the only compulsory inputs of ApplyDeformations are in_files, deformation_field and reference_volume, and they’re all provided.

If I look at the attribute inputs of my ApplyDeformations object I see the following:

deformation_field = /mnt/brain/iy_my_subj.nii
in_files = [’/mnt/brain/my_temp/JHU-ICBM-labels-2mm.nii’]
interp = 0
matlab_cmd =
mfile = True
paths =
reference_volume = /mnt/brain/my_subj_T1.nii
use_mcr =
use_v8struct = True

This once again confirms that all the compulsory inputs are provided.

I am working with nipype version 1.2.2, python version 3.6, Matlab R2016b and SPM12 v7487.

Any help would be much appreciated.

Maybe you have figured out the way around it but I think this is a bug in the nipype, and you should probably open an issue here (

I think the bug is in the InputSpec of this function:

class ApplyDeformationFieldInputSpec(SPMCommandInputSpec):
in_files = InputMultiPath(ImageFileSPM(exists=True), mandatory=True, field=“fnames”)
deformation_field = File(exists=True, mandatory=True, field=“comp{1}.def”)
reference_volume = ImageFileSPM(
exists=True, mandatory=True, field=“comp{2}”
interp = traits.Range(
low=0, high=7, field=“interp”, desc=“degree of b-spline used for interpolation”

I had to change the field for in_files from “fnames” to “out{1}.pull.fnames” for it to work for me. I hadn’t reported/tried pushing the fix since I wasn’t familiar with the SPM function enough to know if this is something specific to my use case… But you should open the issue so that someone can fix it!