neural-encoder is a Python package for learning embeddings from repeated measurements and multiview data, designed for fMRI data or, more generally, high-dimensional noisy data. It provides linear and nonlinear encoders.
The methods are based on Platonic Representations in the Human Brain: Unsupervised Recovery of Universal Geometry. Originally developed for single-trial fMRI responses, they apply more generally to repeated or multiview measurements with a common feature space. They project noisy observations into a low-dimensional embedding that captures the signal shared across repetitions or views. The methods require repeated measurements during training, but work with individual measurements at inference time; multiple repetitions are not required for inference.
neural-encoder is developed by the Dynamics of Memory Formation (DMF) group at the University of Barcelona.
Via PyPI:
pip install neural-encoderor directly from GitHub:
pip install git+https://github.com/pablomm/neural-encoder.gitThe main class is NeuralEncoder, which combines feature reliability weighting, PCA, cross-view ridge denoising, distilled multiset canonical correlation analysis (MCCA), reliability weighting of the embedding dimensions, and nonlinear residual refinement.
It can be used with a single X_train matrix containing all repetitions and a sample_ids array containing the stimulus ID for each row. Rows with the same ID are measurements of the same sample.
from neural_encoder import NeuralEncoder
encoder = NeuralEncoder()
Z_train = encoder.fit_transform(
X_train, sample_ids=sample_ids,
)
Z_test = encoder.transform(X_test)Alternatively, pass the repeated measurements as separate, aligned views. Corresponding rows of X1, X2, and X3 represent the same sample.
from neural_encoder import NeuralEncoder
encoder = NeuralEncoder()
encoder.fit_views([X1, X2, X3])
Z1, Z2, Z3 = (encoder.transform(X) for X in (X1, X2, X3))
Z_test = encoder.transform(X_test)Preprocessing is applied separately. The complete fitted architecture can be exported to PyTorch:
model = encoder.to_pytorch()See the documentation for the full API and usage guide.
neural-encoder is licensed under the MIT License. See the LICENSE file for more details.
If you use this package in your research, please cite:
@misc{marcosmanchon2026platonic,
title = {Platonic Representations in the Human Brain: Unsupervised Recovery of Universal Geometry},
author = {Pablo Marcos-Manchón and Rishi Jha and Lluís Fuentemilla},
year = {2026},
eprint = {2605.20496},
archivePrefix = {arXiv},
primaryClass = {q-bio.NC},
url = {https://arxiv.org/abs/2605.20496}
}