Skip to content

Python GMLMs for dimensionality reduction in neural data.

License

Notifications You must be signed in to change notification settings

latimerk/pyNeuroGMLM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyNeuroGMLM

Generalized multilinear model for dimensionality reduction of neural population spike trains.

The core of the code is a C++/CUDA library with optimized log likelihood and derivative computations. Using the GPU code requires a CUDA capable GPU. CPU-only code using Numpy is also available and easier to work for with Python.

Code tested using:

  • CUDA 11.6 --- Only needed if compiling with GPU code. If CUDA isn't available (or is an older version), only the CPU code will be used.
  • Python 3.9.7
  • pybind11 2.9.2
  • cmake 3.23.1

There are a couple Python scripts that demonstrate the very basic setup the GMLM for GPUs and on CPU in examples/.

Installing with pip

pip install git+https://github.com/latimerk/pyNeuroGMLM/

The basic library will be compiled using cmake. The install uses pybind11 to compile the CUDA/C++ library and hooks it up to Python.

The CPU-only version still requires compiling the C++ library to make sure that the same code handles organizing the GMLM and trial structures - Sorry, this is an annoying and less flexible design choice on my part to not make everything in Python. If no CUDA install is detected, the GPU code is disabled by default. Additionally, the library can be compiled without using Cuda by setting an environment variable before the install command:

export GMLM_WITH_GPU=OFF
pip install -v git+https://github.com/latimerk/pyNeuroGMLM/ 

For some reason, passing in an option directly into pip caused trouble, and replacing it with an environment variable was a quick and dirty fix. WINDOWS USERS: use set GMLM_WITH_GPU=OFF instead of export.

The library can be compiled to use single-precision data (double is default) using the GMLM_WITH_DOUBLE_PRECISION=Off option as (or in additon to) the GPU option above. Given pybind11's limitations with templating, it was way easier to just require recompiling that supporting both simultaneously. If there's any real demand to include both, I could add better support for both precisions.

Citation (preprint)

Latimer, K. W., & Freedman, D. J. (2021). Low-dimensional encoding of decisions in parietal cortex reflects long-term training history. bioRxiv.

https://www.biorxiv.org/content/10.1101/2021.10.07.463576v1

MATLAB support

MATLAB version for the DMC task

About

Python GMLMs for dimensionality reduction in neural data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published