You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for AMICA (modern ICA distributed as binary)? #1715
AMICA is a successor to Infomax. In my experience, it's significantly better than Infomax or fastica. I've started writing a Python wrapper for AMICA, and begun integrating it into MNE, as another possible method besides fastica and infomax when calling ica.fit().
AMICA probably won't become part of sklearn any time soon though. It's GPL'd, but primarily distributed as a ~5, 10 MB binary (which I'm calling from python), and reimplementing it is far beyond my meagre skills.
Would this wrapper have any chances of becoming integrated into MNE?
@jona-sassenhagen if the wrapper is not GPL that would be possible. In my experience all these algos make no difference when all you want is remove ECG/EOG/other artefacts. And FastICA is fast :) Did you compare against the 3 algos that we ship with MNE?
Yes, and I like AMICA more. It's not an extreme improvement, but noticeable. Usually, it's qualitatively similar to extended infomax, but faster and cleaner.
I've never made an objective comparison, but the EEGLAB people themselves have done a few and (surprise!..) they come out in favour of their pet algorithm.
AMICA is also reasonably fast in my experience, as it's well parallelised. As an additional benefit, it has an integrated MLE-based artefact rejection stage enabling it to deal with fairly bad data in an unsupervised manner.
Finally, AMICA has some more advanced features (especially multiple mixtures), but I probably won't be able to implement these any time soon.
The wrapper I've written is a Python translation of Jason's MATLAB/EEGLAB scripts, and would be BSD. If that would make any difference, I could ask Jason if AMICA itself could be BSD'd.
mne.preprocessing.ICA(method='fastica') and
mne.preprocessing.ICA(method='infomax') and
mne.preprocessing.ICA(method='extended_infomax')
?
We do a bit more than just using the algos and also have an inbuilt rejection buffer that allows you to exclude bad segments, hence learn a mode on bad data.
Re: direct comparisons: not strictly - not all within MNE; but I have compared the MNE-implemented fastica and infomax solutions to EEGLAB-based decompositions of the same data using AMICA, and to be honest found the AMICA solutions much better.
I like Infomax in MNE more than in EEGLAB/MATLAB, but I like AMICA best. I guess I could do a direct comparison within MNE and post it here, but that'll take some time.
It is AMICA, written in I think C, that is GPL. The related MATLAB scripts are for calling the binary and loading the results, and that would be what I've duplicated in Python.
I'll ask Jason what he thinks about BSD.
I would most likely not be able to do a Numpy implementation of AMICA, as I'm a terrible programmer.
@jona-sassenhagen comparisons would be lovely. I'm not against it. I only want to make sure it's really worth the added maintenance and testing effort. Also woud be good to know what was your specific question. For exmaple I don't see other algorithms outpeforming FastICA when it comes to artefact rejection.
@dengemann there is a direct comparison of Infomax and AMICA for removing myogenic artefacts here. However, my personal experience is that the superiority of AMICA is most noticeable in being able to more reliably work with less supervision.
It deals well with heavily contaminated data, probably due to the automatic rejection stage (MLE-based rejection is more hands-off than user-set peak-to-peak thresholds) and adaptive mixtures; and it recovers a higher proportion of neurogenic components, so you can more easily reject e.g. all non-dipolar sources, instead of having to identify specific bad components. With my data, I actually get around 2/3rds neurogenic components using AMICA, while fastica and infomax recover around 1/3rds.
Anecdotally, AMICA also makes identifying EOGs easier because it causes less "split" components for slight nonstationarities (e.g., I often get 2 or 3 blink components out of Infomax where AMICA returned just one).
I'll see if I can make up some plots.
I guess the artefact rejection could be integrated into scikit-learn, but the key component of AMICA is Adaptive Mixtures.
Sounds interesting. Would be good to integrate this into the existing API using the method paramter. The more sophisticated rejection should be added to the other methods as well.
It's on my fork, but I have to do some major cleaning up before I'll open a PR. Internally, it's quite messy, as I haven't quite figured out git/github yet. I hope to be able to share it within a week.
my advice is make it public early.
Also we have so far a policy to ship only pure python code to make
packaging "almost" painless on all systems. Relying on an external binary
is a big decision
for the future and I'd much prefer see a python reimplementation of amica.
Experience with infomax rewriting is that our code is now much faster than
the C code / binary from eeglab. And we have no packaging pb...
for the future and I'd much prefer see a python reimplementation of amica.
Experience with infomax rewriting is that our code is now much faster than
the C code / binary from eeglab. And we have no packaging pb...
Activity
dengemann commentedon Dec 24, 2014
@jona-sassenhagen if the wrapper is not GPL that would be possible. In my experience all these algos make no difference when all you want is remove ECG/EOG/other artefacts. And FastICA is fast :) Did you compare against the 3 algos that we ship with MNE?
jona-sassenhagen commentedon Dec 24, 2014
Yes, and I like AMICA more. It's not an extreme improvement, but noticeable. Usually, it's qualitatively similar to extended infomax, but faster and cleaner.
I've never made an objective comparison, but the EEGLAB people themselves have done a few and (surprise!..) they come out in favour of their pet algorithm.
AMICA is also reasonably fast in my experience, as it's well parallelised. As an additional benefit, it has an integrated MLE-based artefact rejection stage enabling it to deal with fairly bad data in an unsupervised manner.
Finally, AMICA has some more advanced features (especially multiple mixtures), but I probably won't be able to implement these any time soon.
The wrapper I've written is a Python translation of Jason's MATLAB/EEGLAB scripts, and would be BSD. If that would make any difference, I could ask Jason if AMICA itself could be BSD'd.
dengemann commentedon Dec 24, 2014
@jona-sassenhagen to be clear: did you compare it against
?
We do a bit more than just using the algos and also have an inbuilt rejection buffer that allows you to exclude bad segments, hence learn a mode on bad data.
larsoner commentedon Dec 24, 2014
Just to pipe in about the license question -- I do think the cleanest
solution would be to request permission to relicense under BSD as you
suggest.
dengemann commentedon Dec 24, 2014
... and then add numpy implementation :)
agramfort commentedon Dec 24, 2014
is there a pure matlab implementation of AMICA?
If it's not a clear improvement I wonder if we should accept the
maintenance cost...
Having a good wrapper could good to do a proper reproducible benchmark
though...
jona-sassenhagen commentedon Dec 24, 2014
Re: direct comparisons: not strictly - not all within MNE; but I have compared the MNE-implemented fastica and infomax solutions to EEGLAB-based decompositions of the same data using AMICA, and to be honest found the AMICA solutions much better.
I like Infomax in MNE more than in EEGLAB/MATLAB, but I like AMICA best. I guess I could do a direct comparison within MNE and post it here, but that'll take some time.
jona-sassenhagen commentedon Dec 24, 2014
It is AMICA, written in I think C, that is GPL. The related MATLAB scripts are for calling the binary and loading the results, and that would be what I've duplicated in Python.
I'll ask Jason what he thinks about BSD.
I would most likely not be able to do a Numpy implementation of AMICA, as I'm a terrible programmer.
agramfort commentedon Dec 24, 2014
yes I got that but sometimes there is also a "slow" matlab version.
maybe Jason has one that he uses for debugging...
dengemann commentedon Dec 24, 2014
@jona-sassenhagen comparisons would be lovely. I'm not against it. I only want to make sure it's really worth the added maintenance and testing effort. Also woud be good to know what was your specific question. For exmaple I don't see other algorithms outpeforming FastICA when it comes to artefact rejection.
jona-sassenhagen commentedon Dec 24, 2014
I've asked Jason.
@dengemann there is a direct comparison of Infomax and AMICA for removing myogenic artefacts here. However, my personal experience is that the superiority of AMICA is most noticeable in being able to more reliably work with less supervision.
It deals well with heavily contaminated data, probably due to the automatic rejection stage (MLE-based rejection is more hands-off than user-set peak-to-peak thresholds) and adaptive mixtures; and it recovers a higher proportion of neurogenic components, so you can more easily reject e.g. all non-dipolar sources, instead of having to identify specific bad components. With my data, I actually get around 2/3rds neurogenic components using AMICA, while fastica and infomax recover around 1/3rds.
Anecdotally, AMICA also makes identifying EOGs easier because it causes less "split" components for slight nonstationarities (e.g., I often get 2 or 3 blink components out of Infomax where AMICA returned just one).
I'll see if I can make up some plots.
I guess the artefact rejection could be integrated into scikit-learn, but the key component of AMICA is Adaptive Mixtures.
dengemann commentedon Dec 24, 2014
Sounds interesting. Would be good to integrate this into the existing API using the method paramter. The more sophisticated rejection should be added to the other methods as well.
jona-sassenhagen commentedon Feb 10, 2015
I have a prototype running. It's very hacky for now, but it works. See http://nbviewer.ipython.org/gist/jona-sassenhagen/752c21f59ca27605ae29
Here, AMICA already delivers many more dipolar (=possibly neurogenic) components than FASTICA, and less component splitting.
agramfort commentedon Feb 11, 2015
@jona-sassenhagen thanks heaps for sharing ! did you make this wrapper public? can you open a PR?
jona-sassenhagen commentedon Feb 11, 2015
It's on my fork, but I have to do some major cleaning up before I'll open a PR. Internally, it's quite messy, as I haven't quite figured out git/github yet. I hope to be able to share it within a week.
agramfort commentedon Feb 12, 2015
jona-sassenhagen commentedon Feb 12, 2015
I have submitted a pull request: #1796
dengemann commentedon Feb 12, 2015
I agree with @agramfort.