Dear SPM ers,
> I have a naive question , is there way of saving the activation blobs which are superimposed on the anatomical scans as analyze images ? I mean if I displayed an anatomical scan and then added blobs to show activation , is there a way I can save the images in analyze format ?
>
>thanks
>
>Vijay
>
>
Dear Vijay,
John Ashburner wrote two scripts for doing it (and it works perfectly
well!). You can find them in the following messages:
*Date:* Thu, 13 Mar 2003 19:39:14 +0000
*Reply-To:* John Ashburner <[log in to unmask]>
*Sender:* "SPM (Statistical Parametric Mapping)" <[log in to unmask]>
*From:* John Ashburner <[log in to unmask]>
*Organization:* FIL
*Subject:* Fwd: Re: saving superimposed images
*Content-Type:* text/plain; charset="iso-8859-1"
> 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 <http://www.fil.ion.ucl.ac.uk/%7Ejohn>
and
*Date:* Fri, 14 Mar 2003 13:16:26 +0000
*Reply-To:* John Ashburner <[log in to unmask]>
*Sender:* "SPM (Statistical Parametric Mapping)" <[log in to unmask]>
*From:* John Ashburner <[log in to unmask]>
*Organization:* FIL
*Subject:* Fwd: Re: saving superimposed images
*Content-Type:* text/plain; charset="iso-8859-1"
The original question was: > > I would like to superimpose activations
on template slices and > > save it on a disk file. > I tryed to use your
routine getting the following problem, do i need > another routine ? > >
??? Undefined function or variable 'spm_create_vol'. > > Error in ==>
c:\spm\spm99\spm99\spm_save_images.m > On line 22 ==> VO =
spm_create_vol(VO); > > > To obtain the same images as using "OVERLAY
SECTION" > after results, which file do I use (filtered file, or
spmT_0002) I should have said that my little script only works for
SPM2b. For SPM99, you could try this slightly modified version: 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_image(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; 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 <http://www.fil.ion.ucl.ac.uk/%7Ejohn>
Best regards,
Dragana
|