Print

Print


I think the problem relates to how you set up your MATLABPATH.  If you
start up spm and then type your spm_jobman command, the path should
have been set up for you.  If you don't first start spm, then you'll
need to use the path command so that MATLAB can find all the various
functions it needs.

Best regards,
-John

On 26 January 2012 19:17, Rodrigo Perea <[log in to unmask]> wrote:
> Hello,
> I was wondering if you could help me with this issue. I created a .m file so I can run the following script (below) but sometimes it works and sometimes it give me the following error:
>
>  ??? Undefined function or method 'cfg_util' for input arguments of type 'cell'.
> Error in ==> spm_jobman at 207
>  cjob = cfg_util('initjob', mljob);  Error in ==> Dartel_Step1_PereaReviewed at 123         spm_jobman('run',matlabbatch);
>
>
> I am running the file in a for loop so I want run it several times for several subjects but I just want to know why I get this error regarding   spm_jobman('run',matlabbatch). I know it works so assigning the files is not a problem but sometimes i get the error above :S
> Thanks in advance,
> Rodrigo
>
>
>
> Here is my .m file:
>
> for i = 1:length(ARRAY WITH ALL IMAGES),
>
> %
> ref = [IMAGE-Timepoint1(i)]
> mov = [IMAGE-Timepoint2(i)]
> %
>  c1   = ['c1' file1name '.nii']
>  jac = ['jy_' file2name '.nii']
>  change = ['GMchange_' file1name '.nii']
>
>        matlabbatch{1}.spm.spatial.coreg.estimate.ref = {ref};
>        matlabbatch{1}.spm.spatial.coreg.estimate.source = {mov};
>        matlabbatch{1}.spm.spatial.coreg.estimate.other = {''};
>        matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.cost_fun = 'nmi';
>        matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.sep = [4 2];
>        matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.tol = [0.02 0.02 0.02 0.001 0.001 0.001 0.01 0.01 0.01 0.001 0.001 0.001];
>        matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.fwhm = [7 7];
>
>        matlabbatch{2}.spm.tools.hdw.data.ref = {ref};
>        matlabbatch{2}.spm.tools.hdw.data.mov = {mov};
>        matlabbatch{2}.spm.tools.hdw.bias_opts.nits = 8;
>        matlabbatch{2}.spm.tools.hdw.bias_opts.fwhm = 60;
>        matlabbatch{2}.spm.tools.hdw.bias_opts.reg = 1e-006;
>        matlabbatch{2}.spm.tools.hdw.bias_opts.lmreg = 1e-006;
>        matlabbatch{2}.spm.tools.hdw.warp_opts.nits = 8;
>        matlabbatch{2}.spm.tools.hdw.warp_opts.reg = 4;
>
>            matlabbatch{3}.spm.tools.preproc8.channel.vols = {ref};
>        matlabbatch{3}.spm.tools.preproc8.channel.biasreg = 0.0001;
>        matlabbatch{3}.spm.tools.preproc8.channel.write = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(1).tpm = {'/usr/local/spm8/toolbox/Seg/TPM.nii,1'};
>        matlabbatch{3}.spm.tools.preproc8.tissue(1).ngaus = 2;
>            matlabbatch{3}.spm.tools.preproc8.tissue(1).native = [1 1];
>        matlabbatch{3}.spm.tools.preproc8.tissue(1).warped = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(2).tpm = {'/usr/local/spm8/toolbox/Seg/TPM.nii,2'};
>        matlabbatch{3}.spm.tools.preproc8.tissue(2).ngaus = 2;
>        matlabbatch{3}.spm.tools.preproc8.tissue(2).native = [1 1];
>        matlabbatch{3}.spm.tools.preproc8.tissue(2).warped = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(3).tpm = {'/usr/local/spm8/toolbox/Seg/TPM.nii,3'};
>        matlabbatch{3}.spm.tools.preproc8.tissue(3).ngaus = 2;
>        matlabbatch{3}.spm.tools.preproc8.tissue(3).native = [1 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(3).warped = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(4).tpm = {'/usr/local/spm8/toolbox/Seg/TPM.nii,4'};
>        matlabbatch{3}.spm.tools.preproc8.tissue(4).ngaus = 3;
>        matlabbatch{3}.spm.tools.preproc8.tissue(4).native = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(4).warped = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(5).tpm = {'/usr/local/spm8/toolbox/Seg/TPM.nii,5'};
>        matlabbatch{3}.spm.tools.preproc8.tissue(5).ngaus = 4;
>        matlabbatch{3}.spm.tools.preproc8.tissue(5).native = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(5).warped = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(6).tpm = {'/usr/local/spm8/toolbox/Seg/TPM.nii,6'};
>        matlabbatch{3}.spm.tools.preproc8.tissue(6).ngaus = 2;
>        matlabbatch{3}.spm.tools.preproc8.tissue(6).native = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.tissue(6).warped = [0 0];
>        matlabbatch{3}.spm.tools.preproc8.warp.reg = 4;
>        matlabbatch{3}.spm.tools.preproc8.warp.affreg = 'mni';
>        matlabbatch{3}.spm.tools.preproc8.warp.samp = 3;
>        matlabbatch{3}.spm.tools.preproc8.warp.write = [0 0];
>
>            matlabbatch{4}.spm.util.imcalc.input = {c1,jac};
>        matlabbatch{4}.spm.util.imcalc.output = change;
>        matlabbatch{4}.spm.util.imcalc.outdir = {''};
>        matlabbatch{4}.spm.util.imcalc.expression = 'i1.*(i2-1)';
>        matlabbatch{4}.spm.util.imcalc.options.dmtx = 0;
>        matlabbatch{4}.spm.util.imcalc.options.mask = 0;
>        matlabbatch{4}.spm.util.imcalc.options.interp = 1;
>        matlabbatch{4}.spm.util.imcalc.options.dtype = 4;
>
>        spm_jobman('run',matlabbatch);
> end %for i