This would do it: defs = matlabbatch{1}.spm.util.defs; spm_defs(defs); Essentially, you could create a structure like the following: defs.comp{1}.inv.comp{1}.def = {'C:test\y_def.nii'}; defs.comp{1}.inv.space = {'C:\test\patient.nii,1'}; defs.ofname = 'invdef'; defs.fnames = {'C:\test\mask.nii,1'}; defs.savedir.savepwd = 1; defs.interp = 1; Best regards, -John On 5 June 2013 16:10, Catharina Lange <[log in to unmask]> wrote: > Hello! > > I am working with SPM8. After stereotactical normalisation, I searched for a way to invert the transformation to apply the inverse to some masks. The Deformation Utility generated quite satisfying results. > Now, I want to "implement" or include these work flows (writing deformations as an nifti image, inverting the deformation field and applying it to my mask) into my matlab routine. > I found the function "spm_defs.m" with the explanation "Various deformation field utilities" and a reference to "spm_config_defs.m" and "spm_jobman". > Additionally, I've already saved the scripts of the batch editor (after successfully running the above mentioned deformation work flows) and had a look into them. > > matlabbatch{1}.spm.util.defs.comp{1}.inv.comp{1}.def = {'C:test\y_def.nii'}; > matlabbatch{1}.spm.util.defs.comp{1}.inv.space = {'C:\test\patient.nii,1'}; > matlabbatch{1}.spm.util.defs.ofname = 'invdef'; > matlabbatch{1}.spm.util.defs.fnames = {'C:\test\mask.nii,1'}; > matlabbatch{1}.spm.util.defs.savedir.savepwd = 1; > matlabbatch{1}.spm.util.defs.interp = 1; > and so on... > > I am no Matlab expert, so I hope, someone could give me a hint, which Matlab functions of the Deformation Utility have to used or respectively in which way I have to implement the "jobs" with the "jobman". > > Thank you very much in advance for your answers! > Best regards, > Catharina.