Home > functions > tool_box > atlas2vb_dir > vb_atlas2vb.m

vb_atlas2vb

PURPOSE ^

vb_atlas2vb create an areafile based on the anatomical atlas

SYNOPSIS ^

function vb_atlas2vb(parm)

DESCRIPTION ^

 vb_atlas2vb create an areafile based on the anatomical atlas
 
 ---- Syntax
 vb_atlas2vb(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)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    vb_atlas2vb(parm)
0002 % vb_atlas2vb create an areafile based on the anatomical atlas
0003 %
0004 % ---- Syntax
0005 % vb_atlas2vb(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 atlas_id   = parm.atlas_id;
0042 atlas_text = parm.atlas_text; 
0043 atlas_file = parm.atlas_file; 
0044 brainfile  = parm.brainfile;
0045 
0046 save_areafile  = parm.save_areafile;
0047 save_atlasfile = parm.save_atlasfile;
0048 
0049 % Max radius to check minimum distance to corresponding point [mm]
0050 if    isfield(parm,'Rlimit')
0051     Rlimit = parm.Rlimit;
0052 else
0053     Rlimit = 4; 
0054 end
0055 
0056 % Max radius to search corresponding point [mm] in the 1st-step
0057 if    isfield(parm,'Rmax')
0058     Rmax = parm.Rmax;
0059 else
0060     Rmax = 2; 
0061 end
0062 
0063 % In the 1st-step, nearest point is searched within Rmax
0064 % In the 2nd-step, nearest point is searched for all candidates
0065 % This value determine, efficiency of search,
0066 % but does not change the result
0067 
0068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0069 %%%%%%%%%%%%%%%%%%%% Don't modify %%%%%%%%%%%%%%%%%%%%%%%%%%%
0070 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0071 
0072 %%% Template file is neurological format (right handed spm).
0073 
0074 % ----- Corpus label
0075 corpus_key   = 'Corpus';
0076 corpus_label = NaN;
0077 
0078 %
0079 % ---- Load MNI-mm-coordinate for subject brain (should be calculated before)
0080 %
0081 load(brainfile, 'Vmni','derr');
0082 XYZmm = Vmni*1000;   % mm
0083 dd    = derr*1000;   % mm
0084 Npoint   = size(XYZmm,1);
0085 Vlabel     = zeros(Npoint,1);
0086 dd_label = zeros(Npoint,1);
0087 %
0088 % ----- Remove corpus
0089 %
0090 fprintf('---  Remove corpus region\n');
0091 [Vindx, Iremove] = vb_remove_corpus_run(brainfile);
0092 Vlabel(Iremove)  = corpus_label;
0093 
0094 fprintf('# of Corpus points = %d\n',length(Iremove))
0095 
0096 % Read image-header
0097 [dim, Trans, XYZmm0] = vb_get_image_info(atlas_file);
0098 
0099 % Read atlas-template image
0100 % Z    - 3D image data
0101 %Zlabel = read_image(atlas_file);
0102 
0103 avw = avw_img_read(atlas_file);
0104 Zlabel = avw.img;
0105 
0106 % Zlabel     - 3D image data (label value)
0107 % XYZmm0 - 3 x n matrix of XYZ locations
0108 %          mm-coordinates in atlas-template (origin : AC-PC center)
0109 Zlabel = Zlabel(:);
0110 
0111 % Extract labeled region
0112 mni_id = find(Zlabel ~= 0); 
0113 Zlabel = Zlabel(mni_id);
0114 % MNI-mm-coordinates in atlas-template for labeled region
0115 XYZmm0 = XYZmm0(:,mni_id)';
0116 
0117 fprintf('# of template points = %d\n',length(mni_id))
0118 
0119 fprintf('--- Mapping Atlas-label onto 2D cortical surface \n');
0120 
0121 % Find nearest labeled point in atlas
0122 [indx, dd_tmp] = vb_find_nearest_point(XYZmm0, XYZmm(Vindx,:), Rmax, 100, 0, 1);
0123 
0124 fprintf('# of matched brain points    = %d\n',length(indx))
0125 
0126 % Find points whose minimum distance to atlas brain region is less than Rlimit
0127 ix_match = find( dd(Vindx) <= Rlimit & dd_tmp < Rmax & indx > 0 );
0128 %ix_match = find( dd(Vindx) <= Rlimit & dd_tmp < Rmax );
0129 %ix_match = find( dd(Vindx) <= Rlimit );
0130 
0131 fprintf('# of close points            = %d\n',length(ix_match))
0132 
0133 dd_label(Vindx) = dd_tmp;
0134 Vlabel(Vindx(ix_match)) = Zlabel(indx(ix_match));
0135 
0136 % Fill label for large distant point
0137 ixz    = find( dd_label >= Rmax );
0138 fprintf('# of unlabeld point = %d\n', length(ixz))
0139 
0140 %fprintf('Filling unlabeled points\n')
0141 %Vlabel = vb_fill_atlas_label(brainfile, Vlabel, ixz, Rlimit);
0142 
0143 %
0144 % ---- Save labeled area
0145 %
0146 Nlabel = sum( Vlabel ~= 0 );    % # of labeled points
0147 fprintf('# of all vertex     = %d\n',Npoint)
0148 fprintf('# of cortex  points = %d\n',length(Vindx))
0149 fprintf('# of labeled points = %d\n',Nlabel)
0150 
0151 % Read atlas text file and extract area keys.
0152 [label, label_name] = vb_read_atlas_label(atlas_text);
0153 
0154 % Add Corpus label
0155 Narea = length(label);
0156 label(Narea+1) = corpus_label;
0157 label_name{Narea+1} = corpus_key;
0158 
0159 % Intensity of 'Act.xxP' is the label for each vertex
0160 Atlas.key = [atlas_id];
0161 Atlas.xxP = Vlabel;
0162 Atlas.label      = label;
0163 Atlas.label_name = label_name;
0164 Atlas.dd_label   = dd_label;
0165 
0166 % Save label as actfile
0167 fprintf('Save the atlas file as "%s"  \n', save_atlasfile);
0168 vb_add_act(save_atlasfile,Atlas,[],false);
0169 
0170 % Save area label into area file
0171 fprintf('Save the area file as "%s" \n', save_areafile);
0172 
0173 vb_save_atlas_label(save_areafile,Vlabel,label,label_name);
0174 
0175 clear Zlabel Vlabel XYZmm0 XYZmm Zlabel

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