Home > functions > tool_box > atlas2vb_dir > vb_read_atlas_label.m

vb_read_atlas_label

PURPOSE ^

Read atlas text file and extract area keys.

SYNOPSIS ^

function [label, key] = vb_read_atlas_label(atlas_text)

DESCRIPTION ^

 Read atlas text file and extract area keys.
   [label, key] = vb_read_atlas_label(atlas_text)
 --- Input
 atlas_text : atlas text file name
 --- Output
 label(n) : label value for n-th area
 key{n}   : label name for n-th area

% 2006/11/14 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    [label, key] = vb_read_atlas_label(atlas_text)
0002 % Read atlas text file and extract area keys.
0003 %   [label, key] = vb_read_atlas_label(atlas_text)
0004 % --- Input
0005 % atlas_text : atlas text file name
0006 % --- Output
0007 % label(n) : label value for n-th area
0008 % key{n}   : label name for n-th area
0009 %
0010 %% 2006/11/14 M.Sato
0011 %
0012 % Copyright (C) 2011, ATR All Rights Reserved.
0013 % License : New BSD License(see VBMEG_LICENSE.txt)
0014 
0015 fid = fopen(atlas_text);
0016 
0017 if fid == -1, error(sprintf('[%s] can not be opened',atlas_text)); end
0018 
0019 Nlabel = 0;
0020 
0021 % Get label name and value
0022 
0023 while 1
0024     str = fgets(fid);
0025     if str == -1  %% if end of the file, go out from loop
0026         break
0027     end
0028  
0029     split  = explode(str,9); % 9 is ascii code of TAB
0030     Nsplit = length(split);
0031     
0032     if Nsplit > 1
0033         Nlabel = Nlabel + 1;
0034         label(Nlabel) = str2num(split{1}); % area label
0035         key{Nlabel}   = deblank(split{2}); % area key
0036         fprintf('Label : %d, Key : %s\n', label(Nlabel),key{Nlabel});
0037     end
0038 end
0039 
0040 fclose(fid);

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