Home > vbmeg > functions > leadfield > head > vb_util_make_joined_head_file.m

vb_util_make_joined_head_file

PURPOSE ^

joins multiple head-files and makes single head-file which is joined given

SYNOPSIS ^

function [new_head_file, idx, r_list] = vb_util_make_joined_head_file(proj_root, headfile_cell, layer_tag, calc_mode, radius)

DESCRIPTION ^

 joins multiple head-files and makes single head-file which is joined given
 head-files. The new head-file will be named from names of multiple head-files
 with new extention '.omega.mat' <after vb_solid_angle_grk>.
 [usage]
   [new_head_file, idx, r_list] = vb_util_make_joined_head_file( ...
     proj_root, headfile_cell, sigma, layer_tag, calc_mode, radius)
 [input]
       proj_root : <required> directory in which 'new_head_file' will be made
   headfile_cell : <required> cell array of headfiles.
                 : if it is not cell, return 'headfile_cell' as 'new_head_file'
                 : with proj_root
       layer_tag : <required> names of each layer
       calc_mode : <optional> calculation method of radius
                 :  for the function vb_util_join_head_files
                 :  1 or 2 or 3 or 4
                 :  [](default depends on vb_util_join_head_files)
                 :  = 1) mean distance of each head
                 :  = 2) minimum distance of each head
                 :  = 3) maximum distance of each head
                 :  = 4) user-specified radius (radii)
          radius : <conditionally optional> user-specified radius
                 :  if calc_mode is 4, this parameter is <required>.
                 :  []
 [output]
   new_head_file : joined head-file
                 :  stored data are as follows:
                 :        XXhead : [Npoint x 3]
                 :         Vhead : [NPoint x 3]
                 :         Fhead : [NPatch x 3] 
                 :       Nvertex : [NL x 2]  : start and end index
                 :        Npatch : [NL x 2]  : start and end index
                 :     layer_tag : {NL} label of each layer
             idx : index list which is sorted by radius of each layer
          r_list : radius list which is sorted by their sizes
 [note]
   @see  vb_util_get_file_body
   @see  util_join_haed_files
 [history]
   2006-12-11 (Sako) initial version
   2007-04-06 (Sako) modified along with the change of vb_util_join_head_files
   2007-06-14 (Sako) removed some parameter from multi-layer head-mat file
   2007-11-29 (Sako) added new argument : radius for calc_mode 4

 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 [new_head_file, idx, r_list] = vb_util_make_joined_head_file( ...
0002   proj_root, headfile_cell, layer_tag, calc_mode, radius)
0003 % joins multiple head-files and makes single head-file which is joined given
0004 % head-files. The new head-file will be named from names of multiple head-files
0005 % with new extention '.omega.mat' <after vb_solid_angle_grk>.
0006 % [usage]
0007 %   [new_head_file, idx, r_list] = vb_util_make_joined_head_file( ...
0008 %     proj_root, headfile_cell, sigma, layer_tag, calc_mode, radius)
0009 % [input]
0010 %       proj_root : <required> directory in which 'new_head_file' will be made
0011 %   headfile_cell : <required> cell array of headfiles.
0012 %                 : if it is not cell, return 'headfile_cell' as 'new_head_file'
0013 %                 : with proj_root
0014 %       layer_tag : <required> names of each layer
0015 %       calc_mode : <optional> calculation method of radius
0016 %                 :  for the function vb_util_join_head_files
0017 %                 :  1 or 2 or 3 or 4
0018 %                 :  [](default depends on vb_util_join_head_files)
0019 %                 :  = 1) mean distance of each head
0020 %                 :  = 2) minimum distance of each head
0021 %                 :  = 3) maximum distance of each head
0022 %                 :  = 4) user-specified radius (radii)
0023 %          radius : <conditionally optional> user-specified radius
0024 %                 :  if calc_mode is 4, this parameter is <required>.
0025 %                 :  []
0026 % [output]
0027 %   new_head_file : joined head-file
0028 %                 :  stored data are as follows:
0029 %                 :        XXhead : [Npoint x 3]
0030 %                 :         Vhead : [NPoint x 3]
0031 %                 :         Fhead : [NPatch x 3]
0032 %                 :       Nvertex : [NL x 2]  : start and end index
0033 %                 :        Npatch : [NL x 2]  : start and end index
0034 %                 :     layer_tag : {NL} label of each layer
0035 %             idx : index list which is sorted by radius of each layer
0036 %          r_list : radius list which is sorted by their sizes
0037 % [note]
0038 %   @see  vb_util_get_file_body
0039 %   @see  util_join_haed_files
0040 % [history]
0041 %   2006-12-11 (Sako) initial version
0042 %   2007-04-06 (Sako) modified along with the change of vb_util_join_head_files
0043 %   2007-06-14 (Sako) removed some parameter from multi-layer head-mat file
0044 %   2007-11-29 (Sako) added new argument : radius for calc_mode 4
0045 %
0046 % Copyright (C) 2011, ATR All Rights Reserved.
0047 % License : New BSD License(see VBMEG_LICENSE.txt)
0048 try
0049   % --- CHECK ARGUMENTS --- %
0050   if ~exist('proj_root', 'var'), proj_root = []; end
0051   if ~exist('headfile_cell', 'var'), headfile_cell = []; end
0052   if ~exist('layer_tag', 'var'), layer_tag = []; end
0053   if ~exist('calc_mode', 'var'), calc_mode = []; end
0054   if ~exist('radius', 'var'), radius = []; end
0055   [ proj_root, headfile_cell, layer_tag, calc_mode, radius] = ...
0056     inner_check_arguments(proj_root, ...
0057       headfile_cell, layer_tag, calc_mode, radius);
0058 
0059 
0060   % --- MAIN PROCEDURE ------------------------------------------------------- %
0061   %
0062   % constants
0063   OMEGA_EXT = '.omega.mat';
0064   HEAD_EXT = '.head.mat';
0065   
0066   % single file - require no action to join files
0067   if ~iscell(headfile_cell)
0068     if ~isempty(strfind(headfile_cell, OMEGA_EXT))
0069       % do nothing
0070       idx = [];
0071       r_list = [];
0072       new_head_file = [proj_root filesep headfile_cell];
0073     else  
0074       new_head_file = ...
0075         [proj_root filesep vb_util_get_file_body(headfile_cell) HEAD_EXT];
0076     end
0077   
0078     % get r_list idx as return parameters
0079     if calc_mode == 4
0080       [r_list] = radius;
0081     else
0082       [r_list] = vb_util_calc_head_radius(proj_root, headfile_cell, calc_mode);
0083     end
0084     idx = 1:size(r_list,2);
0085     return;
0086   end
0087   
0088   new_head_file_body = [];
0089   % make new name of new headfile
0090   for nf = 1:length(headfile_cell)
0091     fname_body = vb_util_get_file_body(headfile_cell{nf});
0092     if nf == 1
0093       new_head_file_body = fname_body;
0094     else  
0095       new_head_file_body = [new_head_file_body '_' fname_body];
0096     end
0097   end
0098   
0099   new_head_file = [proj_root filesep new_head_file_body HEAD_EXT];
0100   
0101 %   vb_util_join_head_files( ...
0102 %     headfile_cell, proj_root, new_head_file, sigma, layer_tag );
0103   [idx, r_list] = vb_util_join_head_files(headfile_cell, proj_root, ...
0104     new_head_file, layer_tag, calc_mode, radius);
0105   return;
0106   
0107 catch
0108   rethrow(lasterror);
0109 end
0110 %
0111 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0112 
0113 % --- INNER FUNCTIONS -------------------------------------------------------- %
0114 %
0115 function [proj_root, headfile_cell, layer_tag, calc_mode, radius] = ...
0116   inner_check_arguments(proj_root, headfile_cell, layer_tag, calc_mode, radius)
0117 
0118 func_ = mfilename;
0119 
0120 if isempty(proj_root)
0121   error('(%s)proj_root is a required parameter', func_);
0122 end
0123 
0124 if isempty(headfile_cell)
0125   error('(%s)headfile_cell is a required parameter', func_);
0126 end
0127 
0128 if isempty(layer_tag)
0129   error('(%s)layer_tag is a required parameter', func_);
0130 end
0131 
0132 if isempty(calc_mode)
0133   % required no action
0134 end
0135 
0136 if isempty(radius)
0137   if calc_mode == 4
0138     error('(%s)if calc_mode is 4, radius is required parameter', func_);
0139   end
0140 end
0141 %
0142 % --- end of inner_check_arguments()
0143 %
0144 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0145 
0146 %%% END OF FILE %%%

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