Skip to main content

pAMICA: Adaptive Mixture ICA

CI codecov DOI Docs status

Python (PyTorch) implementation of Adaptive Mixture Independent Component Analysis (AMICA) that reproduces the reference Fortran implementation within numerical tolerance, with CPU, NVIDIA GPU (CUDA), and Apple GPU (MLX) support. It targets EEG/EMG blind source separation and is a drop-in replacement for EEGLAB's AMICA: single-model output is written in exactly the reference's on-disk format and loads directly in EEGLAB.

Single-model results match the Fortran reference (Hungarian-matched component correlation ~ 0.998 on well-determined data, Newton disabled); see the documentation for validation details and the backend-selection guide.

Overview

AMICA (Adaptive Mixture ICA) is an advanced blind source separation algorithm that uses adaptive mixtures of independent component analyzers. This implementation provides:

  • Multiple source models
  • Different PDF types
  • Newton optimization
  • Component sharing
  • Outlier rejection
  • Data preprocessing (mean removal, sphering)

Installation

The canonical environment is uv:

git clone https://github.com/sccn/pAMICA.git
cd pAMICA
uv sync                     # install dependencies into a managed venv
uv run pytest               # optional: run the tests

The optional Apple-GPU backend (MLX, Apple Silicon only) installs with the mlx extra: uv pip install mlx.

Usage

pamica exposes a scikit-learn-style estimator backed by the PyTorch natural-gradient EM implementation:

import numpy as np
from pamica import AMICA

# X is (n_channels, n_samples) of real EEG/EMG; float64 gives Fortran parity
model = AMICA(n_models=1, n_mix=3).fit(X)

sources = model.transform(X)       # (n_sources, n_samples)
A = model.get_mixing_matrix()      # sensor-space scalp maps
order = model.variance_order()     # EEGLAB IC order (IC1 = highest variance)

Backends and precision

The wrapper auto-selects a device and computes in float64 for Fortran parity.

  • CPU and CUDA (float64) are bit-reproducible; use them for parity runs.
  • float32 (about 7 significant digits, not parity) is required on the Apple GPUs and modestly faster on CPU; it is not a general speedup, since CUDA is overhead-bound (float32 is about as fast as float64).
  • On Apple Silicon the MLX backend is the fastest option; import it explicitly.
AMICA(device="cuda").fit(X)               # NVIDIA GPU, float64
from pamica.mlx_impl import AMICAMLXNG    # Apple GPU (install the mlx extra)

EEGLAB interoperability

pamica writes results in EEGLAB's AMICA output format, so a run drops into an EEGLAB workflow with no manual re-ordering or sign-flipping:

model.write_amica_output("amicaout")   # gm, W, S, mean, c, alpha, mu, sbeta, rho, ...
mod = loadmodout15('amicaout');   % components in EEGLAB variance order

Legacy NumPy CLI

The NumPy reference backend keeps a JSON-driven command-line interface:

python -m pamica.numpy_impl.cli params.json --outdir results

See the documentation for the full API, the parameter reference, and the backend-selection and validation guides.

Citation

If you use pamica, please cite it (see CITATION.cff) and the original AMICA method:

Palmer, J. A., Kreutz-Delgado, K., & Makeig, S. (2012). AMICA: An adaptive mixture of independent component analyzers with shared components. Technical report, Swartz Center for Computational Neuroscience, UC San Diego.

License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

Release files for pamica 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pamica 0.3.3
File Size Uploaded
pamica-0.3.3.tar.gz 214.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pamica 0.3.3
File Interpreter ABI Platform
pamica-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 440.6 kB

Release files / pamica-0.3.3.tar.gz

Download URL pamica-0.3.3.tar.gz
Size 214.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b277319eea3a044af1c68cfb657a27fb03ceb89095da30659ec32a3599abd11a
BLAKE2b-256 checksum
How to use checksums
8d144234f6505aa22cf61436af705bb206cb96656b750ae92397127fed3ce9cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 1, 2026.

Transparency log

Release files / pamica-0.3.3-py3-none-any.whl

Download URL pamica-0.3.3-py3-none-any.whl
Size 225.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1852b0ff30d66631c3261756be349baf0351635b114c2c89caf69e507a78048
BLAKE2b-256 checksum
How to use checksums
1db9ac185d5d3cb70f8acb76c50815c3440b7c14be96a20b4bf8abe2d503a002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 1, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release 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