0001 function [trial_list, trig_ch_list] = vb_timeseries_viewer_load_trigger_file(trigger_obj, trigger_file)
0002
0003
0004
0005
0006
0007 trig = load(trigger_file);
0008 Nsample = vb_continuous_file_get_Nsample(trigger_obj);
0009
0010
0011 if length(trig.status_out) ~= Nsample
0012 res = questdlg(['Specified trigger file and MEG/EEG file have ', ...
0013 'different sample number. Continue operation?'], ...
0014 'Confirm', 'Yes', 'No', 'No');
0015 if strcmpi(res, 'No')
0016 trial_list = [];
0017 trig_ch_list = [];
0018 return;
0019 end
0020 end
0021
0022
0023 trial_list = [];
0024 if exist('trig', 'var')
0025 freq = vb_continuous_file_get_sample_freq(trigger_obj);
0026 for k=1:length(trig.trig)
0027 trial = struct;
0028 trial.from = trig.trig(k)/freq - trig.parm.Pretrigger_ms/1000;
0029 trial.to = trig.trig(k)/freq + trig.parm.Posttrigger_ms/1000;
0030 trial.onset = trig.trig(k)/freq;
0031 trial_list = [trial_list; trial];
0032 end
0033 end
0034
0035
0036 trig_ch_list = trig.parm.status_ch;
0037
0038
0039
0040
0041 if nargout ~= 2
0042 error('Function caller should receive obj.');
0043 end
0044