Segmentation in SPM5(b) actually uses spm_preproc.m, rather than
spm_segment.m. Take a look at spm_config_preproc.m for details about how the
function is called.
job.opts.tpm = strvcat(job.opts.tpm{:});
for i=1:numel(job.data),
res = spm_preproc(job.data{i},job.opts);
[sn(i),isn] = spm_prep2sn(res);
[pth,nam] = spm_fileparts(job.data{i});
savefields(fullfile(pth,[nam '_seg_sn.mat']),sn(i));
savefields(fullfile(pth,[nam '_seg_inv_sn.mat']),isn);
end;
spm_preproc_write(sn,job.output);
If you create a job file via the user-interface, then you can load it into
Matlab. The "job" variable used by the piece of code above is derived by
setting:
job = jobs{1}.spatial{1}.preproc
Best regards,
-John
On Thursday 08 December 2005 19:24, Armin Reinartz wrote:
> Dear John and SPM expert,
>
> I started working with SPM5b two months ago and have now some problems to
> set the right defaults for segmentation. I hope you can help me.
>
> I worked with the SPM GUI and set the following defaults. Now I want to
> change to the segment.m. My question: Which defaults will I have to set to
> get the same results like working with the SPM GUI:
> OUTPUTFILES: Grey: native+modulated normalised
> White: native+modulated normalised
> CSF: native+modulated normalised
> BIAS cor: save BIAS corrected
> CUSTOM: TPM: C:\Matlab6p5\wgrey.nii;...\wwhite.nii\...wcsf.nii
>
> GAUSSIAN: 2 2 2 4
> AFFINE REG: Average sized template
> WARPING REG: 1
> WARP FR CUTOFF: 25
> BIAS REG: 0.001
> BIAS FWHM: 60mm
> SAMP: 3
>
> Working with the m-file, I set the following defaults, but the programm
> gives me just the modulated images(mw...img) and the native segmented
> images (c1*img,c2*img,c3*img) but I donīt get native+modulated normalised
> images (mwc1w...img or mwc2w...img).
> What did I forget to set?
> Is it possible to get these to save them on disc?
>
> The defaults I set in the m-file:
> defaults.segment.estimate.priors = char(...
> fullfile('C:\Matlab6p5\work','wgrey.nii'),...
> fullfile('C:\Matlab6p5\work','wwhite.nii'),...
> fullfile('C:\Matlab6p5\work','wcsf.nii'));
> defaults.segment.estimate.reg = 0.001;
> defaults.segment.estimate.cutoff = 25;
> defaults.segment.estimate.samp = 3;
> defaults.segment.estimate.bb = [[-78 78]' [-112 76]' [-50 85]'];
> defaults.segment.estimate.affreg.smosrc = 8;
> defaults.segment.estimate.affreg.regtype = 'mni';
> defaults.segment.estimate.affreg.weight = '';
> defaults.segment.write.cleanup = 1;
> defaults.segment.write.wrt_cor = 1;
> defaults.segment.write.wrt_brV = 1;
> defaults.segment.graphics = 0;
>
> disp('start segmentation');
> range = [0 30];
> P = spm_select(range,'image','Specify image(s) to be segmented');
> end
> V=spm_vol(P);
> Q = defaults.segment.estimate.priors;
> V = cat(1,V(:));
> [VO, M] = spm_segment(V,Q,defaults.segment.estimate);
> disp('segmentation done');
>
> Please help me and tell which defaults I have to set or what I`ll have to
> programme in the m-file to get the same results as working with the SPM
> GUI.
>
> Thank you
> Armin
|