While processing EEGs for some artificial intelligence based diagnostics, I created an approach that innovates visualation with a Power Spectral Density sliding window integrating several minutes of EEG in a simple 3D visual graph schematic head showing sensor data location.

The simplest in Python is to read EEG files in the EDF+ format with pyEDFlib I then use signal.welch from scipy to compute the Power Spectral Density on a 10 second sliding window.

Thus I am able to visualize as shown in the image below several thousands of seconds of EEG signals in a single 3D Image using ax.plot_surface . While performing the initial visualizations I noticed that there were peaks that were crossing all frequencies that are visible in the image. These peaks are called artifacts and result from muscle movements, eye blinking etc.

3D Signal before

Based on what I was seeing I created an artifact cleaning by process of removal of outliers on a 3D signal representing the Power Spectral Density of an EEG.

The signal is compared with mean and standard deviation across all frequencies at a given window, and suppressing window when a threshold is reached e.g. More than half of the frequencies are 2D outliers, which I implemented un Python using scikit-learn. The artifact removal process is to

  1. Capture signal of a given electrode for a minimum duration that contains both artifacts and non-artifacts
  2. Compute the logarithmic Power Spectral Density on a sliding time window 30 seconds duration in the figure above, sliding every given time step 10 second in the figure above for the full duration of the EEG signal capture
  3. Compute the Power average and the standard deviation for each frequency is Power Spectrum.
  4. If a fraction (1/8th in the figure below) of the signal for a given time step is above the mean optionally summed with a standard deviation fixed proportion for corresponding frequency (none in the figure below), then it is added the time index to artifact list.
  5. Produce a signal with the corresponding time index removed.

The result is the following signal 3D representation, but of course the artifact time intervals can also be removed from a 2D visualisation.

After artifact removal

Attachments

Trackback URL : http://marc.fiammante.blog.free.fr/index.php?trackback/11179017