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
EventTimesToCountstransformer.- Accepts standard array-like inputs (not
Neoobjects), simplifying integration with other tools. - Follows scikit-learn's transformer–estimator interface for clean, reusable workflows.
- Accepts standard array-like inputs (not
- 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.
Install directly from GitHub using pip:
$ pip install git+https://github.com/CausalityInMotion/BlockInverseGPFA.gitOr 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 dependenciesYou are now set to use the package.
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 nbsphinxFinally, to view the documentation locally, run
$ cd docs
$ make html
$ open _build/html/index.htmlor 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)
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.
Modified BSD License based on Elephant, see LICENSE.txt for details.
©️ 2021-2025 Brooks M. Musangu and Jan Drugowitsch
See acknowledgments.