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);
|