> I would like to superimpose activations on template slices and
> save it on a disk file.
Try copying and pasting the following.....
V = spm_vol(spm_get(2,'*.img','Select background and forefround
images')); thresh = spm_input('Threshold',1,'e',[],1);
mxb=-Inf;
for i=1:V(1).dim(3),
tmp = spm_slice_vol(V(1),spm_matrix([0 0 i]),V(1).dim(1:2),0);
mxb = max(mxb,max(tmp(:)));
end;
mxf=-Inf;
for i=1:V(2).dim(3),
tmp = spm_slice_vol(V(2),spm_matrix([0 0 i]),V(2).dim(1:2),0);
mxf = max(mxf,max(tmp(:)));
end;
VO = struct(...
'fname', 'superimposed.img',...
'dim', [V(1).dim(1:3) spm_type('uint8')],...
'pinfo', [1 0 0]',...
'mat', V(1).mat,...
'descrip','Superimposed blobs');
VO = spm_create_vol(VO);
for i=1:VO.dim(3),
Mb = spm_matrix([0 0 i]);
bg = spm_slice_vol(V(1),Mb,V(1).dim(1:2),0);
Mf = V(2).mat\V(1).mat*Mb;
fg = spm_slice_vol(V(2),Mf,V(1).dim(1:2),0);
msk = fg>thresh;
bg = bg*(127/mxb);
fg = (fg-thresh)*(127/(mxf-thresh))+128;
fg(~msk) = 0;
bg( msk) = 0;
dat = bg + fg;
VO = spm_write_plane(VO,dat,i);
end;
VO = spm_close_vol(VO);
Best regards,
-John
--
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
|