Skip to main content

Supervised learning function for temporal decoding.

Project description

Supervised Learning Function for Neural data

This toolbox facilitates neural decoding of time series. Under the hood it uses scikit-learn functions.

Set-up

Install using pip (https://pypi.org/project/temp-dec/)

pip install temp_dec

Requirements

sklearn==0.21.3
numpy==1.13.1
scipy==0.19.1

Python implementation

This function takes in the data X (ndarray; trials by features by time), labels y (ndarray; vector).

from temp_dec import decoding_functions
decoding_functions.temporal_decoding(X, y)

Using a sliding time window

If there is information in the temporal dynamics of the signal, using a sliding time window will increase decoding accuracy (and smooth the signal). We can also demean the signal within each window, this avoids the issue of baselining.

size_window=5
demean=True

Applying PCA

If you use a large amount of features, you might want to consider applying PCA to your features before applying your classifier. In addition, classifiers are sensitive to noise rejecting noise components from the data can be beneficial. You can also regulate how many components you would like to keep (setting the pca_components variant to > 1) or how much variance you would like to explain (setting the pca_components variant to < 1). As a general rule of thumb maintaining 95% of variance will maintain enough signal and reduces feature space. If pca_components = 1 then 100% of the variance will be maintained so no PCA is applied.

pca_components = .95

Classifiers

Different classifiers are supported, selected in accordance with Grootwagers et al (2017) j.cogn.neurosci.

  • LDA: linear disciminant analysis
  • LG: logistic regression
  • GNB: Gaussian Naive Bayes
  • maha: Nearest Neighbours using mahalanobis distance.
classifier = 'LDA'

with the amounts of stratified cross-validations (kfold) adjusted with the following flag, 5-fold by default.

n_folds = 5

All options incorporated

output = decoding_functions.temporal_decoding(data,labels,
                                                n_folds=5,
                                                classifier='LDA',
                                                pca_components=.95,
                                                size_window=20,
                                                demean=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

temp_dec-1.0.9.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

temp_dec-1.0.9-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file temp_dec-1.0.9.tar.gz.

File metadata

  • Download URL: temp_dec-1.0.9.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for temp_dec-1.0.9.tar.gz
Algorithm Hash digest
SHA256 3cef87a393cc5e517d46a117ffd11925bc22969c922b9dd1e62c6045c289171d
MD5 3eb0a5d16c2157a5f718b71bb469ae70
BLAKE2b-256 ccfe08439bfa06e1868adf1586442f230ba76cd9c58e436b1c1a4d3a370614dd

See more details on using hashes here.

File details

Details for the file temp_dec-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: temp_dec-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for temp_dec-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d0aa158893627d348b53afb28ef27d3435fe0c40bde8ed79f19f99b43c27cbb3
MD5 e4ea87e3cf5d860fad99387b3b269e90
BLAKE2b-256 623652962ec25e6f4240d7c6555ddd10817520e1b8a37dddb945a9bc006a2cce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page