Repository navigation
Description
Describe the new feature or enhancement
AMICA (Adaptive Mixture ICA) ranked first out of 22 ICA algorithms for EEG source separation in Delorme et al. (2012, PLoS ONE), producing the most near-dipolar independent components. Despite this, it has never been available in MNE-Python because it only existed as a GPL-licensed Fortran binary (discussed in #1715).
I've now built a pure Python/JAX, BSD-3-licensed implementation that removes this blocker:
- Package: amica-python
- License: BSD-3-Clause (MNE-compatible)
What AMICA adds over existing methods
- Adaptive mixture source models — each source modeled as mixture of generalized Gaussians, capturing both super- and sub-Gaussian distributions (Infomax/Picard assume fixed density)
- Newton optimization — quadratic convergence after natural gradient warm-up (Palmer et al. 2008)
- Sample rejection — automatic outlier downweighting for robust decomposition (Klug et al. 2024)
- Optional GPU acceleration via JAX — 12.5s for 30 components on 118-channel EEG on A100 (vs ~170s for Picard on CPU)
- Multi-model ICA — can learn multiple unmixing matrices for non-stationary data
Validation
Numerical parity with MATLAB AMICA 1.7:
| Config | LL diff | W correlation |
|---|---|---|
| m=1, Newton | 0.0002% | >0.999 |
| m=3, Newton | 0.00008% | >0.999 |
Source separation (Amari index, synthetic):
| Method | Amari Index |
|---|---|
| AMICA | 0.008 |
| FastICA | 0.010 |
| Infomax | 0.195 |
Now I am validatating and debuging it with Real EEG (ds004505, 118ch dual-layer): for now we have Reconstruction error ~1e-15, ICLabel-compatible, full MNE ICA object returned (plot_components, apply, get_sources all work needs fine tuning and some debugging )
Current MNE integration
Already working as standalone package:
from amica_python import fit_ica
ica = fit_ica(raw, n_components=20, max_iter=2000)
ica.plot_components() # standard MNE ICA object
ica.apply(raw)And a Picard-compatible functional API ready for direct integration:
from amica_python import amica
W, n_iter = amica(X, whiten=False, return_n_iter=True, random_state=42)Describe your proposed implementation
Following the exact Picard integration pattern in mne/preprocessing/ica.py.
elif self.method == "amica":
from amica_python import amica
W, n_iter = amica(
data[:, sel].T,
whiten=False,
return_n_iter=True,
random_state=random_state,
**self.fit_params,
)
self.unmixing_matrix_ = W
self.n_iter_ = n_iterUsers would use:
ica = mne.preprocessing.ICA(method='amica', fit_params=dict(num_mix=3))
ica.fit(raw)amica-python would be an optional dependency (like python-picard), installed separately via pip install amica-python. JAX is optional within amica-python — it falls back to NumPy automatically if JAX isn't installed.
I'm happy to submit a PR implementing this if the maintainers are open to it. I'd include:
- Method dispatch in
ica.py - Tests following the existing ICA test patterns
- Documentation updates (docstrings, what's new entry)
- Example comparing AMICA vs Picard vs Infomax
Describe possible alternatives
-
External-only package (current state): Users install
amica-pythonand usefit_ica(raw)which returns a standardmne.preprocessing.ICAobject. This already works but requires users to know about the package — it won't appear in MNE's documentation orICA(method=...)interface. -
MNE plugin/extension system: If MNE develops a plugin system for ICA methods in the future, AMICA could register through that. But no such system exists currently.
-
Contribution to mne-icalabel or mne-connectivity: AMICA could live as an MNE-affiliated package rather than being integrated into core MNE. However, ICA methods are core functionality, and the Picard precedent shows direct integration is preferred.
The direct integration (option in the main proposal) is preferred because:
- It follows the established Picard pattern exactly
- Users discover it through MNE's standard API
- The heavy lifting stays in the external
amica-pythonpackage
Additional context
- Author: Sina Esmaeili, PhD student at Universite de Montreal (CoCo Lab, Karim Jerbi). M/EEG signal processing, also author of mne-denoise.
- Why now: The original issue Add support for AMICA (modern ICA distributed as binary)? #1715 (2014) was blocked by GPL licensing. This pure Python reimplementation with BSD-3 license resolves that.
- Ongoing validation: Currently running multi-subject benchmarks on ds004505 (Studnicki 2022, 25 subjects, 118-channel dual-layer EEG) comparing AMICA vs Picard vs Infomax vs FastICA with multiple metrics (ICLabel, kurtosis, MIR, PSD analysis).
Key references
- Palmer et al. (2011) — AMICA technical report
- Delorme et al. (2012) — AMICA ranked fix time units (s->ms) in examples/inverse/plot_label_source_activations.py #1 of 22 ICA algorithms (PLoS ONE)
- Frank et al. (2023) — Optimal AMICA parameters (IEEE BIBE)
- Klug et al. (2024) — Sample rejection (Scientific Reports)
Activity
welcome commentedon Apr 6, 2026
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴
scott-huberty commentedon Apr 6, 2026
Nice work!
Full conflict of interest disclosure: I maintain a Python implementation of AMICA (even the same package name 😆 ), It was related to my PhD. So I'll try to keep my comments focused only on MNE consideration, from my perspective as an MNE community member.
Tl; DR : My vote is option 1 (for now).
I think AMICA is clearly very valuable to the EEG community. From an MNE perspective, though, I think the question is more about when and how any single implementation would meet the bar for inclusion, e.g. evidence of stability, sustainability, correctness, and some degree of community adoption.
It's also worth noting that AMICA is generally much more computationally and memory intensive than methods like Infomax, both in terms of runtime and convergence behavior: Locally for me, AMICA is over 10x slower than MNE's infomax. Many AMICA intermediate operations scale with both
n_samplesandn_mixtures, so a1GibEEG file can lead to3Gibintermediate arrays, and>10Gibpeak memory if one is not careful. I bring this up because these will affect MNE user experience and I think that we would want to have a good idea of how it performs with real use cases.After a quick search, it seems like there are now a few Python implementations of AMICA on GitHub, including one from one of the SCCN staff. It may be worth letting these mature & stabilize on their own to see where things land wrt the aforementioned considerations. independence from MNE would let these develop faster (MNE has a relatively high bar for stability and backwards compat), and this would allow MNE the time to asses the tradeoffs across approaches before committing to one specific implementation (if any).
BabaSanfour commentedon Apr 7, 2026
Thanks for your feedback @scott-huberty ! We are aware that some people have been working on but did not check who ahah. When we started, most were not there, but it's not the first time that many people work on the same thing on parallel.
We haven't benchmarked against any of these, as we have been working on the AMICA for two years now for several projects we have in the lab (It was In a public repo then we went private) and a whole ecosystem we are developing.
@snesmaeili's initial idea and our supervisor pushed for having it as part of another package we are building, mne-denoise, or something similar while I pushed more for this option of having it used like picard. For me it was the cleanest and easiest, this is why we did not go public with it until now. However, I understand your concerns and some of them are valid.
Anyone who is running an AMICA should be fully aware of its constraints, plus it has its use cases so it will not be the default for mne. And this is why we went with JAX and not another idea, it gives us better speed + efficiency. The implementation we have proved to be faster than infomax. For memory, we can run checks and provide numbers too.
It would be the same as picard, which also takes ages to run. People would have to install it on their own also.
in that case and if the core team of mne thinks the same. We could just add it to mne-denoise for the time being, as it's just another denoising method. What do you think @snesmaeili ?
snesmaeili commentedon Apr 7, 2026
Thanks @BabaSanfour for jumping in and putting the lab context on the record , that saves me writing the long version of the same thing :)))
To answer your direct question: yes, I think mne-denoise is a good interim home, and I'd pair it with keeping amica as the standalone algorithm package.
On the technical side, adding some concrete numbers to what Hamza said, I am doing a ds004505 benchmark (Studnicki 2022, 118ch dual-layer EEG) in progress, AMICA vs Picard vs Infomax vs FastICA scored with ICLabel and quality metrics. Multi-subject results will land in this thread when they're done.
-Sina
drammock commentedon Apr 7, 2026
let's wait for the benchmark results, but for me I think "separate package with picard-like API" is actually a sweet spot:
The main question is: if we're going to adopt a "blessed" AMICA implementation by wrapping it in the MNE-Python API (like we did with picard), which (of the apparently many!) AMICA implementations do we go with? Benchmark should help us pick, but other things matter too (API, license, best guess at long-term support status, install footprint).
cbrnr commentedon Jun 24, 2026
I would also prefer to not add any AMICA package to MNE for now, as it seems pretty easy to use the package directly. I'm also very interested in benchmarks.
In my experience, Picard is very fast. A typical decomposition (64 channels, about 30 minutes of data) takes around 15-30 seconds. This is certainly slower than FastICA or Infomax, but I wouldn't call it ages.
I'm also open to integrating AMICA into MNELAB, where I don't really care if it is available directly in MNE-Python or not. If you want, feel free to submit a PR.
Regarding the algorithm, the biggest benefit of AMICA over other ICA algorithms is that it supports multiple models for non-stationary data and therefore also yields the most probable model for every time point. How can we use this feature in MNE-Python? Do you return multiple ICA objects along with probabilities? If this feature is not available, I don't think there are huge improvements over Extended Infomax, as also mentioned in Delorme et al. (2012)
snesmaeili commentedon Jun 24, 2026
Thanks @cbrnr , and you're right about Picard. "Takes ages" was an overstatement on our side; ~15–30 s for 64 ch / 30 min is a fair baseline, and AMICA is clearly the heavier method. Quick update, since the benchmark is essentially done and we're getting the preprint ready to submit.
Here are few results from the benchmark we did:
amica-python vs Picard / extended Infomax / FastICA, on three OpenNeuro datasets (ds004505 table-tennis task; ds004504 19-ch resting; ds004621 128-ch resting), all from raw recordings with identical 1–100 Hz + per-site-notch + 250 Hz preprocessing, PCA→N, scored with the Frank (2022) MIR rate, remnant pairwise MI, ICLabel, and dipolarity:
On the multi-model point — the most important thing you raised, and I agree with your framing. The real differentiator over Extended Infomax is the mixture of M>1 ICA models with a most-probable model per time point. Our solver does fit the multi-model case
M unmixing matrices W⁽ʰ⁾, per-model centres/densities, and the posterior model time-course p(h|t). Example below: p(h|t) segmenting a task and a resting recording into temporal regimes (demonstration of the capability).
The MNE-facing exposure is exactly the open question, and it's what we're finalising now. An
mne.preprocessing.ICAholds a single unmixing matrix, so it can't natively represent M models. The approach we're implementing:fit_ica(raw, num_models=M)returns a standardICAfor the highest-weight model (soplot_components/apply/get_sourceskeep working), with the full multi-model result + p(h|t) attached and aget_model_ica(ica, h)helper to pull any model out as its ownICA. That's a workaround, not a native representation — and that's the piece we'd love to design with you: e.g. a small container holding the MICAobjects + the posterior array, or returning(list_of_ICA, posteriors).The amica-python repo is private for now since we are using one of the branches to save the benchmarking results for the paper. It will be released as soon as we submit the preprint.
Scope-wise I'm with @drammock : not asking for AMICA in MNE core: "separate package + picard-like API" is what we target, and amica-python already exposes that. The multi-model representation is the one piece that needs an MNE-side convention, which is why I wanted to surface it. Preprint + full per-subject tables + a reproduction capsule will be linked when posted.
Thanks all for the thoughtful triage.
— Sina
larsoner commentedon Jun 24, 2026
No opinions on ICA from my end... but to move forward I would suggest to follow the standard ideal "add to related software" path
amica-pythonoutmne-installersand CircleCIdoc/related_software.txtOnce that's done, as part of (4) you could add
amica-pythonto the core ICA tutorial or some other example/tutorial to advertise its utility (with relevant references). If warranted, could be a separate tutorial / example -- but if AMICA is better in some circumstances than existing other methods like Picard, it seems worth mentioning in the core tutorial since that's where people can hopefully learn some stuff about how to use ICA properly.sappelhoff commentedon Aug 7, 2026
I agree with Dan's comment:
--> an integration like done with picard would be easiest in terms of user convenience and mne maintenance burden / development speed.
I also agree that we need to let the (currently)
34 python AMICA implementations mature a little and see which one has an edge over the other ones. It would of course be much much better to join forces. But I understand that everyone also has their own agendas (progress as part of a phd project, EEGLAB integration, specific points in the algorithm they find more or less important, etc.).cc @neuromechanist @DerAndereJohannes FYI
also cc @jona-sassenhagen maybe you are still interested in this
cbrnr commentedon Aug 7, 2026
I would also be interested in runtime comparisons across the three AMICA packages (plus some reference implementations and other popular algorithms such as PICARD). In particular, I think CPU runtime is still the most important metric, as many users will not have access to suitable GPUs. Being two orders of magnitude slower on CPU is therefore not really ideal, and I would look into the usual ways of speeding up Python code, such as using a C extension or Numba. That should yield a significant speedup (probably not as much as running on a GPU), and it would make the implementation more useful to a broader audience. @scott-huberty do you have numbers for AMICA-Python?
drammock commentedon Aug 7, 2026
I think we never really addressed this question. Flagging so we don't lose track of it; let's plan to talk about this at the sprint.
BabaSanfour commentedon Aug 7, 2026
@cbrnr i disagree with you on this point. With the AI boom most labs/universities have access to dedicated resources/clusters and powerful compute. So a GPU compute time is as important as CPU; if not more. And the main idea behind all packages is making it faster which requires by default a GPU.
To add, the trend now is collecting large datasets with more subjects and time per subject.. (meta initiative, recent advances in foundation models) .. with the amount of data being collected.. you need the proper resources anyway. CPU runtime only as a metric does not make sense.
k-jerbi commentedon Aug 7, 2026
I would say we definitely need benchmarking on both CPU and GPU. Both have their users and use cases.
The rise of foundation models for neuroscience and massive pretraining on substantial amounts of brain data (eg. EEG from 25,000 subjects in our recent REVE model) is just one of the ways our field is evolving in this direction.
Bottom line, CPU and GPU are both relevant. Love and peace! ☮️😄
cbrnr commentedon Aug 7, 2026
I did not say CPU runtime should be the only metric, but especially in the field of EEG analysis, most people do not have access to good GPUs. Even if many universities have access to some sort of compute clusters with GPUs, accessing this resource is not straightforward as running a quick computation on my local machine, which might not have a dedicated or fast enough GPU.
So if I see an algorithm taking 300x longer compared to other popular ICA algorithms, my first thought is that there has to be room for optimization and not just rely on users running it on GPUs.
So yes, both CPU and GPU are relevant and I'd like to see some more extensive comparisons.
drammock commentedon Aug 7, 2026
I don't think we have insight into what fraction of our users have access to such resources. For example, at my institution there is plenty of managed compute available (including GPU), but it's not free to use: I think students get a small quota for free (for coursework), but faculty/staff are pay-per-use, meaning if you don't have a grant (or didn't budget for compute in your grant) you may be stuck running things on laptops (or waiting a year or more until you have funding to pay for it).
And at least some of our users are not at top-tier universities; they can use commercial cloud-compute services, but again there's the question of who pays for it. So echoing what @k-jerbi just said: CPU and GPU benchmarking both matter.
k-jerbi commentedon Aug 7, 2026
We should also keep in mind that the availability /accessibility of GPUs to students and researchers might dramatically change over the next couple of years.
cbrnr commentedon Aug 7, 2026
So you don't think optimizing the CPU path is worthwhile at all?
k-jerbi commentedon Aug 7, 2026
Optimization is always worthwhile (and it is on our to-do list) 😄
It is nested in a bigger optimization problem which is around optimizing time management, prioritizing tasks, and bandwidth, and distinguishing side projects from the central projects of our lab members 🤓
So short answer, definitely up for optimizing CPU runtime, as that has its own important target users, it will just take time, and/or support from the community.
I think (hope) we are all on the same page here.
cbrnr commentedon Aug 7, 2026
Sure. But there are now four competing AMICA packages for Python, and you are asking us to pick one (if only to be mentioned in the docs). We cannot do that right now and need more data, and for me runtime on both CPU and GPU is important. It's easy enough to test, so can you post code to reproduce the benchmark you mentioned above? We can then use it to test the other three packages as well.
scott-huberty commentedon Aug 7, 2026
benchmarking aside, from a maintenance perspective I would probably lean towards the SCCN implementation (they are the algorithm founders and also maintain the Fortran version). I did not know that they had a Python implementation.
cbrnr commentedon Aug 7, 2026
Yes, this would also be my first thought. But if one of the other packages is either way faster or easier to use or has some other advantages, I'd still be open for alternatives. But again, the real solution would be to bring the developers of those four packages together to create one canonical AMICA package.
k-jerbi commentedon Aug 7, 2026
Thanks Clemens for offering this!
I just spoke with Sina, Hamza and Yorguin.
We will definitely get back to you on this next week. In the meantime we will look into running some additional benchmarking tests on our end (we have in fact already done a series of comparison tests) as well as discussing strategies for cpu runtime optimization).
More soon!
DerAndereJohannes commentedon Aug 7, 2026
Before seeing any benchmarks, I would lean towards this too. The implementation that you found under my profile was mostly a weekend project where I wanted to test how well you could translate Fortan into python using Claude (AI disclaimer is also in the repo). I have done testing on it myself and the models look reasonable. I did read through the original paper and Fortran code more carefully to make sure that it is doing the right thing. Of course, I cannot guarantee anything though ;-)
However, I think the SCCN implementation would probably be the most supported due to the nature of the source account. I did however submit an issue a couple weeks ago with no response so far, but it could just be that they are on holiday. One thing to note is that based on a quick look of the repo, it could also be mostly a Claude rewrite (please do correct me if I am wrong) without any AI disclaimer. They do seem to have more robust validation though.
Happy to help with any sort of validation or reviews in the meantime. GPU wise I have a 5000 series RTX card with 16GB RAM and could also do macos based tests. Just note that apple MPS/MLX does not support 64bit float on the GPU.
neuromechanist commentedon Aug 9, 2026
Thanks for the pointer, @sappelhoff.
On scope I agree with @drammock and @cbrnr: AMICA doesn't belong in MNE core. It's a different and heavier algorithm, and a separate package with a Picard-like API is the right shape. As long as the output is compatible it's easy to import, and MNE's maintenance surface stays flat.
We'll maintain pAMICA because we need it:
sccn/eegprepand nemarOrg projects (not yet public) use it as their AMICA step.On @cbrnr's CPU point, I'd frame it a bit differently. The reference implementation is already Fortran on BLAS, about as close to the metal as this algorithm gets; on the same machine it runs ~70 ms/iteration against ~193 for our PyTorch CPU path. I don't expect a Python port to beat that, so rather than try to out-run it we ship it: pAMICA distributes the reference Fortran as a dependency-free build for macOS, Linux, and Windows, with no MKL or MPI runtime and no compiler toolchain. That gives a fast CPU path to people without a GPU, which I think is what's actually being asked for. GPU support isn't only about speed either: our MLX backend means someone can experiment with AMICA on a Mac.
On cross-package benchmarking: nice to have, but I wouldn't gate anything on it. We each benchmark our own, and cross-package numbers are easy to get wrong in ways that flatter whoever ran them. If someone does run one, what would make it credible is a public dataset anyone can pull. We use the Wakeman & Henson face-processing data: on002718 for the EEGLAB-ready EEG, and on000117, whose MEG files carry EEG and MEG together, for anyone wanting to take this past EEG. Low noise, long recordings, already public.
On @drammock's multi-model point, it is quite significant: returning the highest-weight model as the
ICAis wrong for this algorithm, not just lossy. In Hsu et al. (2018), Modeling brain dynamic state changes with adaptive mixture independent component analysis, NeuroImage 183:47-61, the separate models correspond to distinct cognitive states, and the sleep-staging and drowsiness results come out of exactly the models a highest-weight rule discards. The non-dominant models are the result, not overhead.So our wrapper keeps all M.
model_idxselects the model on every consumer method (get_sources,plot_components),to_mne_ica(model_idx=h)returns a standardICAfor any one of them, and the per-sample posterior is exposed asget_model_probability(raw), shape(n_models, n_samples), since MNE has no concept for it. Same for the fieldsICAlacks: source-density families, generalized-Gaussian shape, shared components. Documented at eeglab.org/pAMICA/api/mne-compat.One thing worth being precise about, since multi-model came up as the main advantage over Extended Infomax: what the mixture models is soft segmentation into a finite set of stationary regimes, rather than continuous adaptation. That's still a meaningful difference from a single fixed model, just a narrower claim than "non-stationary data" might suggest.
As for how that maps onto MNE, I don't have a strong view on the right shape. Our version keeps the models and the posterior on our own object, which works but doesn't compose with code that expects an
mne.preprocessing.ICA. Whether that's better solved byICAcarrying multiple models and a posterior, or by a small container holding several of them, seems like a good question for the sprint. Happy to help either way.neuromechanist commentedon Aug 10, 2026
Correction to my numbers above, in a direction that matters for @cbrnr's CPU question.
I said PyTorch CPU runs at ~193 ms/iteration and PyTorch-Metal at ~255, and that Metal never beats the CPU beside it. Those figures were measured at our default
block_sizeof 512, and it turns out that default is badly tuned for this workload. Sweeping it on an M4 Pro, same real 32-channel EEG, float32, same seed:Log-likelihood is unchanged to six significant figures across all of these, so it is purely a throughput knob.
Three things I got wrong:
What holds: MLX remains the fastest Apple backend, and the native Fortran build remains a fast CPU path needing no GPU or toolchain.
The underlying mistake is worth naming, since it applies to cross-package benchmarking generally: I compared backends with a parameter pinned to one value, while their sensitivity to that parameter differed by more than an order of magnitude. Anyone benchmarking these implementations against each other should sweep block size per implementation rather than fixing it, or the comparison mostly measures whose default happens to suit the test.
Tracked on our side as sccn/pAMICA#216.
k-jerbi commentedon Aug 24, 2026
Thanks everyone for the suggestions and feedback!
It took us a bit more time than initially planned, but we're happy now to report a few significant updates, and to address a few key points from the discussion above:
• MNE integration: from our side, the Picard-style single-model integration path is ready. The remaining open question is how to expose multi-model AMICA in MNE; TBD at the sprint.
• Name update: we renamed the package to jamica (JAX-powered AMICA) to avoid confusion and naming conflicts with existing AMICA Python packages.
• Performance benchmark: following the feedback here, we took some time to substantially improve the CPU runtime and reran the cross-implementation benchmark using the latest Git versions of each implementation, with fixed iteration budgets and early stopping disabled. At the fastest tested settings on ds004505, jamica is the fastest GPU implementation (~60 s), while the Python implementations are much closer on CPU (~9–11 min). Memory varies with chunk size, with jamica becoming increasingly competitive at larger chunks.
Quick Overview (TLDR:) concise overview with the main CPU/GPU runtime and memory results and figures:
https://htmlpreview.github.io/?https://github.com/snesmaeili/jamica-benchmark/blob/main/benchmark/comparator/results/xperf_chunksize/xperf_chunk_tldr_standalone.html
Detailed Report full figures and results across chunk sizes:
https://htmlpreview.github.io/?https://github.com/snesmaeili/jamica-benchmark/blob/main/benchmark/comparator/results/xperf_chunksize/xperf_chunk_report_standalone.html
For use:
PyPI: done — jamica is released on PyPI.
Repository: https://github.com/snesmaeili/jamica
Reproducible benchmark: https://github.com/snesmaeili/jamica-benchmark
conda-forge: done.
As you might notice, we also now have an official logo (hinting to the jam session analogy, as jam sessions are in realty "an adaptive mixture of independent" musicians!).
Looking forward to hearing back + sending positive vibes for the Meta/MNE sprint!
snesmaeili commentedon Aug 24, 2026
Following up on the multi-model API question that @cbrnr raised, and on @drammock's comment:
I spent some time going through the MNE side of this in more detail and I think there is a fairly clean way to expose multi-model AMICA without changing the semantics of
mne.preprocessing.ICA.The main idea is:
keep the complete AMICA fit as the authoritative object, and expose each constituent model as a normal single-model MNE
ICAview.Conceptually:
AMICA fit
Mmodelsp(h | t)ICAper modelSo something along these lines:
The important point is that the child objects do not need to teach MNE what a mixture model is. Each child still has exactly what MNE expects, one unmixing matrix, one PCA state, one exclude, one labels_, etc. The mixture stays one level above that.
This also gets rid of the current highest-weight-model workaround for M > 1. I don't think silently returning the globally dominant model is a good final API because the remaining models and the posterior time course are part of the AMICA result, not auxiliary metadata.
For the AMICA-level API I would keep the distinction explicit:
For Raw, probabilities would stay aligned to the recording timeline. For Epochs, I think the natural public shape is (n_models, n_epochs, n_times) rather than exposing the flattened representation used internally.
One thing I would deliberately not define implicitly yet is multi-model apply().
Hard per-sample switching using argmax p(h|t) and posterior-weighted sensor-space reconstruction are both possible, but they are methodological choices and I would rather not bake one into the API accidentally.
I also checked the MNE representation more closely. A per-model AMICA centre can be folded into the child's pca_mean_, so an individual AMICA model can be represented by an ordinary mne.preprocessing.ICA without adding a new MNE class. Keeping the full PCA basis also preserves MNE's existing PCA-residual behavior when n_components < rank.
There is some useful prior art here as well: pAMICA and pyamica both keep the full AMICA state outside the individual MNE ICA objects and expose models individually. I don't think we need to copy either API exactly, but they support the same basic separation.
I wrote up the architecture, the MNE mapping, the rank/centre handling, and the invariants I think we should test here:
models-as-views.html
larsoner commentedon Aug 24, 2026
Seems reasonable to me! Someday maybe we can make the
M > 1.applycase work, maybe with some options (like maybe smooth model transitions or something?) but makes sense for it to raise for now. Maybe if people need it having.apply(raw, model_idx=1, start=0, stop=None)so you could do it piecewise manually could make sense, but that could be a follow-up PR based on actual end-user need (just nice to see that it's compatible with this API).We'd have to think about how to actually save these objects, but that can be worked out in the PR I think...