Home > vbmeg > demo > tutorial_for_vbmeg2 > advanced > make_trial_eeg.m

make_trial_eeg

PURPOSE ^

Make trial data

SYNOPSIS ^

function make_trial_eeg(p)

DESCRIPTION ^

 Make trial data

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function make_trial_eeg(p)
0002 % Make trial data
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 disp(mfilename);
0008 
0009 % Set parameters
0010 parm.Pretrigger_ms  = p.Pretrigger_ms; % before trigger [msec]
0011 parm.Posttrigger_ms = p.Posttrigger_ms; % after trigger [msec]
0012 parm.condition={'stim'};
0013 parm.status_ch={'EXT1'};
0014 parm.trig_type='analog';
0015 parm.slope='low_to_high';
0016 parm.status_level=0.5;
0017 
0018 plot_parm.mode  = 1; % = 1: plot all trial
0019 plot_parm.NXmax = 25; % # of trial in X-axis
0020 plot_parm.NYmax = 5; % # of subplot in Y-axis
0021 
0022 Nfile = length(p.file_list);
0023 
0024 % Extract stimulus onsets
0025 for file=1:Nfile
0026     % Set input file
0027     parm.data_file = fullfile(p.eeg_dirname, p.filter_dirname, [p.file_list{file} '.eeg.mat']);
0028     
0029     % Set output file
0030     parm.trig_file = fullfile(p.eeg_dirname, p.filter_dirname, [p.file_list{file} '.trig.mat']);
0031     
0032     % Get time index for each trial by checking status channel
0033     vb_job_trial_onset(p.proj_root,parm);
0034     vb_plot_status(fullfile(p.proj_root, parm.trig_file), plot_parm);
0035 end
0036 
0037 % Remove first trigger for visual task
0038 % because it does not represent stimulus onset
0039 for run=1:2
0040     % Load trigger data
0041     trig_file = fullfile(p.proj_root, p.eeg_dirname, p.filter_dirname, ['v' num2str(run) '.trig.mat']);
0042     load(trig_file, 'cond_id', 'ix_trial', 'trig')
0043     
0044     % Remove first trigger
0045     cond_id = cond_id(2:end);
0046     ix_trial = ix_trial(:,2:end);
0047     trig = trig(2:end);
0048     
0049     % Save modified trigger
0050     vb_save(trig_file, 'cond_id', 'ix_trial', 'trig');
0051 end
0052 
0053 % Make trial data
0054 for file = 1:Nfile
0055     % Set input file
0056     filtered_file = fullfile(p.proj_root, p.eeg_dirname, p.filter_dirname, [p.file_list{file} '.eeg.mat']);
0057     proc_spec.trig_file = fullfile(p.proj_root, p.eeg_dirname, p.filter_dirname, [p.file_list{file} '.trig.mat']);
0058     
0059     % Set output file
0060     trial_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, [p.file_list{file} '.eeg.mat']);
0061     
0062     % Make trial data
0063     vb_msrmnt_make_trial_data(filtered_file, proc_spec, trial_file);
0064 end
0065 
0066 
0067 
0068

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