mne-tools / mne-tools/mne-python
can't pickle Epochs with preload=False
Open
Nobody has claimed this yet.
BUG
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
Description
To replicate:
from pathlib import Path
import mne
import pickle
sample_dir = Path(mne.datasets.sample.data_path())
sample_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(sample_fname)
raw.crop(tmax=60)
events = mne.find_events(raw, stim_channel='STI 014')
event_id = {'auditory/left': 1}
epochs = mne.Epochs(raw, events=events, event_id=event_id,
tmin=-0.2, tmax=0.5, baseline=(None, 0),
preload=True)
epochs.save('toto-epo.fif', overwrite=True)
epochs = mne.read_epochs('toto-epo.fif', preload=False)
# del epochs._raw[0].fid # uncomment this line to fix it
fname = "toto.pkl"
with open(fname, 'wb') as fid:
pickle.dump(epochs, fid)
it's due to the fid in epochs._raw[0].fid
@larsoner thoughts?
reported by @gemeinl in braindecode
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Python reproduction with MNE's sample dataset and inspect the loaded Epochs object's epochs._raw[0].fid after read_epochs(..., preload=False). Done means an Epochs object loaded with preload=False can be serialized with pickle without requiring the manual fid deletion shown in the report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100