Skip to main content

jamica - Adaptive Mixture Independent Component Analysis, powered by JAX

JAX-accelerated Adaptive Mixture Independent Component Analysis for Python.

CI Docs Codecov PyPI - Version conda-forge Python Versions License DOI

jamica is a JAX implementation of AMICA (Adaptive Mixture Independent Component Analysis), an algorithm for blind source separation. It is aimed mainly at EEG.

AMICA is one of the strongest methods in the ICA family for EEG decomposition. The original implementation is a Fortran program from UCSD, usually run through MATLAB or EEGLAB. jamica rewrites it in Python on top of JAX, so the same code JIT-compiles and runs on either CPU or GPU, and it works directly with MNE-Python.


Why jamica?

JAX + AMICA = jamica. The name also describes the problem AMICA solves.

Record a jam session with a few microphones. Each one picks up a different blend of the same players. Getting the individual instruments back out of those recordings is blind source separation, which is what ICA does for EEG: electrodes pick up mixtures of cortical, muscular and ocular activity, and the job is to pull them apart again.

A jam is rarely one fixed mixture, though. Players drop in and out. Someone takes a solo. The statistics of what the microphones hear keep shifting. AMICA handles this by fitting several mixture models instead of one, and by learning the shape of each source distribution rather than assuming it. That makes it a good match for data a single stationary ICA model does not describe well.

jamica runs that algorithm on JAX, on CPU or GPU, inside the usual Python scientific stack.

Status: jamica reproduces the Fortran AMICA 1.7 reference on the tested single-model configurations. See Validation.


Highlights

  • The AMICA algorithm in Python, JIT-compiled through JAX
  • Runs on CPU or GPU without changing your code
  • Numerical agreement with the Fortran AMICA 1.7 reference on the tested configurations
  • Native integration with MNE-Python
  • Support for multi-model AMICA
  • Modern scientific Python API
  • Extensive testing and continuous integration
  • Fully open source (BSD-3-Clause)

Installation

pip install "jamica[jax]"

or, from conda-forge:

conda install -c conda-forge jamica jax

Renamed from amica. Releases up to 0.1.0 were published as amica. That name installed a top-level amica module, which collided with amica-python — an independent implementation of the same algorithm by another author — so the two could not coexist in one environment. Since 0.2.0 this project installs as jamica, and the two can be installed side by side.

For NVIDIA GPUs, take the CUDA build of JAX instead:

pip install "jamica[gpu]"        # JAX with CUDA 12 (Linux only)

The other extras are separate, so you only install what you need:

pip install "jamica[mne]"        # MNE-Python integration, fit_ica()
pip install "jamica[icalabel]"   # ICLabel component classification
pip install "jamica[viz]"        # plotting and density diagnostics
pip install "jamica[all]"        # everything above

From source

For development, or to run the test suite:

git clone https://github.com/snesmaeili/jamica.git
cd jamica
pip install -e ".[dev]"

With uv:

git clone https://github.com/snesmaeili/jamica.git
cd jamica
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]"

Quick Start

from jamica import Amica, AmicaConfig

config = AmicaConfig(
    max_iter=2000,
    num_mix_comps=3,
)

model = Amica(config, random_state=42)

result = model.fit(data)

sources = model.transform(data)

For MNE-Python:

from jamica import fit_ica

ica = fit_ica(raw)

ica.plot_components()
ica.apply(raw)

For integrations that already whiten and PCA-reduce their data, jamica.amica is the stable single-model solver boundary:

from jamica import amica

_, W, sources, n_iter = amica(
    X_ica,
    whiten=False,
    return_n_iter=True,
    random_state=42,
)

Here X_ica is shaped (n_components, n_samples), sources == W @ X_ica, and JAMICA performs no additional centering, whitening, or PCA. Multi-model adaptive ICA and its model probabilities remain available through the native JAMICA API rather than this conventional-ICA boundary.

See the MNE single-model solver contract for the exact matrix, preprocessing, random-state, and error guarantees.


Examples

Example scripts are available in the examples/ directory, including:

  • MNE-Python integration
  • Native AMICA API
  • JAX acceleration
  • Multi-model AMICA
  • HPC / SLURM execution

Documentation

Full documentation, API reference, validation experiments, and tutorials are available at

https://snesmaeili.github.io/jamica/


Validation

jamica reproduces the Fortran AMICA 1.7 reference on single-model fits: final log-likelihoods, unmixing matrices and adaptive-density parameters agree closely across K=1 and K=3 density terms, under both Newton and natural-gradient updates, and on a 100-iteration audit on real EEG.

Protocols, the patched reference build, comparisons against other AMICA implementations and against Picard, extended Infomax and FastICA, and every figure and table in the manuscript are in jamica-benchmark. Exact scope is in the documentation.


Contributing

Contributions are welcome!

Please read CONTRIBUTING.md before opening a pull request.

Parts of jamica were written with AI assistance; AI_USAGE.md says where, and what it does not change about how the package is verified.


Citation

If jamica contributes to your research, please cite the original AMICA publications.

Citation metadata is available in CITATION.cff.


License

jamica is distributed under the terms of the BSD 3-Clause License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jamica-0.3.0.tar.gz (139.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jamica-0.3.0-py3-none-any.whl (101.7 kB view details)

Uploaded Python 3

File details

Details for the file jamica-0.3.0.tar.gz.

File metadata

  • Download URL: jamica-0.3.0.tar.gz
  • Upload date:
  • Size: 139.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for jamica-0.3.0.tar.gz
Algorithm Hash digest
SHA256 06ee3a5b8aee630bddd2edb2d59412c309b0a37882ec5ee2cc8d1bf7d6aa8094
MD5 985952615dcf65f5af9fb11fa525b246
BLAKE2b-256 0c4f46f4e38f0904fa794541fdc5225d78c9f2d8947296eb98452eba83da19ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for jamica-0.3.0.tar.gz:

Publisher: release.yml on snesmaeili/jamica

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jamica-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: jamica-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 101.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for jamica-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a185ed9a847512bcf2250e47b2b154f471ad8b9f93373eea08bff2eb4c5a8f1d
MD5 1d0a78c169a7565a1f4d170e65135837
BLAKE2b-256 46f357e3401b6041d91af95346883513802ef62843ffee206e368d5cc89eadf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for jamica-0.3.0-py3-none-any.whl:

Publisher: release.yml on snesmaeili/jamica

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page