Skip to content

bmusangu/BlockInverseGPFA

 
 

Repository files navigation

BlockInvGPFA

Automated Tests Documentation Status

This package provides a Python implementation of Gaussian Process Factor Analysis (GPFA) that incorporates a novel approach to efficiently handle variable-length time series data. Building on the original method by Byron Yu et al. (2009), this implementation introduces a block-matrix–based inversion strategy that reuses kernel computations across trials of different lengths.

The package also includes scikit-learn–compatible API for integration into existing ML workflows such as:

  • A Modular Preprocessing — Separates data preprocessing from model logic via a dedicated EventTimesToCounts transformer.
    • Accepts standard array-like inputs (not Neo objects), simplifying integration with other tools.
    • Follows scikit-learn's transformer–estimator interface for clean, reusable workflows.
  • A new variance-explained metric to evaluate GPFA model fits.

This implementation is adapted from Elephant’s GPFA codebase with substantial modifications to improve performance, modularity, and usability in Python-based pipelines.

Usage

Installation


Install directly from GitHub using pip:

$ pip install git+https://github.com/CausalityInMotion/BlockInverseGPFA.git

Or clone the repo and install locally:

$ git clone https://github.com/CausalityInMotion/BlockInverseGPFA.git
$ cd BlockInverseGPFA
$ pip install . # or pip install .[test,docs] to include optional dependencies

You are now set to use the package.


Building the documentation


Building the documentation requires the following packages:

You can install the required documentation dependencies by:

$ pip install .[docs]

or manually by calling

$ pip install sphinx sphinx-rtd-theme numpydoc nbsphinx

Finally, to view the documentation locally, run

$ cd docs
$ make html
$ open _build/html/index.html

or view them online: BlockInvGPFA docs

A detailed walkthrough of the package — including how to fit the model to real neural data — is available in the Jupyter notebook example: (link)


Tests


To run the full test suite in the test folder, use:

$ pip install .[test]
$ pytest test/

Tests are automatically run via GitHub Actions on every push and pull request.

License

Modified BSD License based on Elephant, see LICENSE.txt for details.

Copyright

©️ 2021-2025 Brooks M. Musangu and Jan Drugowitsch

Acknowledgments

See acknowledgments.

About

Implementation of GPFA in python for sklearn

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%