vb_atlas2vb create an areafile based on the anatomical atlas ---- Syntax vb_atlas2vb_std_aal(parm) ---- Input (Field names in 'parm') atlas_id : ID of atlas. atlas_text : atlas label name text file atlas_file : atlas image file save_areafile : Area file saved save_atlasfile : Atlas file saved 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)
0001 function vb_atlas2vb_std_aal(parm) 0002 % vb_atlas2vb create an areafile based on the anatomical atlas 0003 % 0004 % ---- Syntax 0005 % vb_atlas2vb_std_aal(parm) 0006 % 0007 % ---- Input (Field names in 'parm') 0008 % atlas_id : ID of atlas. 0009 % atlas_text : atlas label name text file 0010 % atlas_file : atlas image file 0011 % save_areafile : Area file saved 0012 % save_atlasfile : Atlas file saved 0013 % brainfile : brain file; 0014 % 0015 % --- Function required 0016 % explode : string manupilation 0017 % 0018 % ---- NOTE ----- 0019 % When using the normalize transformation matrix created by 'spm99', 0020 % back transformation results with a little shift 0021 % toward X(Left-Right) direction compared with brain file. 0022 % It is highly recommended to recalculate 0023 % the transformation matrix by spm2 !!! 0024 % 0025 % 2005/03/03 OY 0026 % 2005/03/28 modified 0027 % 2005/04/21 second part modified 0028 % 2005/09/09 ver.030b compatible 0029 % 2005/12/22 M.Sato 0030 % 2006/2/3 M.Sato 0031 % 2006/11/14 M.Sato 0032 % 2007/03/05 OY 0033 % * MNI coordinate is stored in brainfile. 0034 % * save_xyzfile is removed. 0035 % * A label for 'Corpus' is NaN. 0036 % 2009-01-05 Taku Yoshioka 0037 % Supression of confirmation dialog 0038 % 0039 % Copyright (C) 2011, ATR All Rights Reserved. 0040 % License : New BSD License(see VBMEG_LICENSE.txt) 0041 0042 % 0043 % ---- Define aal-atlas 0044 % 0045 0046 % Max value corresponding to Cerebrum cortex region in aal-atlas 0047 % 1-90: Cerebrum, 91-108: Cerebellum, 109-116: Vermis 0048 MaxLabel = 90; 0049 0050 atlas_dir = parm.atlas_dir; 0051 atlas_id = 'aal'; 0052 atlas_text = [atlas_dir 'aal.txt']; 0053 atlas_file = [atlas_dir 'aal.img']; 0054 0055 brainfile = parm.brainfile; 0056 0057 save_areafile = parm.save_areafile; 0058 save_atlasfile = parm.save_atlasfile; 0059 0060 % In the 1st-step, nearest point is searched within Rmax 0061 % In the 2nd-step, nearest point is searched for all candidates 0062 % This value determine, efficiency of search, 0063 % but does not change the result 0064 0065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0066 %%%%%%%%%%%%%%%%%%%% Don't modify %%%%%%%%%%%%%%%%%%%%%%%%%%% 0067 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0068 0069 %%% Template file is neurological format (right handed spm). 0070 0071 % Standard brain cortex in MNI-mm coordinate (origin in MNI-space) 0072 load(brainfile,'V','F') 0073 0074 NL = F.NdipoleL; 0075 NP = size(V,1); 0076 Vlabel = zeros(NP,1); 0077 0078 % Read atlas-template image 0079 % Zlabel - label for 3D image data (label value) 0080 % XYZmm0 - 3 x n matrix of XYZ locations 0081 % mm-coordinates in atlas-template (origin : AC-PC center) 0082 0083 avw = avw_img_read(atlas_file); 0084 Zlabel = avw.img; 0085 0086 % Read image-header 0087 [dim, Trans] = vb_get_image_info(atlas_file); 0088 0089 % convert to standard voxcel coordinate from mm-coordinate 0090 Vox = [V*1000 ones(NP,1)] * inv(Trans'); 0091 Vox = round(Vox(:,1:3)); 0092 0093 % Extract labeled left/right region 0094 mni_L = sub2ind(dim, ... 0095 Vox(1:NL,1),Vox(1:NL,2),Vox(1:NL,3)); 0096 mni_R = sub2ind(dim, ... 0097 Vox(1+NL:end,1),Vox(1+NL:end,2),Vox(1+NL:end,3)); 0098 0099 % 0100 % ---- Left brain (Left label is odd integer in 'aal') 0101 % 0102 label_L = Zlabel(mni_L); 0103 ixz = find( mod( label_L, 2 ) == 0 | label_L > MaxLabel); 0104 label_L(ixz) = 0; 0105 % 0106 % ---- Right brain (Right label is even integer in 'aal') 0107 % 0108 label_R = Zlabel(mni_R); 0109 ixz = find( mod( label_R, 2 ) == 1 | label_R > MaxLabel); 0110 label_R(ixz) = 0; 0111 0112 fprintf('--- Mapping Atlas-label onto 2D cortical surface \n'); 0113 0114 % 0115 % ---- Save labeled area 0116 % 0117 Nlabel_L = sum( label_L ~= 0 ); % # of labeled points 0118 Nlabel_R = sum( label_R ~= 0 ); % # of labeled points 0119 0120 fprintf('# of all vertex = %d\n',NP) 0121 fprintf('# of labeled points = %d\n',Nlabel_L+Nlabel_R) 0122 0123 % Read atlas text file and extract area keys. 0124 [label, label_name] = vb_read_atlas_label(atlas_text); 0125 0126 % Save area label into area file 0127 fprintf('Save the area file as "%s" \n', save_areafile); 0128 0129 Vlabel(1:NL) = label_L; 0130 Vlabel(1+NL:end) = label_R; 0131 0132 vb_save_atlas_label(save_areafile,Vlabel,label,label_name); 0133 0134 % Intensity of 'Act.xxP' is the label for each vertex 0135 Atlas.key = [atlas_id]; 0136 Atlas.xxP = Vlabel; 0137 Atlas.label = label; 0138 Atlas.label_name = label_name; 0139 0140 % Save label as actfile 0141 fprintf('Save the atlas file as "%s" \n', save_atlasfile); 0142 vb_add_act(save_atlasfile,Atlas,[],false); 0143 0144 0145 %clear Zlabel Vlabel XYZmm0 XYZmm Zlabel