Welcome to braivest! Braivest is a package for analyzing brain state data based on Variational Autoencoders (VAEs). Accompanying preprint is coming soon!
Why use braivest?
- Supervised learning for brain state classification is restricted to predefined states and biased by expert labels
- Traditional dimensionality reduction/visualization methods fail
- Braivest can be used to compare brain state data across... experimental conditions (i.e. healthy vs cancerous), brain regions, task conditions, and more!
- Braivest is agnostic to recording modality including LFP, EEG, voltage imaging, and more!
We recommend using a conda or virtualenv environment for braivest. Environment yaml file is provided. In addition, please install tensorflow and tensorflow-probability with instructions from the website. Currently, only tensorflow 2.15.0 and tensorflow-probability 0.23.0 are supported. Higher versions have keras dependency issues.
We recommend using a machine with access to GPU nodes for training of models. Our models are written using Tensorflow and Tensorflow probability. Please refer to the Tensorflow documentation to learn how to set up your GPU for use.
pip install .
The first step to using braivest is to preprocess your data. First use pywavelets to calculate wavelets from your data. Be sure to take note of the sampling rate of your data. Use wavelet_utils to determine scales and calculate continuous wavelets, then transforming them into power spectral density data. NOTE: Wavelets are computationally expensive and calculations will be much faster with multithreading.
Then, turn your transformed data into a usable dataset. Take consideration of training vs test set. You can look at examples in examples. The emgVAE (optionally) uses the last axis of input data (traditionally emg), as one of the axes of the low-dimensional manifold.
We recommend using wandb for dataset versioning, hyperparameter sweeps, and model training tracking. Our package includes wandb flags for optionally using wandb.
After you have your dataset, it is time to train your model using the Trainer. Follow the example
After obtaining your low-dimensional manifold representation, you can optionally segment your data using a Hidden Markov Model (HMM). We recommend using the ssm package from Linderman Lab . Additionally, we have forked the linderman/ssm repository to add an additional type of HMM which allows for multiple transition graphs for different datasets that share cluster emissions (termed MultiHMM). You can find that here
There are several types of analysis that can be done. Follow examples in the examples section.
Plotly allows for interactive web apps to view data. We have included example apps for viewing the manifold, selecting a point, and viewing the corresponding raw data or spectrogram.