Home > vbmeg > functions > common > loadfunc > subdirectory > vb_load_head_shell.m

vb_load_head_shell

PURPOSE ^

load head shell model from VBMEG head model file(.head.mat)

SYNOPSIS ^

function shells = vb_load_head_shell(head_file, tags)

DESCRIPTION ^

 load head shell model from VBMEG head model file(.head.mat)
 [Usage]
     shells = vb_load_head_shell(head_file[,tags]);
 [Input]
     head_model : VBMEG head model file(.head.mat)
           tags : [optional] shell name to load.  [string or cellstr]
                  case-insensitive. if not specified(or empty) all the shell
                  data will be loaded.
                  (e.g. 'CSF', {'CSF', 'Skull', 'Scalp'})
 [Output]
  shells{n}      : Data get by specified tags.     [Nx1]
                   shells(n) is loaded by tags{n}. 
         .Vhead  : Vertices.
         .Fhead  : Patches.
         .XXhead : Normal vector.
         .Tag    : Shell name.

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function shells = vb_load_head_shell(head_file, tags)
0002 % load head shell model from VBMEG head model file(.head.mat)
0003 % [Usage]
0004 %     shells = vb_load_head_shell(head_file[,tags]);
0005 % [Input]
0006 %     head_model : VBMEG head model file(.head.mat)
0007 %           tags : [optional] shell name to load.  [string or cellstr]
0008 %                  case-insensitive. if not specified(or empty) all the shell
0009 %                  data will be loaded.
0010 %                  (e.g. 'CSF', {'CSF', 'Skull', 'Scalp'})
0011 % [Output]
0012 %  shells{n}      : Data get by specified tags.     [Nx1]
0013 %                   shells(n) is loaded by tags{n}.
0014 %         .Vhead  : Vertices.
0015 %         .Fhead  : Patches.
0016 %         .XXhead : Normal vector.
0017 %         .Tag    : Shell name.
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 %
0023 % --- Previous check
0024 %
0025 if ~exist('head_file', 'var')
0026     error('head_file is a required.');
0027 end
0028 if exist(head_file, 'file') ~= 2
0029     error('Specified file not found.');
0030 end
0031 if ~exist('tags', 'var')
0032     tags = [];
0033 end
0034 
0035 if ischar(tags)
0036     tags = {tags};
0037 end
0038 if isempty(tags)
0039     % tags = []; % means all the tags.
0040     tmp = vb_load_head_shell_info(head_file);
0041     tags = tmp.tags;
0042 end
0043 
0044 if ~iscellstr(tags)
0045     error('Specified Invalid tag');
0046 end
0047 
0048 %
0049 % --- Previous check
0050 %
0051 Nshell = vb_head_get_layer_num(head_file);
0052 Ntags  = length(tags);
0053 
0054 shells  = [];
0055 for k=1:Ntags
0056     shells = [shells; inner_shell_template]; % allocate 1 struct
0057 
0058     % retrieve data from head_file
0059     info  = vb_head_get_specified_headinfo(head_file, tags{k});
0060     if isempty(info)
0061         error('Specified invalid tag  : %s', tags{k});
0062     end
0063     % There is a case that the 1shell model doesn't have LayerTag.
0064     if Nshell == 1 && ~isfield(info, 'LayerTag')
0065         info.LayerTag = 'CSF';
0066     end
0067     % Set fields
0068     shells(k).Vhead  = info.Vhead;
0069     shells(k).Fhead  = info.Fhead;
0070     shells(k).XXhead = info.XXhead;
0071     shells(k).Tag    = info.LayerTag;
0072 end
0073 
0074 function template = inner_shell_template
0075 template = struct;
0076 template.Vhead  = [];
0077 template.Fhead  = [];
0078 template.XXhead = [];
0079 template.Tag    = [];

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005