Home > functions > tool_box > atlas2vb_dir > vb_atlas2vb_aal.m

vb_atlas2vb_aal

PURPOSE ^

vb_atlas2vb_aal create an area indices

SYNOPSIS ^

function vb_atlas2vb_aal(parm)

DESCRIPTION ^

 vb_atlas2vb_aal create an area indices
   based on the Automated anatomical labeling 'aal'-atlas
 ---- Syntax
 vb_atlas2vb_aal(parm)

 ---- Input
 fields in 'parm'
 atlas_dir      : Dir of atlas file 'aal.img'
 save_areafile  : Area file saved
 save_atlasfile : Atlas file saved
 save_xyzfile   : MNI & Talairach coordinate file
 brainfile      : brain file;


 --- Function required  
  explode      : string manupilation 

 ---- NOTE -----
 When using the normalize transformation matrix created by 'spm99',  
 back transformation results with a little shift 
 toward X(Left-Right) direction compared with brain file.
 It is highly recommended to recalculate 
 the transformation matrix by spm2 !!!

 2005/03/03 OY
 2005/03/28 modified 
 2005/04/21 second part modified
 2005/09/09 ver.030b compatible
 2005/12/22 M.Sato
 2006/2/3   M.Sato
 2006/11/14 M.Sato
 2007/03/05 OY
 * MNI coordinate is stored in brainfile.
 * save_xyzfile is removed.
 * A label for 'Corpus' is NaN.
 2009-01-05 Taku Yoshioka
   Supression of confirmation dialog

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    vb_atlas2vb_aal(parm)
0002 % vb_atlas2vb_aal create an area indices
0003 %   based on the Automated anatomical labeling 'aal'-atlas
0004 % ---- Syntax
0005 % vb_atlas2vb_aal(parm)
0006 %
0007 % ---- Input
0008 % fields in 'parm'
0009 % atlas_dir      : Dir of atlas file 'aal.img'
0010 % save_areafile  : Area file saved
0011 % save_atlasfile : Atlas file saved
0012 % save_xyzfile   : MNI & Talairach coordinate file
0013 % brainfile      : brain file;
0014 %
0015 %
0016 % --- Function required
0017 %  explode      : string manupilation
0018 %
0019 % ---- NOTE -----
0020 % When using the normalize transformation matrix created by 'spm99',
0021 % back transformation results with a little shift
0022 % toward X(Left-Right) direction compared with brain file.
0023 % It is highly recommended to recalculate
0024 % the transformation matrix by spm2 !!!
0025 %
0026 % 2005/03/03 OY
0027 % 2005/03/28 modified
0028 % 2005/04/21 second part modified
0029 % 2005/09/09 ver.030b compatible
0030 % 2005/12/22 M.Sato
0031 % 2006/2/3   M.Sato
0032 % 2006/11/14 M.Sato
0033 % 2007/03/05 OY
0034 % * MNI coordinate is stored in brainfile.
0035 % * save_xyzfile is removed.
0036 % * A label for 'Corpus' is NaN.
0037 % 2009-01-05 Taku Yoshioka
0038 %   Supression of confirmation dialog
0039 %
0040 % Copyright (C) 2011, ATR All Rights Reserved.
0041 % License : New BSD License(see VBMEG_LICENSE.txt)
0042 
0043 %
0044 % ---- Define aal-atlas
0045 %
0046 
0047 % Max value corresponding to Cerebrum cortex region in aal-atlas
0048 %  1-90: Cerebrum, 91-108: Cerebellum, 109-116: Vermis
0049 MaxLabel   = 90;    
0050 
0051 atlas_dir  = parm.atlas_dir;
0052 atlas_id   = 'aal';
0053 atlas_text = [atlas_dir 'aal.txt'];
0054 atlas_file = [atlas_dir 'aal.img'];
0055 brainfile  = parm.brainfile;
0056 
0057 save_areafile  = parm.save_areafile;
0058 save_atlasfile = parm.save_atlasfile;
0059 
0060 % Max radius to check minimum distance to corresponding point [mm]
0061 if    isfield(parm,'Rlimit')
0062     Rlimit = parm.Rlimit;
0063 else
0064     Rlimit = 4; 
0065 end
0066 
0067 % Max radius to search corresponding point [mm] in the 1st-step
0068 if    isfield(parm,'Rmax')
0069     Rmax = parm.Rmax;
0070 else
0071     Rmax = 2; 
0072 end
0073 
0074 % In the 1st-step, nearest point is searched within Rmax
0075 % In the 2nd-step, nearest point is searched for all candidates
0076 % This value determine, efficiency of search,
0077 % but does not change the result
0078 
0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0080 %%%%%%%%%%%%%%%%%%%% Don't modify %%%%%%%%%%%%%%%%%%%%%%%%%%%
0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0082 
0083 %%% Template file is neurological format (right handed spm).
0084 
0085 % ----- Corpus label
0086 corpus_key   = 'Corpus';
0087 corpus_label = NaN;
0088 
0089 %
0090 % ---- Load MNI-mm-coordinate for subject brain (should be calculated before)
0091 %
0092 load(brainfile, 'Vmni','derr');
0093 XYZmm = Vmni*1000;   % mm
0094 dd    = derr*1000;   % mm
0095 
0096 [Npoint, NdipoleL] = vb_load_cortex_info(brainfile);
0097 Vlabel     = zeros(Npoint,1);
0098 dd_label = zeros(Npoint,1);
0099 
0100 %
0101 % ----- Remove corpus
0102 %
0103 fprintf('---  Remove corpus region\n');
0104 [Vindx, Iremove] = vb_remove_corpus_run(brainfile);
0105 Vlabel(Iremove)  = corpus_label;
0106 
0107 fprintf('# of Corpus points = %d\n',length(Iremove))
0108 
0109 %
0110 % ---- Load Atlas template file
0111 %
0112 
0113 % Read image-header
0114 [dim, Trans, XYZmm0] = vb_get_image_info(atlas_file);
0115 
0116 % Read atlas-template image
0117 % Z    - 3D image data
0118 %Zlabel = read_image(atlas_file);
0119 
0120 avw = avw_img_read(atlas_file);
0121 Zlabel = avw.img;
0122 
0123 % Zlabel - 3D image data (label value)
0124 % XYZmm0 - 3 x n matrix of XYZ locations
0125 %        mm-coordinates in atlas-template (origin is specified by image file)
0126 Zlabel = Zlabel(:);
0127 
0128 % Extract labeled region
0129 mni_id = find(Zlabel ~= 0); 
0130 Zlabel = Zlabel(mni_id);
0131 XYZmm0 = XYZmm0(:,mni_id)';
0132 
0133 %
0134 % ---- Left brain (Left label is odd integer in 'aal')
0135 %
0136 ix_L  = find( mod( Zlabel, 2 ) == 1 & Zlabel < MaxLabel);
0137 ix_LV = Vindx( Vindx <= NdipoleL );
0138 
0139 fprintf('# of Left template points = %d\n',length(ix_L))
0140 fprintf('# of Left brain points    = %d\n',length(ix_LV))
0141 
0142 fprintf('--- Mapping Atlas-label onto 2D cortical surface \n');
0143 
0144 % Find nearest labeled point in atlas
0145 [indx, dd_tmp] = ...
0146         vb_find_nearest_point(XYZmm0(ix_L,:), XYZmm(ix_LV,:), Rmax, 100, 0, 1);
0147 
0148 fprintf('# of matched Left brain points    = %d\n',length(indx))
0149 
0150 % Find points whose minimum distance to atlas brain region is less than Rlimit
0151 ix_match = find( dd(ix_LV) <= Rlimit & dd_tmp < Rmax & indx > 0 );
0152 %ix_match = find( dd(ix_LV) <= Rlimit & dd_tmp < Rmax );
0153 
0154 fprintf('# of close points in Left brain   = %d\n',length(ix_match))
0155 
0156 % Map label to subject cortex
0157 Vlabel(ix_LV(ix_match)) = Zlabel(ix_L(indx(ix_match)));
0158 dd_label(ix_LV) = dd_tmp;
0159 %
0160 % ---- Right brain (Right label is even integer in 'aal')
0161 %
0162 ix_R  = find( mod( Zlabel, 2 ) == 0 & Zlabel <= MaxLabel);
0163 ix_RV = Vindx( Vindx > NdipoleL );
0164 
0165 fprintf('# of Right template points = %d\n',length(ix_R))
0166 fprintf('# of Right brain points    = %d\n',length(ix_RV))
0167 
0168 fprintf('--- Mapping Atlas-label onto 2D cortical surface \n');
0169 
0170 % Find nearest labeled point in atlas
0171 [indx, dd_tmp] = ...
0172         vb_find_nearest_point(XYZmm0(ix_R,:), XYZmm(ix_RV,:), Rmax, 100, 0, 1);
0173 
0174 fprintf('# of matched Right brain points    = %d\n',length(indx))
0175 
0176 % Find points whose minimum distance to atlas brain region is less than Rlimit
0177 ix_match = find( dd(ix_RV) <= Rlimit & dd_tmp < Rmax & indx > 0 );
0178 %ix_match = find( dd(ix_RV) <= Rlimit & dd_tmp < Rmax );
0179 
0180 fprintf('# of close points in Right brain   = %d\n',length(ix_match))
0181 
0182 % Map label to subject cortex
0183 Vlabel(ix_RV(ix_match)) = Zlabel(ix_R(indx(ix_match)));
0184 dd_label(ix_RV) = dd_tmp;
0185 
0186 % Fill label for large distant point
0187 ixz    = find( dd_label >= Rmax );
0188 fprintf('# of unlabeld point = %d\n', length(ixz))
0189 
0190 %fprintf('Filling unlabeled points\n')
0191 %Vlabel = vb_fill_atlas_label(brainfile, Vlabel, ixz, Rlimit);
0192 
0193 %
0194 % ---- Save labeled area
0195 %
0196 Nlabel = sum( Vlabel ~= 0 );    % # of labeled points
0197 fprintf('# of all vertex     = %d\n',Npoint)
0198 fprintf('# of cortex  points = %d\n',length(Vindx))
0199 fprintf('# of labeled points = %d\n',Nlabel)
0200 
0201 % Read atlas text file and extract area keys.
0202 [label, label_name] = vb_read_atlas_label(atlas_text);
0203 
0204 % Add Corpus label
0205 Narea = length(label);
0206 label(Narea+1) = corpus_label;
0207 label_name{Narea+1} = corpus_key;
0208 
0209 % Intensity of 'Act.xxP' is the label for each vertex
0210 Atlas.key = [atlas_id];
0211 Atlas.xxP = Vlabel;
0212 Atlas.label      = label;
0213 Atlas.label_name = label_name;
0214 Atlas.dd_label   = dd_label;
0215 
0216 % Save label as actfile
0217 fprintf('Save the atlas file as "%s"  \n', save_atlasfile);
0218 vb_add_act(save_atlasfile,Atlas,[],false);
0219 
0220 % Save area label into area file
0221 fprintf('Save the area file as "%s" \n', save_areafile);
0222 
0223 vb_save_atlas_label(save_areafile,Vlabel,label,label_name);
0224 
0225 clear Zlabel Vlabel XYZmm0 XYZmm Zlabel

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005