Skip to content

EEG: make evoked responses

Fa-Hsuan Lin edited this page Nov 1, 2019 · 3 revisions

EEG: make evoked responses

This example script will calculate the evoked responses of the EEG data. This was an experiment of steady-state visual evoked potential. We showed black/white checkerboards reversals at 7.5 Hz to the subject. The data can be downloaded for your testing purpose.

Some explanation of the setting that you may need to update based on your needs:

  • These two lines specify the locations data file including data and its annotations.
headerFile = {'../eeg_raw/SSVEP_out_1.vhdr';};
markerFile={'../eeg_raw/SSVEP_out_1.vmrk';};

*These three lines specify the electrodes to be included in the analysis. They are EEG traces from the 1st to 31th in the time series and an ECG trace as the 32th time series.

select_channel={ 'Fp1'    'Fp2'    'F3'    'F4'    'C3'    'C4'    'P3'    'P4'    'O1'    'O2'    'F7'    'F8'    'T7'    'T8'    'P7'    'P8'    'Fz'    'Cz'    'Pz'    'Oz'    'FC1'    'FC2'    'CP1'    'CP2'    'FC5'    'FC6'    'CP5'    'CP6'    'TP9'    'TP10'    'POz'    'ECG'};
eeg_channel=[1:31];
ecg_channel=[32];
  • These are flags to determine whether re-referencing, high-pass filtering, average artifact suppression (AAS; needed when EEG was recorded during MRI excitation/reading), and ballistocardiogram (BCG) artifact removal (need when EEG was recorded inside MRI) are needed.
flag_reref= [1]; %referencing: remove the average time course across all electrodes from the time course at each individual electrode
flag_hp=    [1]; %high pass filtering at 0.1 Hz
flag_aas=   [0]; %AAS for gradient artifact suppression
flag_bcg=   [1]; %BCG artifact suppression
  • Here we set the evoked response with 0.2 s pre-stimulus baseline and 1.0 s post-stimulus duration.
erp_pre=0.2; %s; pre-stimulus interval
erp_post=1.0; %s; post-stimulus interval
  • Then trials with excessive large values will be discarded automatically. We also want to remove the bias in the pre-stimulus baseline.
flag_badrejection=1; %automatic bad trial rejection
flag_baseline_corr=1;
  • Finally, we considered three different kinds of evoked responses. They were time-locked to the onsets of events marked as "1", "10", and ("1" or "10"). The evoked responses will be saved into a Matlab file erp_avg_outside.mat.
erp_event={1,10, [1 10]};
output_avg_file='erp_avg_outside.mat';
  • The output will be a structure cell variable named erp. It has three structures. Taking erp{3} as the example, you can see that each structure includes the following fields:
  • n_trial: 48 (# of trials used for the estimation of the evoked response)
  • trial_idx: [48×1 double] (trials that were included in the estimation of the evoked response)
  • erp: [31×6000 double] (a 2D matrix of 31 electrodes with 6000 time points; sampled at the target sampling rate of 500 Hz)
  • timeVec: [1×6000 double] (a 1D vector of timing of the evoked response; in seconds)
  • trigger: {[1 10]} (the trigger(s) used for this evoked response)
  • electrode_name: {1×32 cell} (electrodes of the evoked response)
Clone this wiki locally