Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/latest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ Bugs

- Fix bug in the :class:`mne.viz.Brain` tool bar that prevented the buttons to call the corresponding feature (:gh:`10560` by `Guillaume Favelier`_)

- 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`_)

API and behavior changes
~~~~~~~~~~~~~~~~~~~~~~~~
- When creating BEM surfaces via :func:`mne.bem.make_watershed_bem` and :func:`mne.bem.make_flash_bem`, the ``copy`` parameter now defaults to ``True``. This means that instead of creating symbolic links inside the FreeSurfer subject's ``bem`` folder, we now create "actual" files. This should avoid troubles when sharing files across different operating systems and file systems (:gh:`10531` by `Richard Höchenberger`_)
Expand Down
8 changes: 8 additions & 0 deletions mne/preprocessing/_csd.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ 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):
inst.reject = None if inst.reject is None else \
{k: v for k, v in inst.reject.items() if k != 'eeg'}
Comment on lines +182 to +183
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if inst.reject and "eeg" in inst.reject:
   del inst.reject["eeg"]

would be more readable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!
I'll push a "fix"

inst.flat = None if inst.flat is None else \
{k: v for k, v in inst.flat.items() if k != 'eeg'}

return inst


Expand Down
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 @@ -186,6 +187,19 @@ def test_csd_fif():
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)


def test_compute_bridged_electrodes():
"""Test computing bridged electrodes."""
# test I/O
Expand Down