Skip to content

This repository includes useful MATLAB codes for the detection of SSVEP in EEG signals using spatial filters, frequency recognition algorithms, and machine-learning methods.

Notifications You must be signed in to change notification settings

RezaSaadatyar/SSVEP-based-EEG-signal-processing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1️⃣ Introduction

  • Brain-Computer Interfaces (BCI):
    "BCI" is a method of measuring central nervous system activity and converting it into artificial output that can replace, restore, enhance, supplement, or improve natural CNS output and alter the ongoing interactions between the CNS and its external or internal environment. BCIs can be categorized based on their dependability as dependent or independent. Dependent BCIs enable individuals to use some form of motor control, such as gaze. The use of BCIs based on motor imagery is a common example of dependent BCIs. A BCI without motor control, on the other hand, can be used by stroke survivors or those with locked-in syndrome. Synchronous BCI involves the subject responding to cues imposed by the system over a set period. As opposed to synchronous BCI, asynchronous BCI allows the subject to communicate with the application at any time. BCIs that are synchronous have a lower usability than those that are asynchronous.

  • EEG Paradigms used in BCI:
    Motor Imagery (MI) (Further information)
    Event‑Related Potential (ERP)
    Steady‑State Evoked Potentials (SSEP)
    Blank diagram - Page 1 (2) Blank diagram - Page 1 (1)

  • Steady‑State Evoked Potentials (SSEP):
    According to visual, auditory, and somatosensory stimulation, SSEP are classified as Steady-State Visually Evoked Potentials (SSVEP), Steady-State Auditory Evoked Potentials (SSAEP), and Steady-State Somatosensory Evoked Potentials (SSSEP).
    SSAEP:
    The SSAEP are usually extracted using trains of click stimuli, tone pulses, or amplitude-modulated tones, at a repetition or modulation rate between 20 and 100 Hz.
    SSSEP
    The SSSEP paradigm uses vibrotactile sensors to produce stimulation at distant frequencies, which are mounted on predetermined parts of the body.
    SSVEP:
    In SSVEP-based BCIs, visual stimuli are triggered at constant frequencies between 3.5 and 75 Hz. The best response for this stimulus is obtained for frequencies between 5 and 20 Hz. Focusing on a flickering stimulus generates an SSVEP with the same frequency as the target ficker. Speller recognition is one of the most widely used BCI applications since it transmits information faster than other paradigms. Since an SSVEP can transmit information at a high rate and requires little training, it is widely used in numerous applications, like spellers, smart homes, games, robot control, and exoskeleton control.

  • In a biological visual system, the visual pathway starts with the retina and each unit has a corresponding function. Blank diagram - Page 1


2️⃣ Methods

  • Experimental setup

    • Dataset
    • Sampling rate: 256 Hz
    • Stimulus frequencies: 13, 17, 21 Hz
    • Number of channels : 9 (Oz, O1, O2, POz, PO3, PO4, PO7 and PO8; Fz: Reference)
    • For each trial, a 5-second were used for stimuli and a 3-second for pauses, and a total of 160 trials were recorded for each subject.
    • Trial length: 2565=1280 ---> 12808 (Number channels)
    • A trial starts with a Label_XX stimulation code indicating the class of the example.
      • Label_01 ---> 13Hz stimulation (33025)
      • Label_02 ---> 21Hz stimulation (33026)
      • Label_03 ---> 17Hz stimulation (33027)
  • Data pre-processing
    Convert gdf data to mat:
    Put the "biosig4format" folder on the desktop ---> biosig4octmat ---> biosig ---> run the install code ---> run [Signal, Inform] = sload('file name.gdf ') in command window then save Signal and Inform (App1_Data_Preprocessing_a_trial.m; App2_Data_Preprocessing_all_trial.m).
    Inform.EVENT.TYP ---> Label trials
    Inform.EVENT.Pos ---> Time start the trials

App3_Plot_Trial.m; App4_Filter_Signal.m: ↘️

1 2

  • Algorithms proposed
    • Spatial filtering approaches:
      Spatial filters are commonly used to improve the signal-to-noise ratio (SNR) of EEG. In a spatial filter, the signal from the EEG electrodes is mixed in such a way that the signal of interest is enhanced, while noise or artifact components are reduced.

      • Common average reference (CAR)
      • Small Laplacian
      • Large Laplacian
    • SSVEP frequency recognition algorithms
      Power Spectral Density Analysis (PSDA):
      The PSDA method is often used for SSVEP detection, which is related to frequency domain signal processing. The power spectral density analysis is implemented by calculating the signal/noise ratio based on the power densities around the stimulus frequencies.
      Canonical correlation analysis (CCA) method:
      The CCA-based frequency recognition method is one of the widely used methods in SSVEP-based BCI, and several extended versions were proposed in the past decade. CCA measures the correlation between two multidimensional variables, and it can produce multiple canonical correlation coefficients. The largest coefficient was usually used for frequency recognition, the remaining coefficients were optionally discarded. The scalp EEG data often contain noise and artifacts. Scalp EEG data often contain noise and artifacts. When using CCA for frequency detection with EEG data, noise and artifacts may result in discriminative information spanning all or parts of the canonical correlation coefficients, and discarding other coefficients may result in the loss of useful information for frequency detection.

      • Fusing Canonical Coefficients of CCAs (FoCCA):
        To begin using the FoCCA method, use the standard CCA to obtain the canonical coefficients for each individual test sample and reference signal at each given frequency. Then, for each given frequency, use formula (1) to calculate a new feature for the test sample and $f_{test} = max βi( f ), i = 1, 2, . . . , Nf$ to identify the frequency.
        $$βi( f )=\sum_{k=0}^D φk.(\lambda_k)^2 \leftarrow φk=k^{-a}+b \Longleftarrow (1)$$
      • Filter bank CCA (FBCCA):
        A filter bank is a collection of band-pass filters that divide an input signal into multiple sub-band components. Given the distinct spectral properties of multiple harmonic frequencies in SSVEPs, the filter bank method has significant potential to improve SSVEP CCA-based frequency detection. Three methods were proposed to optimize the filter bank design.
        • Method 1: sub-bands with equally spaced bandwidths
        • Method 2: sub-bands corresponding to individual harmonic frequency bands
        • Method 3: sub-bands covering multiple harmonic frequency bands

      Multivariate synchronization index method (MSI):
      The MSI was proposed based on the theory of S-estimator. It calculates correlation based on the entropy of the normalized eigenvalues of a multichannel signal's covariance matrix. The estimation of the covariance matrix in the MSI method ignores the temporally local structure of samples.
      Fast Fourier Transform (FFT)

      App5_Filter_CAR.m; App6_PSDA_a_trial.m: ↘️

3 4 7


3️⃣ Results

  • Performance of Methods:

    App7_PSDA_all_trial.m; App9_CCA_all_trial.m; App10_FOCCA_all_trial.m; App11_FBCCA_all_trial.m; App12_MSI_all_trial.m: ↘️ 10

    App13_CCA_FeatureExtraction.m: ↘️
    1011

    App15_FeatureExtraction_Classification.m: ↘️
    1213