Giter VIP home page Giter VIP logo

pywptemd's Introduction

WPTEMD

Python 3.9 Poetry

A class used to remove artifacts from EEG signals, the default EEG signal has a duration of 6 seconds and 19 channels.

How to use it:

Inputs:

EEG data with artifacts to be filtered, and EEG data in resting state, dimensions N x channels where N is the length of an EEG record

Methods

_wpt_filter: filters data selecting the most corrupt node in a wpt removes it and makes the reconstruction of the signal, a wpt is computed per channel

wptemd_filter: applies _wpt_filter, and after decomposing each filtered channel into imfs using emd, to filter again the signal removing the most corrupt imf computing J a criterion based on entropy and std normalized with respect to the resting data

wptica_filter: like in wptemd_filter applies _wpt_filter to filter the data, afterward a second ICA based filter is applied where is removed the most contaminated ICA component, and reconstructed the sources

Output

Data_filtered a filtered version of the original EEG data

Example

import numpy as np
from Pywptemd.wptemd import wptemd

fs = 500
data = np.random.randn(19,6*fs)
data_rest = np.random.randn(19,6*fs)*.25

parameters = {'wavelet':'dmey', 'maxlevel':7, # wavelet parameters
'imf_opts':{'stop_method':'rilling', 'rilling_thresh':(0.05, 0.5, 0.05)}, # emd parameters
'w':0.5, # emd selection criterion J parameter
'n_components':19} # ICA parameter
filter = wptemd(**parameters)

wpt_filtered = filter._wpt_filter(data)
print(wpt_filtered.shape)

data_filtered_wptemd = filter.wptemd_filter(data, data_rest)
print(data_filtered_wptemd.shape)

data_filtered_wtpica = filter.wptica_filter(data)
print(data_filtered_wtpica.shape)

References

[1] Bono, V., Das, S., Jamal, W., & Maharatna, K. (2016). Hybrid wavelet and EMD/ICA approach for artifact suppression in pervasive EEG. Journal of neuroscience methods, 267, 89-107.

pywptemd's People

Contributors

efsierraa avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.