pyamica
PyTorch implementation of AMICA (Adaptive Mixture Independent Component Analysis).
AMICA fits a mixture of ICA models to multi-channel time-series data. Each model has its own unmixing matrix and source densities; a per-sample posterior indicates which model most likely generated each data point. This makes it well-suited for EEG recordings where different experimental conditions have different source statistics.
Install
pip install pyamica # core (no MNE)
pip install "pyamica[mne]" # with MNE-Python integration
With uv:
uv add pyamica
uv add "pyamica[mne]"
Quick Start
import torch
from pyamica import AMICA, AmicaICA
# Low-level PyTorch API - X shape: (T, n_channels), float64
model = AMICA(n_models=2, max_iter=200, device="cuda")
model.fit(X)
print(model.gm_) # global model weights
print(model.posteriors_) # (n_models, T) per-sample posteriors
# MNE-Python wrapper
ica = AmicaICA(n_models=2, max_iter=200, device="cuda")
ica.fit(raw, picks="eeg")
ica.plot_model_dominance(smooth_s=1.0)
for m in range(ica.n_models):
ica.review(raw, model_idx=m, eog_ch=["HEOG", "VEOG"], ecg_ch="ECG")
ica.apply(raw)
Background
pyamica is a pure Python reimplementation of AMICA built on PyTorch, with an
MNE-Python wrapper to make it usable in modern EEG pipelines. It runs on CPU
and GPU alike and slots in wherever mne.preprocessing.ICA would be used.
It started as a weekend project and a practical test of LLM-assisted code translation from the original Fortran implementation (sccn/amica). The translation was supported by Claude Sonnet 4.6 with a lot of back-and-forth, and turned out good enough (I think) to publish.
All credit for the algorithm, theory, and original implementation goes to Jason A. Palmer and the SCCN team. The canonical reference is:
Palmer, J. A., Kreutz-Delgado, K., & Makeig, S. (2012). AMICA: An Adaptive Mixture of Independent Component Analyzers with Shared Components. Technical Report, UC San Diego. [PDF]
The AMICA introduction on their wiki covers what it does, why it works, and how to interpret multi-model fits.
Development Install
git clone https://github.com/DerAndereJohannes/pyamica
cd pyamica/
pip install -e ".[mne,dev]"
With uv:
git clone https://github.com/DerAndereJohannes/pyamica
cd pyamica/
uv sync --extra mne --extra dev
Tests
# fast tests (synthetic data only)
pytest tests/ -v -m "not slow and not gpu"
# with coverage
pytest tests/ -v -m "not slow and not gpu" --cov=pyamica
# Fortran comparison (requires data/ directory)
pytest tests/ -v -m slow
With uv:
uv run pytest tests/ -v -m "not slow and not gpu"
Acknowledgements
This repository includes the pre-compiled amica15ub binary and default
parameter file from the AMICA project by
Jason Palmer and contributors, used here for development and testing only.
They are not distributed as part of the installable package.
That binary is licensed under the BSD 2-Clause License; see
LICENSES/sccn-amica.txt for the full license text.
Metadata
Release files for pyamica 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyamica-0.3.0.tar.gz | 65.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyamica-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 99.6 kB
Release files / pyamica-0.3.0.tar.gz
| Download URL | pyamica-0.3.0.tar.gz |
|---|---|
| Size | 65.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
508947247a8963a048f8506f72a3cc54c1f28269fab286f917b9dab597b4e022
|
|
BLAKE2b-256 checksum How to use checksums |
0bcff18b03179256131e02723701da53e1a9ce5907426d0c39392922be5a1f17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 15, 2026.
Transparency logRelease files / pyamica-0.3.0-py3-none-any.whl
| Download URL | pyamica-0.3.0-py3-none-any.whl |
|---|---|
| Size | 33.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb96ba9c5975fefafaba337a99f8f9780397f0020e71d96bca05e5667799c91c
|
|
BLAKE2b-256 checksum How to use checksums |
d475340505fa807be8d9394287530de1074c80bdbce890d5c692564e11aa3e3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 15, 2026.
Transparency log