Joint Autoencoders (JAE1 channel-split, JAE2 JEPA) for neural signal denoising and manifold learning
Project description
JAE: Joint Autoencoders for Neural Signal Denoising and Manifold Learning
pyjae (pronounced "pie-jay") provides two joint-autoencoder models for
denoising high-dimensional neural population recordings and recovering the
low-dimensional manifold underneath them:
- JAE1 is a corrected reimplementation of the channel-split Joint Autoencoder from Altan et al. (2021). It splits channels into disjoint partitions that share the signal but carry independent noise, and denoises by forcing their latents to agree.
- JAE2 is a JEPA (Joint-Embedding Predictive Architecture): instead of a fixed channel split, it masks part of the input and predicts the embedding of the masked region from the visible context, learning the manifold with a VICReg objective that prevents latent collapse.
Installation
pip install pyjae
Or with uv:
uv add pyjae
For development from source:
git clone https://github.com/egealtan/pyjae.git
cd pyjae
uv sync # installs the package with the dev extras
Quick start
from pyjae import JAE, simulate_neural_data
# Simulate a 6D nonlinear manifold observed on 64 noisy channels
clean, noisy, info = simulate_neural_data(
n_samples=400, n_channels=64, n_timepoints=96,
latent_dim=6, snr_db=10.0, nonlinear=True, alpha=3.0, seed=0,
)
# Train the channel-split model and denoise
model = JAE(latent_dim=6) # backend="jae1" by default
model.fit(noisy, epochs=200)
denoised = model.denoise(noisy)
print("VAF:", model.score(clean, denoised))
Use the JEPA backend for representation learning plus a denoising readout:
model = JAE(latent_dim=32, backend="jepa", patch_len=8, d_model=64)
model.fit(noisy, epochs=150)
denoised = model.denoise(noisy)
How it works
JAE1 (channel split). The recorded channels are partitioned into two disjoint sets. Both observe the same underlying low-dimensional signal, but the per-channel noise is independent across the partitions. Each partition is encoded and decoded by its own autoencoder, and the loss adds a term that pulls the two partitions' latents together:
C = MSE(X1, X1_hat) + MSE(X2, X2_hat) + ||Z1 - Z2||^2
Matching independent noise realizations is not a low-cost solution, so the model keeps only the shared, denoised structure. This is the Noise2Noise principle applied across channel subsets, and it is why a plain autoencoder without the split has no comparable pressure to reject channel-specific noise.
JAE2 (JEPA). A single shared encoder embeds both a masked "context" view and the full input. A small predictor guesses the embeddings of the masked region from the context, and the loss is computed in latent space (Smooth-L1), not signal space, so the model can discard unpredictable noise instead of reconstructing it. A VICReg variance/covariance term keeps the representation from collapsing. A lightweight decoder head turns the encoding into a denoised signal.
Evaluation
Denoising quality is measured as per-channel Variance Accounted For (VAF / R^2) against the clean ground truth, on a held-out test split, with matched latent dimensions across methods. The results are regime-specific by design:
- On linear data, PCA and Factor Analysis are near-optimal and beat JAE1 (a JAE win here would be a red flag).
- On nonlinear data, JAE1 beats PCA and Factor Analysis, and the margin grows with the strength of the nonlinearity, reproducing the paper's central finding.
The harness also runs negative controls (phase-shuffled and pure-noise data) to confirm the model does not invent structure that is not there. Run it with:
uv run python scripts/benchmark.py --quick # small, fast sweep
uv run python scripts/benchmark.py # fuller sweep
Package layout
| Module | Purpose |
|---|---|
pyjae.api |
JAE facade (fit / denoise / score / save / load) over both backends |
pyjae.models |
JAE1, JAE2, and shared encoder building blocks |
pyjae.views |
Modular channel-split and JEPA-mask strategies |
pyjae.data |
Simulator (Altan et al. generative model) and evaluation controls |
pyjae.metrics |
Per-channel VAF plus a collapse-resistant latent-quality panel |
pyjae.baselines |
PCA, Factor Analysis, denoising autoencoder, Wiener oracle |
pyjae.eval |
Non-gameable benchmark harness |
Requirements
- Python >= 3.10
- PyTorch >= 2.0, NumPy, scikit-learn, SciPy
Citation
@article{altan2021jae,
title={Estimating the dimensionality of the manifold underlying multi-electrode neural recordings},
author={Altan, Ege and Solla, Sara A. and Miller, Lee E. and Perreault, Eric J.},
journal={PLOS Computational Biology},
year={2021},
volume={17},
number={11},
pages={e1008591},
doi={10.1371/journal.pcbi.1008591}
}
License
MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyjae-0.2.0.tar.gz.
File metadata
- Download URL: pyjae-0.2.0.tar.gz
- Upload date:
- Size: 68.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99eedfbdd0c00dc9c1dccf7b1f5e6615aafcbd7bae66e0431fac81c35be4d518
|
|
| MD5 |
4b7dd7010c77b255d73807077f147063
|
|
| BLAKE2b-256 |
0d8334b049010854111d95761c0e4b435adf389c7e1022049cd4ea5dedb839b0
|
File details
Details for the file pyjae-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyjae-0.2.0-py3-none-any.whl
- Upload date:
- Size: 53.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d9b9170ba700fdf95c91788fdb68eb51605e324d187a0402cbced2b1a7b0e40
|
|
| MD5 |
48c149617d93152a7c2e31a802a17e51
|
|
| BLAKE2b-256 |
19bcbdef475303de0ce2700da2a9f2067b370741b24c7a0259909d7aa648748a
|