0001 function [trigger_channel_idx, trigger_sample_idx] = ...
0002 vb_msrmnt_get_trigger_samples(msrmnt_file, trigger_ch, tr_strt_idx)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 vb_define_device;
0030
0031
0032 if ~exist('msrmnt_file', 'var'), msrmnt_file = []; end
0033 if ~exist('trigger_ch', 'var'), trigger_ch = []; end
0034 if ~exist('tr_strt_idx', 'var'), tr_strt_idx = []; end
0035 [msrmnt_file, trigger_ch, tr_strt_idx, ...
0036 Measurement, info, data, trg_ch_idx] = ...
0037 inner_check_arguments(msrmnt_file, trigger_ch, tr_strt_idx);
0038
0039 trigger_channel_idx = trg_ch_idx;
0040
0041
0042
0043 func_ = mfilename;
0044 switch Measurement
0045 case 'EEG'
0046 idx = vb_eeginfo_get_trigger_status_label(info);
0047
0048 status_data = data(idx,:);
0049
0050 bit_len = DEFAULT_BIT_LEN;
0051 bit_arrays = vb_eeg_make_channel_bit_array(status_data, trg_ch_idx, bit_len);
0052
0053 trigger_sample_idx = [];
0054 for nch = 1:size(bit_arrays,1)
0055 trigger_sample_idx = [trigger_sample_idx; ...
0056 vb_util_get_bit_on_list(bit_arrays(nch,:), bit_len)];
0057 end
0058
0059 case 'MEG'
0060 error('(%s)not be implemented yet for ''%s''', func_, Measurement);
0061 otherwise
0062 error('(%s)unknown Measurement: ''%s''', func_, Measurement);
0063 end
0064
0065
0066
0067
0068
0069
0070
0071 function [msrmnt_file, trigger_ch, tr_strt_idx, ...
0072 Measurement, info, data, trg_ch_idx] = ...
0073 inner_check_arguments(msrmnt_file, trigger_ch, tr_strt_idx)
0074
0075 func_ = mfilename;
0076
0077 info = [];
0078 data = [];
0079 trg_ch_idx = [];
0080
0081 if isempty(msrmnt_file)
0082 error('(%s)msrmnt_file is a required parameter', func_);
0083 end
0084
0085 if exist(msrmnt_file, 'file') ~= 2
0086 error('(%s)cannot read msrmnt_file : %s', func_, msrmnt_file);
0087 end
0088
0089 [measurement] = vb_load_device(msrmnt_file);
0090 Measurement = upper(measurement);
0091
0092 switch Measurement
0093 case 'EEG'
0094 info = vb_eegfile_load_eeginfo(msrmnt_file);
0095 data = load_eeg_data(msrmnt_file);
0096
0097 if isempty(tr_strt_idx)
0098 tr_strt_idx = vb_eeginfo_get_sensor_number(info) + 1;
0099 end;
0100
0101
0102 all_ch_label = vb_eegfile_get_channel_label(msrmnt_file);
0103 org_ch_idx = vb_util_get_matching_label_index(all_ch_label, trigger_ch);
0104 trg_ch_idx = org_ch_idx - tr_strt_idx + 1;
0105
0106
0107 trg_ch_idx = vb_util_arrange_list(trg_ch_idx,1);
0108
0109 case 'MEG'
0110 error('(%s)not be implemented yet for ''%s''', func_, Measurement);
0111 otherwise
0112 error('(%s)unknown Measurement : ''%s''', func_, Measurement);
0113 end
0114
0115 if isempty(trigger_ch)
0116 error('(%s)trigger_ch is a required parameter', func_);
0117 end
0118
0119
0120
0121
0122