Dear Saul,
attached are two functions of which one might help. vox2mni transforms 3 by N
vectors of coordinates in voxel-space to MNI-space. In order to do so you
have to feed the function with the respective 4x4 matrix M of the volume as
well. This is stored in the field "mat" of a structure created by the function
spm_vol. So typing MNI=vox2mni(M,VOX) will give you then a 3 by N matrix of
vectors with MNI-coordinates. The other function simply does the reverse.
Hope that's what you need,
Thilo
On Tuesday 20 September 2005 14:08, Miller, Saul wrote:
> Hi,
> I'm trying to use a script to get the maximum T value from a mask I created
> in SPM2. The mask is basically a binary mask multiplied by a spmT image.
> Using a script, I am able to get the maximum T value and I'm also able to
> get at what coordinates in the matrix this T value occurrs, but I'm not
> sure how to go from the matrix coordinates into MNI coordinates, which is
> what I really want to know. Any help on this matter would be appreciated.
> See below for the script. Thank you.
> -Saul
>
>
> %Subjects list
> sub_list = str2mat('sub1','sub2','sub3');
> %Directory where subjects are located
> working_dir = '/study_dir/';
> %Directory where mask is located within subjects dir
> mask_dir = 'labels/';
> %text file containing .img mask
> inputfile = 'ROIs.txt';
>
>
> num_sub = size(sub_list,1);
>
>
> fid=fopen(inputfile);
> c=0;
> masks=[];
> while 1
> line = fgetl(fid);
> if ~isstr(line), break, end
> if c==0
> masks=line;
> c=1;
> else
> masks=str2mat(masks,line);
> end
> end
> fclose(fid);
> [nummasks,temp]=size(masks);
>
> fid = fopen('T_values.txt','w');
>
> for i=1:num_sub
> cur_sub = deblank(sub_list(i,:));
> fprintf(fid,['Subject: ',cur_sub,'\n']);
> for j=1:nummasks
> highT = 0;
> x_coord = 0;
> y_coord = 0;
> z_coord = 0;
> mask_name = masks(j,:);
> m_num = strfind(mask_name,'.');
> mask_label = masks(j,1:m_num-1);
> mask =
> spm_read_vols(spm_vol([working_dir,cur_sub,'/',mask_dir,mask_name]));
> for x=1:size(mask,1)
> for y=1:size(mask,2)
> for z=1:size(mask,3)
> if mask(x,y,z) > highT
> highT = mask(x,y,z);
> x_coord = x;
> y_coord = y;
> z_coord = z;
> end
> end
> end
> end
> fprintf(fid,[mask_label,': highest T: ',num2str(highT),'
> (',num2str(x_coord),',',num2str(y_coord),',',num2str(z_coord),')','\n']);
> end
> end
> fclose(fid);
--
Thilo Kellermann
RWTH Aachen University
Pauwelstr. 30
52074 Aachen
Tel.: +49 (0)241 / 8089977
Fax.: +49 (0)241 / 8082401
E-Mail: [log in to unmask]
|