0001 function vb_msrmnt_update_active_flag_ex(base_file, active_ch, new_file)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if ~exist('base_file', 'var'), base_file = ''; end
0023 if ~exist('active_ch', 'var'), active_ch = []; end
0024 if ~exist('new_file', 'var'), new_file = ''; end
0025 [base_file, active_ch, new_file] = ...
0026 inner_check_arguments(base_file, active_ch, new_file);
0027
0028
0029
0030 info = vb_load_measurement_info(base_file);
0031 n_channel = vb_info_get_Nchannel(info);
0032
0033 if ~isempty(active_ch)
0034 act_len = size(active_ch, 1);
0035 if act_len ~= n_channel
0036 warning('(%s)length of active_ch (%d) ~= n_channel(%d)\n', ...
0037 mfilename, act_len, n_channel);
0038 fprintf('(%s)ActiveChannel has not been updated\n', mfilename);
0039 else
0040 info = vb_info_set_active_channel(info, active_ch);
0041 end
0042 end
0043
0044 if ~isempty(active_tr)
0045 act_len = size(active_tr, 1);
0046 if act_len ~= n_trial
0047 warning('(%s)length of active_tr (%d) ~= n_trial(%d)\n', ...
0048 mfilename, act_len, n_trial);
0049 fprintf('(%s)ActiveTrial has not been updated\n', mfilename);
0050 else
0051 info = vb_info_set_active_trial(info, active_tr);
0052 end
0053 end
0054
0055
0056 if ~isempty(new_file)
0057 org_data = load(base_file);
0058 measurement = vb_info_get_measurement(info);
0059
0060 switch measurement
0061 case 'MEG'
0062 org_data.MEGinfo = info;
0063 case 'EEG'
0064 org_data.EEGinfo = info;
0065 otherwise
0066 error('(%s) unknown measurement : %s', mfilename, measurement);
0067 end
0068
0069 vb_save_struct(new_file, org_data);
0070 end
0071
0072
0073
0074
0075
0076
0077
0078 function [base_file, active_ch, active_tr, new_file] = ...
0079 inner_check_arguments(base_file, active_ch, active_tr, new_file)
0080 func_ = mfilename;
0081
0082 if isempty(base_file)
0083 error('(%s) base_file is a required parameter', func_);
0084 end
0085
0086 if exist(base_file, 'file') ~= 2
0087 error('(%s) cannot find base_file : %s', func_, base_file);
0088 end
0089
0090 if isempty(active_ch)
0091
0092 end
0093
0094 if isempty(active_tr)
0095
0096 end
0097
0098 if isempty(new_file)
0099 new_file = base_file;
0100 end
0101 return;
0102
0103
0104
0105
0106
0107