Home > vbmeg > functions > device > eeg > vb_eegfile_add_position.m

vb_eegfile_add_position

PURPOSE ^

overwrite position data from POS-MAT file for EEG-MAT file

SYNOPSIS ^

function errcode =vb_eegfile_add_position(eegfile_old, posfile, eegfile_new)

DESCRIPTION ^

 overwrite position data from POS-MAT file for EEG-MAT file
 [usage]
   errcode = eegfile_overwrite_position(eegfile_old, posfile, eegfile_new)
 [input]
   eegfile_old : <required> <<file>> EEG-MAT file which will be updated
       posfile : <optional> <<file>> POS-MAT file ['']
               :  if this is not specified or empty, do nothing
   eegfile_new : <optional> <<string>> new EEG-MAT file if it is necessary
               :  [eegfile_old]
               :  if this is not specified, eegfile_old will be overwrite
 [output]
       errcode : error code
               :  1 ) success
               :  0 ) do nothing
               :  -1) invalid eegfile_old
 [note]
   overwritten fields are as follows:
       .Vcenter
       .Vradius
       .Coord
       .CoordType
       .device_info.TransInfo

 [history]
   2008-03-19 (Sako) initial version
   2011-05-27 (Sako) modified, according to the new data format

 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 errcode = ...
0002   vb_eegfile_add_position(eegfile_old, posfile, eegfile_new)
0003 % overwrite position data from POS-MAT file for EEG-MAT file
0004 % [usage]
0005 %   errcode = eegfile_overwrite_position(eegfile_old, posfile, eegfile_new)
0006 % [input]
0007 %   eegfile_old : <required> <<file>> EEG-MAT file which will be updated
0008 %       posfile : <optional> <<file>> POS-MAT file ['']
0009 %               :  if this is not specified or empty, do nothing
0010 %   eegfile_new : <optional> <<string>> new EEG-MAT file if it is necessary
0011 %               :  [eegfile_old]
0012 %               :  if this is not specified, eegfile_old will be overwrite
0013 % [output]
0014 %       errcode : error code
0015 %               :  1 ) success
0016 %               :  0 ) do nothing
0017 %               :  -1) invalid eegfile_old
0018 % [note]
0019 %   overwritten fields are as follows:
0020 %       .Vcenter
0021 %       .Vradius
0022 %       .Coord
0023 %       .CoordType
0024 %       .device_info.TransInfo
0025 %
0026 % [history]
0027 %   2008-03-19 (Sako) initial version
0028 %   2011-05-27 (Sako) modified, according to the new data format
0029 %
0030 % Copyright (C) 2011, ATR All Rights Reserved.
0031 % License : New BSD License(see VBMEG_LICENSE.txt)
0032 
0033 % --- CHECK ARGUMENTS --- %
0034 if ~exist('eegfile_old', 'var'), eegfile_old = ''; end
0035 if ~exist('posfile', 'var'), posfile = ''; end
0036 if ~exist('eegfile_new', 'var'), eegfile_new = ''; end
0037 [errcode, eegfile_old, posfile, eegfile_new] = ...
0038   inner_check_arguments(eegfile_old, posfile, eegfile_new);
0039 
0040 % --- MAIN PROCEDURE --------------------------------------------------------- %
0041 %
0042 if errcode ~= 1
0043   % do nothing
0044   return;
0045 end
0046 
0047 EEGinfo = vb_eegfile_load_eeginfo(eegfile_old);
0048 pos = load(posfile);
0049 
0050 % ----- overwritten fields of EEGinfo
0051 %       .Vcenter
0052 %       .Vradius
0053 %       .Coord
0054 %       .CoordType
0055 %       .device_info.TransInfo
0056 % -----
0057 EEGinfo = vb_eeginfo_set_sensor_position(EEGinfo, pos.pos);
0058 EEGinfo.Vcenter = pos.spherical_info.Vcenter;
0059 EEGinfo.Vradius = pos.spherical_info.Vradius;
0060 EEGinfo.CoordType = pos.coord_type;
0061 EEGinfo = vb_info_set_transinfo(pos.trans_info);
0062 
0063 if ~isequal(eegfile_old, eegfile_new)
0064   copyfile(eegfile_old, eegfile_new);
0065 end
0066 vb_save(eegfile_new, 'EEGinfo');
0067 return;
0068 %
0069 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0070 
0071 % --- INNER FUNCTIONS -------------------------------------------------------- %
0072 %
0073 % --- inner_check_arguments()
0074 %
0075 function [errcode, eegfile_old, posfile, eegfile_new] = ...
0076   inner_check_arguments(eegfile_old, posfile, eegfile_new)
0077 func_ = mfilename;
0078 errcode = 1; % success
0079 
0080 if isempty(eegfile_old)
0081   fprintf('(%s)eegfile_old is a required parameter\n', func_);
0082   errcode = -1;
0083   return;
0084 else
0085   if exist(eegfile_old, 'file') ~= 2
0086     fprintf('(%s)cannot find eegfile: %s\n', func_, eegfile_old);
0087     errcode = -1;
0088   end
0089 end
0090 
0091 if isempty(posfile)
0092   fprintf('(%s)As posfile is not specified, do nothing\n', func_);
0093   errcode = 0;
0094   return;
0095 end
0096 
0097 if isempty(eegfile_new)
0098   eegfile_new = eegfile_old;
0099 end
0100 return;
0101 %
0102 % --- end of inner_check_arguments()
0103 %
0104 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0105 
0106 % --- END OF FILE --- %

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