I forgot that the data were represented as uint8, with a scalefactor of 1/255.
For the procedure to work, you may need to replace:
VT(3).dat = ((VT(1).dat + VT(2).dat + VT(3).dat)>0.5).*(1 - VT(1).dat - VT(2).dat);
with:
t1 = ((double(VT(1).dat) + double(VT(2).dat) + double(VT(3).dat)) > 0.5*255);
t2 = (1 - (double(VT(1).dat) + double(VT(2).dat))/255);
VT(3).dat = uint8(round((t1.*t2)*255));
All the best,
-John
> Thanks a lot for your help.
> Below if the whole VBM script we are using. Did we insert you patches in
> the right places?
>
> spm_defaults
> global defaults
> dseg = defaults.segment;
> dseg.write.wrt_cor = 0;
> dnrm = defaults.normalise;
> dnrm.write.vox = [1 1 1];
> % dnrm.write.bb(1,3) = -70;
> dnrm.estimate.graphics = 0;
>
> V = spm_vol(spm_get(Inf,'*.IMAGE','Select images'));
> VG0 = spm_vol(fullfile(spm('Dir'),'templates','T1.mnc'));
> VG1 = spm_vol(deblank(dseg.estimate.priors(1,:)));
>
> for i=1:length(V),
> [pth,nam,ext] = fileparts(V(i).fname);
> VT = spm_segment(V(i),VG0,dseg);
> VT = VT(1);
> prm = spm_normalise(VG1,VT,'','','',dnrm.estimate);
> clear VT
> VN = spm_write_sn(V(i),prm,dnrm.write);
> VT = spm_segment(VN,eye(4),dseg);
> clear VN
> VT(1).fname = fullfile(pth,['G' nam ext]);
> VT(2).fname = fullfile(pth,['W' nam ext]);
> VT(3).fname = fullfile(pth,['C' nam ext]);
> VT(3).dat = ((VT(1).dat + VT(2).dat + VT(3).dat)>0.5).*(1 - VT(1).dat - VT(2).dat);
> spm_write_sn(VT(1),prm,'modulate');
> spm_write_sn(VT(2),prm,'modulate');
> spm_write_sn(VT(3),prm,'modulate');
> clear VT
> end;
>
> We tried to run it and got this error
>
> ??? Error using ==> +
> Function '+' is not defined for values of class 'uint8'.
>
> Error in ==> /usr/local/spm2/temporary.m
> On line 26 ==> VT(3).dat = ((VT(1).dat + VT(2).dat + VT(3).dat)>0.5).*(1
> - VT(1).dat - VT(2).dat);
--
Dr John Ashburner.
Functional Imaging Lab., 12 Queen Square, London WC1N 3BG, UK.
tel: +44 (0)20 78337491 or +44 (0)20 78373611 x4381
fax: +44 (0)20 78131420 http://www.fil.ion.ucl.ac.uk/~john
|