All Projects β†’ ganguli-lab β†’ twpca

ganguli-lab / twpca

Licence: MIT license
πŸ• Time-warped principal components analysis (twPCA)

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to twpca

Dimensionality-reduction-and-classification-on-Hyperspectral-Images-Using-Python
In this repository, You can find the files which implement dimensionality reduction on the hyperspectral image(Indian Pines) with classification.
Stars: ✭ 63 (-46.61%)
Mutual labels:  dimensionality-reduction, principal-components
federated pca
Federated Principal Component Analysis Revisited!
Stars: ✭ 30 (-74.58%)
Mutual labels:  dimensionality-reduction, principal-components
Fooof
Parameterizing neural power spectra into periodic & aperiodic components.
Stars: ✭ 162 (+37.29%)
Mutual labels:  neuroscience
Brayns
Visualizer for large-scale and interactive ray-tracing of neurons
Stars: ✭ 232 (+96.61%)
Mutual labels:  neuroscience
Brainrender
a python based software for visualization of neuroanatomical and morphological data.
Stars: ✭ 183 (+55.08%)
Mutual labels:  neuroscience
Brainflow
BrainFlow is a library intended to obtain, parse and analyze EEG, EMG, ECG and other kinds of data from biosensors
Stars: ✭ 170 (+44.07%)
Mutual labels:  neuroscience
Neurodocker
Generate custom Docker and Singularity images, and minimize existing containers
Stars: ✭ 198 (+67.8%)
Mutual labels:  neuroscience
Kilosort
Fast spike sorting with drift correction for up to a thousand channels
Stars: ✭ 148 (+25.42%)
Mutual labels:  neuroscience
Pyphi
A toolbox for integrated information theory.
Stars: ✭ 246 (+108.47%)
Mutual labels:  neuroscience
Bmtk
Brain Modeling Toolkit
Stars: ✭ 177 (+50%)
Mutual labels:  neuroscience
Awesome Computational Neuroscience
A list of schools and researchers in computational neuroscience
Stars: ✭ 230 (+94.92%)
Mutual labels:  neuroscience
Dvid
Distributed, Versioned, Image-oriented Dataservice
Stars: ✭ 174 (+47.46%)
Mutual labels:  neuroscience
Eegrunt
A Collection Python EEG (+ ECG) Analysis Utilities for OpenBCI and Muse
Stars: ✭ 171 (+44.92%)
Mutual labels:  neuroscience
Neurotech Course
CS198-96: Intro to Neurotechnology @ UC Berkeley
Stars: ✭ 202 (+71.19%)
Mutual labels:  neuroscience
Erplab
ERPLAB Toolbox is a free, open-source Matlab package for analyzing ERP data. It is tightly integrated with EEGLAB Toolbox, extending EEGLAB’s capabilities to provide robust, industrial-strength tools for ERP processing, visualization, and analysis. A graphical user interface makes it easy for beginners to learn, and Matlab scripting provides enormous power for intermediate and advanced users.
Stars: ✭ 166 (+40.68%)
Mutual labels:  neuroscience
Brainiak
Brain Imaging Analysis Kit
Stars: ✭ 232 (+96.61%)
Mutual labels:  neuroscience
Suite2p
cell detection in calcium imaging recordings
Stars: ✭ 153 (+29.66%)
Mutual labels:  neuroscience
Opensesame
Graphical experiment builder for the social sciences
Stars: ✭ 173 (+46.61%)
Mutual labels:  neuroscience
Neurolib
Easy whole-brain modeling for computational neuroscientists πŸ§ πŸ’»πŸ‘©πŸΏβ€πŸ”¬
Stars: ✭ 188 (+59.32%)
Mutual labels:  neuroscience
Data-Science
Using Kaggle Data and Real World Data for Data Science and prediction in Python, R, Excel, Power BI, and Tableau.
Stars: ✭ 15 (-87.29%)
Mutual labels:  dimensionality-reduction

⚠️ Please use our newer code --- Piecewise Linear Time Warping:

Our new work removes the assumption of low-dimensional dynamics, and uses a new optimization framework to avoid local minima in the warping function fitting routine. The new code package is also better optimized for speed, contains cross-validation routines, and has tools for working with spike data in continuous time.

[DEPRECATED] Time warped principal components analysis (TWPCA)

Ben Poole 🍺, Alex H. Williams πŸŽ™οΈ, Niru Maheswaranathan ⚽

image

Overview

Installation

Again, this package is deprecated, so it should only be used as legacy software. But if you want to install it, you can do so manually:

git clone https://github.com/ganguli-lab/twpca
cd twpca
pip install -e .

Description

Analysis of multi-trial neural data often relies on a strict alignment of neural activity to stimulus or behavioral events. However, activity on a single trial may be shifted and skewed in time due to differences in attentional state, biophysical kinetics, and other unobserved latent variables. This temporal variability can inflate the apparent dimensionality of data and obscure our ability to recover inherently simple, low-dimensional structure.

Here we present a novel method, time-warped PCA (twPCA), that simultaneously identifies temporal warps of individual trials and low-dimensional structure across neurons and time. Furthermore, we identify the temporal warping in a data-driven, unsupervised manner, removing the need for explicit knowledge of external variables responsible for temporal variability.

For more information, check out our abstract or poster.

We also encourage you to look into our new package, affinewarp, which was built with similar applications in mind.

Code

We provide code for twPCA in python (note: we use tensorflow as a backend for computation).

To apply twPCA to your own dataset, first install the code (pip install twpca) and load in your favorite dataset and shape it so that it is a 3D numpy array with dimensions (number of trials, number of timepoints per trial, number of neurons). For example, if you have a dataset with 100 trials each lasting 50 samples with 25 neurons, then your array should have shape (100, 50, 25).

Then, you can apply twPCA to your data by running from twpca import TWPCA; model = TWPCA(data, n_components).fit() where n_components is the number of low-rank factors you wish to fit and data is a 3D numpy as described above. A more thorough example is given below:

from twpca import TWPCA
from twpca.datasets import jittered_neuron

# generates a dataset consisting of a single feature that is jittered on every trial.
# This helper function returns the raw feature, as well as the aligned (ground truth)
# data and the observed (jittered) data.
feature, aligned_data, raw_data = jittered_neuron()

# applies TWPCA to your dataset with the given number of components (this follows the
# scikit-learn fit/trasnform API)
n_components = 1
model = TWPCA(raw_data, n_components).fit()

# the model object now contains the low-rank factors
time_factors = model.params['time']         # compare this to the ground truth feature
neuron_factors = model.params['neuron']     # in this single-neuron example, this will be a scalar

# you can use the model object to align data (compare this to the aligned_data from above)
estimated_aligned_data = model.transform()

We have provided a more thorough demo notebook demonstrating the application of tWPCA to a synthetic dataset.

Further detail

Motivation

Performing dimensionality reduction on misaligned time series produces illusory complexity. For example, the figure below shows that a dataset consisting of a single feature jittered across trials (red data) has illusory complexity (as the spectrum of singular values decays slowly).

image

The twPCA model

To address this problem for a sequence of multi-dimensional time-series we simultaneously fit a latent factor model (e.g. a matrix decomposition), and time warping functions to align the latent factors to each measured time series. Each trial is modeled as a low-rank matrix where the neuron factors are fixed (gray box below) while the time factors vary from trial to trial by warping a canonical temporal factor differently on each trial.

image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].