Hello. The attached code will also work. For all cluster max in the SPM results table it finds what the AAL and BA labels are from the MRICro maps. Just make sure you change the locations in the code for the BA and AAL maps.
I hope this helps,
Jason.
----- Original Message ----
From: Juanjo Lull (UPV) <[log in to unmask]>
To: [log in to unmask]
Sent: Monday, May 12, 2008 4:24:13 AM
Subject: Re: [SPM] hot to obtain BA#
Dear Vincent,
One short answear.
You can take your results image (if that is the case) via the 'Save' button.
Then you can use MRIcron to watch the BA number, if your results image
was in MNI space.
Best regards,
Juanjo
Defeng WANG wrote:
> Dear SPMers,
> I have a quick question. That is, how to obtain BA# in SPM?
> Cheers!
> Vincent
--
________________________________________________________
Juan J. Lull Noguera - jualulno_at_upvnet.upv.es
- [log in to unmask]
http://www.ibime.upv.es
[MI - Medical Imaging Area]
IBIME::Biomedical Informatics Group
UPV - Politechnical University of Valencia - Spain
________________________________________________________
[IM - Área de Imagen]
IBIME::Informática Biomédica
UPV - Universidad Politécnica de Valencia
________________________________________________________
"Education is the best provision for the journey to old age"
Aristotle
function FindAALandBAForSPMResults(xSPM, hReg)
% Usage:
% After results have been estimated and the glass brains are displayed in
% the Graphics window.
% Execute:
% FindAALandBAForSPMResults(xSPM, hReg)
%
% NOTE: This has been written for spm5.
%
% Extract all voxels from the SPM table of results and find the AAL and
% Brodmann Labels for them. Then write out most of the SPM results table
% and the AAL and BA labels to a tab-delimited text file.
%
% Note you will need to change the locations for MRICro which are hardcoded
% below.
%
% filename: FindAALandBAForSPMResults.m
% written by: Jason Steffener
% Date: 4/17/08
% Once SPM results are run this program will work
% The table of results is extracted
TabDat = spm_list('List', xSPM, hReg);
% The tabular data is broken into different arrays
NClust = size(TabDat.dat,1);
XYZmm = zeros(NClust,3);
TList = zeros(NClust,1);
ZList = zeros(NClust,1);
pList = zeros(NClust,1);
ClList = zeros(NClust,1);
for i = 1:NClust
XYZmm(i,:) = TabDat.dat{i,end}(:)';
TList(i,1) = TabDat.dat{i,8};
ZList(i,1) = TabDat.dat{i,9};
pList(i,1) = TabDat.dat{i,10};
tempCl = TabDat.dat{i,4};
if ~isempty(tempCl)
ClList(i,1) = tempCl;
end
end
% This program finds the AAL and Brodmann Area labels for all XYZ mm
% coordinates it is passed.
[AALList BAList] = subfnFindAALandBA(XYZmm);
% Create an informative output file name
OutPutFileName = [xSPM.title '_Teq' num2str(xSPM.u)];
OutPutFileName(findstr(OutPutFileName, ' ')) = '';
OutPutFileName(findstr(OutPutFileName, '.')) = 'p';
OutPutFileName(findstr(OutPutFileName, '(')) = '';
OutPutFileName(findstr(OutPutFileName, ')')) = '';
OutPutFileName(findstr(OutPutFileName, '<')) = 'l';
OutPutFileName(findstr(OutPutFileName, '>')) = 'g';
OutPutFileName = [OutPutFileName '_AALandBA.txt'];
OutPutFile = fullfile(xSPM.swd,[OutPutFileName]);
fid = fopen(OutPutFile, 'w');
% Write all data to file
fprintf(fid,'Region\tLat\tBrodmann Area\tx\ty\tz\tT\tZ\tp\tk\n');
for i = 1:NClust
fprintf(fid,'%s\t%s\t%d\t',AALList{i}(1:end-2), AALList{i}(end),BAList(i));
fprintf(fid,'%d\t%d\t%d\t',XYZmm(i,:));
fprintf(fid,'%0.2f\t%0.2f\t%0.2f\t%d\n',TList(i,1),ZList(i,1),pList(i,1),ClList(i,1));
end
fclose(fid);
fprintf('Data saved to:\n\t%s\n',OutPutFile);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [AALList BAList] = subfnFindAALandBA(XYZmm)
% This takes an array of XYZ coordinates in millimeters and finds the AAL
% and BA labels for them. Using mm coordinates they are converted to the
% voxel space of teh AAL and BA maps regardless of differing image sizes.
%
% filename: FindAALandBAForSPMResults.m
% written by: Jason Steffener
% Date: 4/17/08
%
%%%%% Change these before using!! %%%%%%%%%%%%%%%%%%%%%%%%
Paal = '/mnt/data6/Brady/mricro/aal.img';
[aalCol1 aalCol2 aalCol3] = textread('/mnt/data6/Brady/mricro/aal.txt','%d%s%d');
Pba = '/mnt/data6/Brady/mricro/brodmann.img';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Vba = spm_vol(Pba);
Vaal = spm_vol(Paal);
Iaal = spm_read_vols(Vaal);
Iba = spm_read_vols(Vba);
% Account for differing image sizes and flip the images
VMat = Vaal.mat;
VMat(1,1) = -VMat(1,1);
VMat(1,4) = -VMat(1,4);
NVoxels = length(XYZmm);
AALList = {};
BAList = zeros(NVoxels,1);
for i = 1:NVoxels
CurrentMMLoc = XYZmm(i,:)';
CurrentAALLoc = inv(VMat)*[CurrentMMLoc; 1];
CurrentValue = Iaal(CurrentAALLoc(1), CurrentAALLoc(2), CurrentAALLoc(3));
BAList(i,1) = Iba(CurrentAALLoc(1), CurrentAALLoc(2), CurrentAALLoc(3));
if CurrentValue
AALList{i} = aalCol2{CurrentValue};
else
AALList{i} = '**empty**';
end
end
|