Home > functions > tool_box > atlas2vb_dir > vb_find_atlas_label_number.m

vb_find_atlas_label_number

PURPOSE ^

SYNOPSIS ^

function [Nvert,Npart,name] = vb_find_atlas_label_number(atlasfile,brainfile)

DESCRIPTION ^

 
   [Mvert,Npart,name] = vb_find_atlas_label_number(atlasfile,brainfile)
 --- Input
 atlasfile,
 brainfile
 --- Output
 Mvert{n} : # of vertex in n-th label
 Npart(n) : # of connected area in n-th label
 name{n}  : area name of n-th label
 
 2009-10-12 M. Sato

 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    [Nvert,Npart,name] = vb_find_atlas_label_number(atlasfile,brainfile)
0002 %
0003 %   [Mvert,Npart,name] = vb_find_atlas_label_number(atlasfile,brainfile)
0004 % --- Input
0005 % atlasfile,
0006 % brainfile
0007 % --- Output
0008 % Mvert{n} : # of vertex in n-th label
0009 % Npart(n) : # of connected area in n-th label
0010 % name{n}  : area name of n-th label
0011 %
0012 % 2009-10-12 M. Sato
0013 %
0014 % Copyright (C) 2011, ATR All Rights Reserved.
0015 % License : New BSD License(see VBMEG_LICENSE.txt)
0016 
0017 % load brain
0018 [V, F] = vb_load_cortex(brainfile);
0019 
0020 F     = F.F3;        % patch index
0021 NV   = size(V,1);    % # of vertex
0022 
0023 load(atlasfile)
0024 Act = Act{1};
0025 
0026 name  = Act.label_name;
0027 label = Act.label      ; % label value;
0028 Narea = length(label);
0029 
0030 % label value for each vertex [Nvertex x 1]
0031 xxP   = Act.xxP; 
0032 
0033 Npart = zeros(Narea+1,1);
0034 Nvert = cell(Narea+1,1);
0035 Nvert{Narea+1} = sum( xxP == 0 );
0036 name{Narea+1}  = 'Non_area';
0037 Npart(Narea+1) = 1;
0038 
0039 for n=1:Narea
0040     % vertex index for n-th label
0041     ix = find( xxP == label(n) );
0042     
0043     if isempty(ix), continue; end;
0044     
0045     % find connected region
0046     [Vindx, Nall] = vb_connected_vertex(ix,F);
0047     
0048     % set label to largest connected region
0049     if ~isempty(Vindx)
0050         Npart(n) = length(Nall);
0051         Nvert{n} = Nall;
0052     end
0053     
0054 end
0055 
0056 return
0057 
0058 Nmax = max(Npart);
0059 Mvert = zeros(Narea+1,Nmax);
0060 
0061 for n=1:Narea+1
0062     if Npart(n) > 0
0063         Mvert(n,1:Npart(n)) = Nvert{n};
0064     end
0065 end

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