Skip to content

Add support for AMICA (modern ICA distributed as binary)? #1715

Closed

Description

@jona-sassenhagen

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?

Activity

  1. dengemann commented on Dec 24, 2014

    @dengemann
    Member

    @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?

  2. jona-sassenhagen commented on Dec 24, 2014

    @jona-sassenhagen
    ContributorAuthor

    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.

  3. dengemann commented on Dec 24, 2014

    @dengemann
    Member

    @jona-sassenhagen to be clear: did you compare it against

    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.

  4. larsoner commented on Dec 24, 2014

    @larsoner
    Member

    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.

  5. dengemann commented on Dec 24, 2014

    @dengemann
    Member

    ... and then add numpy implementation :)

  6. agramfort commented on Dec 24, 2014

    @agramfort
    SponsorMember

    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...

  7. jona-sassenhagen commented on Dec 24, 2014

    @jona-sassenhagen
    ContributorAuthor

    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.

  8. jona-sassenhagen commented on Dec 24, 2014

    @jona-sassenhagen
    ContributorAuthor

    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.

  9. agramfort commented on Dec 24, 2014

    @agramfort
    SponsorMember

    yes I got that but sometimes there is also a "slow" matlab version.

    maybe Jason has one that he uses for debugging...

  10. dengemann commented on Dec 24, 2014

    @dengemann
    Member

    @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.

  11. jona-sassenhagen commented on Dec 24, 2014

    @jona-sassenhagen
    ContributorAuthor

    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.

  12. dengemann commented on Dec 24, 2014

    @dengemann
    Member

    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.

  13. jona-sassenhagen commented on Feb 10, 2015

    @jona-sassenhagen
    ContributorAuthor

    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.

  14. agramfort commented on Feb 11, 2015

    @agramfort
    SponsorMember

    @jona-sassenhagen thanks heaps for sharing ! did you make this wrapper public? can you open a PR?

  15. jona-sassenhagen commented on Feb 11, 2015

    @jona-sassenhagen
    ContributorAuthor

    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.

  16. agramfort commented on Feb 12, 2015

    @agramfort
    SponsorMember
  17. jona-sassenhagen commented on Feb 12, 2015

    @jona-sassenhagen
    ContributorAuthor

    I have submitted a pull request: #1796

  18. dengemann commented on Feb 12, 2015

    @dengemann
    Member

    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...

    I agree with @agramfort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions