question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot pickle mne.preprocessing.ica.ICA anymore

See original GitHub issue

With the current master (installed via pip install git+https://github.com/mne-tools/mne-python.git#egg=mne), I get an error when pickling an mne.preprocessing.ica.ICA object:

import pickle
import mne


print(mne.__version__)
ica = mne.preprocessing.ICA()
raw = mne.io.read_raw_edf("/Users/clemens/Downloads/testfiles/S001R04.edf", preload=True)
ica.fit(raw)
pickle.loads(pickle.dumps(ica))
# Traceback (most recent call last):
#   File "/Users/clemens/Repositories/mnelab/.venv/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
#     exec(code_obj, self.user_global_ns, self.user_ns)
#   File "<ipython-input-8-a056623ee708>", line 1, in <module>
#     pickle.loads(pickle.dumps(ica))
# TypeError: __new__() missing 1 required positional argument: 'val'

The same code works with the latest released version 0.17.2. I didn’t see any change to the ICA object that might be causing this (but maybe I’m missing something). If indeed nothing changed, could this behavior be due to how pip installs stuff from GitHub (vs. “proper” packages from PyPI)? If so, how can I fix this (I need to pickle because I want to use the multiprocessing module)?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Teekuningascommented, Apr 29, 2019

This is expected behavior when defining custom __new__-methods.

You could add something like this to utils/_bunch.py 's NamedInt: def __getnewargs__(obj): return obj._name, int(obj)

0reactions
cbrnrcommented, Apr 29, 2019

Thanks @Teekuningas, this solves the problem!

Read more comments on GitHub >

github_iconTop Results From Across the Web

mne.preprocessing.ICA — MNE 1.2.2 documentation
Data decomposition using Independent Component Analysis (ICA). ... the baseline period of the cleaned data may not be of zero mean anymore.
Read more >
How to set up and fit the ICA? - MNE Forum - Discourse
In the preprocessing section, the tutorial says: # set up and fit the ICA ica = mne.preprocessing.ICA(n_components=20, random_state=97, ...
Read more >
A Toolbox and Crowdsourcing Platform for Automatic Labeling ...
The ALICE toolbox aims to build a sustainable algorithm to remove artifacts and find specific patterns in EEG signals using ICA decomposition ...
Read more >
A Toolbox and Crowdsourcing Platform for Automatic ... - NCBI
Independent Component Analysis (ICA) is a conventional approach to exclude non-brain signals such as eye movements and muscle artifacts from ...
Read more >
(PDF) A Toolbox and Crowdsourcing Platform for Automatic ...
PDF | Independent Component Analysis (ICA) is a conventional approach to exclude non-brain signals such as eye movements and muscle ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found