Home > vbmeg > functions > device > meg > vb_megfile_patch_posfile.m

vb_megfile_patch_posfile

PURPOSE ^

update coordinates which have not been transformed

SYNOPSIS ^

function vb_megfile_patch_posfile(megfile, posfile, outfile)

DESCRIPTION ^

 update coordinates which have not been transformed
 [usage]
   vb_megfile_patch_posfile(megfile, posfile, outfile)
 [input]
   megfile : <required> MEG-MAT file
           :   the coordinates of which are not tranformed
   posfile : <required> POS-MAT file
   outfile : <optional> output file ['megfile']
 [output]
   none
 [note]

 [see also]
   vb_load_sensor

 [history]
   2009-04-16 (Sako) initial version
   2011-08-31 (Sako) modified how to call vb_load_sensor

 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_megfile_patch_posfile(megfile, posfile, outfile)
0002 % update coordinates which have not been transformed
0003 % [usage]
0004 %   vb_megfile_patch_posfile(megfile, posfile, outfile)
0005 % [input]
0006 %   megfile : <required> MEG-MAT file
0007 %           :   the coordinates of which are not tranformed
0008 %   posfile : <required> POS-MAT file
0009 %   outfile : <optional> output file ['megfile']
0010 % [output]
0011 %   none
0012 % [note]
0013 %
0014 % [see also]
0015 %   vb_load_sensor
0016 %
0017 % [history]
0018 %   2009-04-16 (Sako) initial version
0019 %   2011-08-31 (Sako) modified how to call vb_load_sensor
0020 %
0021 % Copyright (C) 2011, ATR All Rights Reserved.
0022 % License : New BSD License(see VBMEG_LICENSE.txt)
0023 
0024 if ~exist('megfile', 'var'), megfile = ''; end
0025 if ~exist('posfile', 'var'), posfile = ''; end
0026 if ~exist('outfile', 'var'), outfile = ''; end
0027 [megfile, posfile, outfile] = inner_check_arguments(megfile, posfile, outfile);
0028 
0029 % --- MAIN PROCEDURE --------------------------------------------------------- %
0030 %
0031 func_ = mfilename;
0032 
0033 meginfo = vb_megfile_load_meginfo(megfile);
0034 if isempty(meginfo)
0035   error('(%s) meginfo is empty', func_);
0036 end
0037 
0038 meg = load(megfile);
0039 transinfo = vb_info_get_transinfo(meginfo);
0040 
0041 if isempty(transinfo)
0042   [old_pick, old_Qpick] = vb_load_sensor(megfile, 'MEG', '', false);
0043 
0044   [pick, Qpick] = vb_meg_transform_coordinate(old_pick, old_Qpick, '', posfile);
0045   [MEGinfo] = vb_info_add_posfile_info(meginfo, posfile);
0046 
0047   meg.pick = pick;
0048   meg.Qpick = Qpick;
0049   meg.MEGinfo = MEGinfo;
0050 else
0051   fprintf('(%s) do nothing because there is MEGinfo.TransInfo\n', func_);
0052   return;
0053 end
0054 
0055 if isempty(outfile)
0056   outfile = megfile;
0057 end
0058 
0059 save_cmd = sprintf('save %s -struct meg', outfile);
0060 eval(save_cmd);
0061 return;
0062 %
0063 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0064 
0065 % --- INNER FUNCTIONS -------------------------------------------------------- %
0066 %
0067 % --- inner_check_arguments()
0068 %
0069 function [megfile, posfile, outfile] = ...
0070   inner_check_arguments(megfile, posfile, outfile)
0071 func_ = mfilename;
0072 if ~inner_is_valid_input_file(megfile)
0073   error('(%s) megfile is invalid', func_);
0074 end
0075 if ~inner_is_valid_input_file(posfile)
0076   error('(%s) megfile is invalid', func_);
0077 end
0078 
0079 if isempty(outfile)
0080   % nothing to do
0081 end
0082 return;
0083 %
0084 % --- end of inner_check_arguments()
0085 
0086 % --- inner_is_valid_input_file()
0087 %
0088 function result = inner_is_valid_input_file(cur_file)
0089 % result : <<boolean>>
0090 if isempty(cur_file)
0091   result = false;
0092   return;
0093 end
0094 
0095 if exist(cur_file, 'file') ~= 2
0096   result = false;
0097   return;
0098 end
0099 
0100 result = true;
0101 return;
0102 %
0103 % --- end of inner_is_valid_input_file()
0104 %
0105 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0106 
0107 % --- END OF FILE --- %

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