set spherical data (Vcenter, Vradius) to a .meg.mat file or .eeg.mat file [usage] vb_msrmnt_set_spherical_data( msrmnt_file, sph_data ) [input] msrmnt_file : <required> <<file>> target file (.meg.mat or .eeg.mat) sph_data : <required> <<struct>> data of spherical model following fields are required. .Vcenter : (x,y,z) center coordinate of the spherical model .Vradius : [m] radius of the spherical model [output] none [note] updated fields are .Vcenter and .Vradius of MEGinfo or EEGinfo [history] 2011-05-30 (Sako) initial version Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function vb_msrmnt_set_spherical_data( msrmnt_file, sph_data ) 0002 % set spherical data (Vcenter, Vradius) to a .meg.mat file or .eeg.mat file 0003 % [usage] 0004 % vb_msrmnt_set_spherical_data( msrmnt_file, sph_data ) 0005 % [input] 0006 % msrmnt_file : <required> <<file>> target file (.meg.mat or .eeg.mat) 0007 % sph_data : <required> <<struct>> data of spherical model 0008 % following fields are required. 0009 % .Vcenter : (x,y,z) center coordinate of the spherical model 0010 % .Vradius : [m] radius of the spherical model 0011 % [output] 0012 % none 0013 % [note] 0014 % updated fields are .Vcenter and .Vradius of MEGinfo or EEGinfo 0015 % [history] 0016 % 2011-05-30 (Sako) initial version 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('msrmnt_file', 'var'), msrmnt_file = ''; end 0023 if ~exist('sph_data', 'var'), sph_data = []; end 0024 [msrmnt_file, sph_data] = inner_check_arguments(msrmnt_file, sph_data); 0025 0026 % --- MAIN PROCEDURE --------------------------------------------------------- % 0027 % 0028 [measurement] = vb_load_device(msrmnt_file); 0029 Measurement = upper(measurement); 0030 0031 msrmnt = load(msrmnt_file); 0032 0033 switch Measurement 0034 case 'MEG' 0035 if isfield(sph_data, 'Vcenter') 0036 msrmnt.MEGinfo.Vcenter = sph_data.Vcenter; 0037 end 0038 0039 if isfield(sph_data, 'Vradius') 0040 msrmnt.MEGinfo.Vradius = sph_data.Vradius; 0041 end 0042 0043 case 'EEG' 0044 if isfield(sph_data, 'Vcenter') 0045 msrmnt.EEGinfo.Vcenter = sph_data.Vcenter; 0046 end 0047 0048 if isfield(sph_data, 'Vradius') 0049 msrmnt.EEGinfo.Vradius = sph_data.Vradius; 0050 end 0051 0052 otherwise 0053 warning('%s is unknown measurement\n', Measurement); 0054 return; 0055 end 0056 0057 vb_save_struct(msrmnt_file, msrmnt); 0058 return; 0059 % 0060 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0061 0062 % --- INNER FUNCTIONS -------------------------------------------------------- % 0063 % 0064 % --- inner_check_arguments() 0065 % 0066 function [msrmnt_file, sph_data] = inner_check_arguments(msrmnt_file, sph_data) 0067 func_ = mfilename; 0068 0069 if isempty(msrmnt_file) 0070 error('(%s) msrmnt_file is a required parameter', func_); 0071 end 0072 if exist(msrmnt_file, 'file') ~= 2 0073 error('(%s) cannot be found msrmnt_file : %s', func_, msrmnt_file); 0074 end 0075 0076 if isempty(sph_data) 0077 error('(%s) sph_data is a required parameter', func_); 0078 end 0079 return; 0080 % 0081 % --- end of inner_check_arguments() 0082 % 0083 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0084 0085 % --- END OF FILE --- % 0086 0087