Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/changes/1.0.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Version 1.0.X

- Retain epochs metadata when using :func:`mne.channels.combine_channels` (:gh:`10504` by `Clemens Brunner`_)

- Fix issue with saving epochs once :func:`~mne.preprocessing.compute_current_source_density` has been used if a rejection threshold was used first (:gh:`10619` by `Alex Rockhill`_ and `Richard Höchenberger`_)

Version 1.0.2 (2022-04-15)
--------------------------
- Fix bug where ``theme`` was not handled properly in :meth:`mne.io.Raw.plot` (:gh:`10500` by `Eric Larson`_)
Expand Down
8 changes: 8 additions & 0 deletions mne/preprocessing/_csd.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,12 @@ def compute_current_source_density(inst, sphere='auto', lambda2=1e-5,
for pick in picks:
inst.info['chs'][pick].update(coil_type=FIFF.FIFFV_COIL_EEG_CSD,
unit=FIFF.FIFF_UNIT_V_M2)

# Remove rejection thresholds for EEG
if isinstance(inst, BaseEpochs):
if inst.reject and 'eeg' in inst.reject:
del inst.reject['eeg']
if inst.flat and 'eeg' in inst.flat:
del inst.flat['eeg']

return inst
16 changes: 15 additions & 1 deletion mne/preprocessing/tests/test_csd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from scipy import linalg

from mne.channels import make_dig_montage
from mne import create_info, EvokedArray, pick_types, Epochs
from mne import (create_info, EvokedArray, pick_types, Epochs, find_events,
read_epochs)
from mne.io import read_raw_fif, RawArray
from mne.io.constants import FIFF
from mne.utils import object_diff
Expand Down Expand Up @@ -183,3 +184,16 @@ def test_csd_fif():
ch.update(coil_type=FIFF.FIFFV_COIL_EEG, unit=FIFF.FIFF_UNIT_V)
raw_csd._data[pick] = raw._data[pick]
assert object_diff(raw.info, raw_csd.info) == ''


def test_csd_epochs(tmp_path):
"""Test making epochs, saving to disk and loading."""
raw = read_raw_fif(raw_fname)
raw.pick_types(eeg=True, stim=True).load_data()
events = find_events(raw)
epochs = Epochs(raw, events, reject=dict(eeg=1e-4), preload=True)
epochs = compute_current_source_density(epochs)
epo_fname = tmp_path / 'test_csd_epo.fif'
epochs.save(epo_fname)
epochs2 = read_epochs(epo_fname, preload=True)
assert_allclose(epochs._data, epochs2._data)