Home > vbmeg > functions > gui > preAnalysis > meeg_processor > utility > timeseries_viewer > vb_timeseries_viewer_load_trigger_file.m

vb_timeseries_viewer_load_trigger_file

PURPOSE ^

load trigger file and return the trial, trigger channel information

SYNOPSIS ^

function [trial_list, trig_ch_list] = vb_timeseries_viewer_load_trigger_file(trigger_obj, trigger_file)

DESCRIPTION ^

 load trigger file and return the trial, trigger channel information
 [Input]
     trigger_obj : vb_continuous_file object for trigger.
    trigger_file : trigger file(.trig.mat)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [trial_list, trig_ch_list] = vb_timeseries_viewer_load_trigger_file(trigger_obj, trigger_file)
0002 % load trigger file and return the trial, trigger channel information
0003 % [Input]
0004 %     trigger_obj : vb_continuous_file object for trigger.
0005 %    trigger_file : trigger file(.trig.mat)
0006 %
0007 trig = load(trigger_file);
0008 Nsample = vb_continuous_file_get_Nsample(trigger_obj);
0009 
0010 % consistency check between status channel and MEG/EEG sample
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 % Create trial information
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; % sec
0029         trial.to    = trig.trig(k)/freq + trig.parm.Posttrigger_ms/1000;% sec
0030         trial.onset = trig.trig(k)/freq;                       % sec
0031         trial_list = [trial_list; trial];
0032     end
0033 end
0034 
0035 % Trigger channel
0036 trig_ch_list = trig.parm.status_ch;
0037 
0038 %
0039 % --- After check
0040 %
0041 if nargout ~= 2
0042     error('Function caller should receive obj.');
0043 end
0044

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