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

vb_headinfo_save

PURPOSE ^

save <Headinfo> to <head_file>

SYNOPSIS ^

function vb_headinfo_save(Headinfo, head_file)

DESCRIPTION ^

 save <Headinfo> to <head_file>
 [usage]
   vb_headinfo_save(Headinfo, head_file)
 [input]
   Headinfo : <required> <<struct>>
   head_file : <required> file name that you want to save
 [output]
   none
 [note]
   Not all fields of Headinfo are stored to head-mat file
   @see vb_out_normal.m
 [history]
   2007-04-06 (Sako) initial version
   2007-06-14 (Sako) remove some fields from head-mat file
   2010-10-25 (Sako) if XXhead is empty, calculate it before making file

 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 vb_headinfo_save(Headinfo, head_file)
0002 % save <Headinfo> to <head_file>
0003 % [usage]
0004 %   vb_headinfo_save(Headinfo, head_file)
0005 % [input]
0006 %   Headinfo : <required> <<struct>>
0007 %   head_file : <required> file name that you want to save
0008 % [output]
0009 %   none
0010 % [note]
0011 %   Not all fields of Headinfo are stored to head-mat file
0012 %   @see vb_out_normal.m
0013 % [history]
0014 %   2007-04-06 (Sako) initial version
0015 %   2007-06-14 (Sako) remove some fields from head-mat file
0016 %   2010-10-25 (Sako) if XXhead is empty, calculate it before making file
0017 %
0018 % Copyright (C) 2011, ATR All Rights Reserved.
0019 % License : New BSD License(see VBMEG_LICENSE.txt)
0020 
0021 % --- CHECK ARGUMENTS --- %
0022 if ~exist('Headinfo', 'var'), Headinfo = []; end;
0023 if ~exist('head_file', 'var'), head_file = []; end;
0024 [Headinfo, head_file] = inner_check_arguments(Headinfo, head_file);
0025 
0026 % --- MAIN PROCEDURE --------------------------------------------------------- %
0027 %
0028 % existing each fields are guaranteed in inner_check_arguments()
0029 Vhead    = Headinfo.Vhead;
0030 Fhead    = Headinfo.Fhead;
0031 XXhead   = Headinfo.XXhead;
0032 Sigma    = Headinfo.Sigma;
0033 LayerTag = Headinfo.LayerTag;
0034 Rmethod  = Headinfo.Rmethod;
0035 R        = Headinfo.R;
0036 Npatch   = Headinfo.Npatch;
0037 Nvertex  = Headinfo.Nvertex;
0038 
0039 % support empty XXhead
0040 if isempty(XXhead)
0041   if ~isempty(Vhead) && ~isempty(Fhead)
0042     if ~isempty(Nvertex) && ~isempty(Npatch)
0043       n_layer = size(Nvertex,1);
0044 
0045       prev_point = 0;
0046       for i_layer = 1:n_layer
0047         % if plural layer model, calculate each layer
0048         f_begin = Npatch(i_layer,1);
0049         f_end   = Npatch(i_layer,2);
0050         v_begin = Nvertex(i_layer,1);
0051         v_end   = Nvertex(i_layer,2);
0052         
0053         cur_v = Vhead(v_begin:v_end,:);
0054         cur_f = Fhead(f_begin:f_end,:) - prev_point;
0055         [new_f, new_v, cur_XX] = vb_out_normal(cur_f, cur_v);
0056         XXhead = [XXhead; cur_XX];
0057         prev_point = prev_point + size(cur_v,1);
0058       end
0059     else
0060       [new_f, new_v, XXhead] = vb_out_normal(Fhead, Vhead);
0061     end
0062   else
0063     if isempty(Vhead), warning('Vhead is empty'); end
0064     if isempty(Fhead), warning('Fhead is empty'); end
0065     warning('XXhead is empty');
0066   end
0067 end
0068 
0069 % --- 20070615 removed Sigma, Rmethod, R
0070 %
0071 % vb_save(head_file, 'Vhead', 'Fhead', 'XXhead', 'Sigma', 'LayerTag', ...
0072 %   'Rmethod', 'R', 'Npatch', 'Nvertex' );
0073 vb_save(head_file, 'Vhead','Fhead','XXhead','Npatch','Nvertex','LayerTag');
0074 %
0075 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0076 
0077 % --- INNER FUNCTIONS -------------------------------------------------------- %
0078 %
0079 % --- inner_check_arguments()
0080 %
0081 function [Headinfo, head_file] = inner_check_arguments(Headinfo, head_file)
0082 if isempty(Headinfo)
0083   error('Headinfo is a required parameter');
0084 end
0085 
0086 if isempty(head_file)
0087   error('head_file is a required parameter');
0088 end
0089 
0090 if ~isfield(Headinfo, 'Vhead')    Headinfo.Vhead = []; end;
0091 if ~isfield(Headinfo, 'Fhead')    Headinfo.Fhead = []; end;
0092 if ~isfield(Headinfo, 'XXhead')   Headinfo.XXhead = []; end;
0093 if ~isfield(Headinfo, 'Sigma')    Headinfo.Sigma = []; end;
0094 if ~isfield(Headinfo, 'LayerTag') Headinfo.LayerTag = []; end;
0095 if ~isfield(Headinfo, 'Rmethod')  Headinfo.Rmethod = []; end;
0096 if ~isfield(Headinfo, 'R')        Headinfo.R = []; end;
0097 if ~isfield(Headinfo, 'Npatch')   Headinfo.Npatch = []; end;
0098 if ~isfield(Headinfo, 'Nvertex')  Headinfo.Nvertex = []; end;
0099 %
0100 % --- end of inner_check_arguments()
0101 
0102 %%% END OF FILE %%%

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