diff --git a/azure-pipelines.yml b/azure-pipelines.yml index efdf0061ced..c40d05dea98 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -111,7 +111,7 @@ stages: - bash: | set -e python -m pip install --progress-bar off --upgrade pip setuptools wheel codecov - python -m pip install --progress-bar off mne-qt-browser[opengl] vtk scikit-learn pytest-error-for-skips python-picard + python -m pip install --progress-bar off mne-qt-browser[opengl] vtk scikit-learn pytest-error-for-skips python-picard "pyqt5>=5.10,!=5.15.3" python -m pip uninstall -yq mne python -m pip install --progress-bar off --upgrade -e .[test] displayName: 'Install dependencies with pip' diff --git a/doc/changes/1.0.inc b/doc/changes/1.0.inc index 467ce575bea..af578c657d6 100644 --- a/doc/changes/1.0.inc +++ b/doc/changes/1.0.inc @@ -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`_) diff --git a/mne/beamformer/tests/test_lcmv.py b/mne/beamformer/tests/test_lcmv.py index a442e560221..bd413e80f9c 100644 --- a/mne/beamformer/tests/test_lcmv.py +++ b/mne/beamformer/tests/test_lcmv.py @@ -677,8 +677,8 @@ def test_localization_bias_fixed(bias_params_fixed, reg, weight_norm, use_cov, # no reg (0.00, 'vector', None, True, None, 23, 24, 0.96, 0.97), (0.00, 'vector', 'unit-noise-gain-invariant', True, None, 52, 54, 0.95, 0.96), # noqa: E501 - (0.00, 'vector', 'unit-noise-gain', True, None, 44, 46, 0.97, 0.98), - (0.00, 'vector', 'nai', True, None, 44, 46, 0.97, 0.98), + (0.00, 'vector', 'unit-noise-gain', True, None, 44, 48, 0.97, 0.99), + (0.00, 'vector', 'nai', True, None, 44, 48, 0.97, 0.99), (0.00, 'max-power', None, True, None, 14, 15, 0, 0), (0.00, 'max-power', 'unit-noise-gain-invariant', True, None, 35, 37, 0, 0), # noqa: E501 (0.00, 'max-power', 'unit-noise-gain', True, None, 35, 37, 0, 0), diff --git a/mne/preprocessing/_csd.py b/mne/preprocessing/_csd.py index affefcc9894..879be604d68 100644 --- a/mne/preprocessing/_csd.py +++ b/mne/preprocessing/_csd.py @@ -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 diff --git a/mne/preprocessing/tests/test_csd.py b/mne/preprocessing/tests/test_csd.py index 9586a5ff479..0e571326f2d 100644 --- a/mne/preprocessing/tests/test_csd.py +++ b/mne/preprocessing/tests/test_csd.py @@ -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 @@ -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) diff --git a/mne/viz/backends/_utils.py b/mne/viz/backends/_utils.py index 774439a8fab..28c8c3181b8 100644 --- a/mne/viz/backends/_utils.py +++ b/mne/viz/backends/_utils.py @@ -232,7 +232,6 @@ def _qt_get_stylesheet(theme): # but it's easy enough just to set it transparent and inherit # the bgcolor of the window (which is the same). We also take # the separator images from QDarkStyle (MIT). - icons_path = _qt_init_icons() stylesheet = """\ QStatusBar { border: 1px solid rgb(76, 76, 75); @@ -245,23 +244,7 @@ def _qt_get_stylesheet(theme): background-color: transparent; border-bottom: 1px solid rgb(99, 99, 99); } -QToolBar::separator:horizontal { - width: 16px; - image: url("%(icons_path)s/toolbar_separator_horizontal@2x.png"); -} -QToolBar::separator:vertical { - height: 16px; - image: url("%(icons_path)s/toolbar_separator_vertical@2x.png"); -} -QToolBar::handle:horizontal { - width: 16px; - image: url("%(icons_path)s/toolbar_move_horizontal@2x.png"); -} -QToolBar::handle:vertical { - height: 16px; - image: url("%(icons_path)s/toolbar_move_vertical@2x.png"); -} -""" % dict(icons_path=icons_path) +""" else: stylesheet = '' else: diff --git a/tools/azure_dependencies.sh b/tools/azure_dependencies.sh index 588bea0cc89..0f027da9659 100755 --- a/tools/azure_dependencies.sh +++ b/tools/azure_dependencies.sh @@ -14,7 +14,7 @@ elif [ "${TEST_MODE}" == "pip-pre" ]; then # SciPy Windows build is missing from conda nightly builds python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps -i "https://pypi.anaconda.org/scipy-wheels-nightly/simple" numpy python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps scipy - python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps -i "https://pypi.anaconda.org/scipy-wheels-nightly/simple" pandas scikit-learn dipy statsmodels + python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps --default-timeout=60 -i "https://pypi.anaconda.org/scipy-wheels-nightly/simple" pandas scikit-learn dipy statsmodels python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps -f "https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com" h5py Pillow matplotlib # Until VTK comes out with a 3.10 wheel, we need to use PyVista's python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" https://github.com/pyvista/pyvista-wheels/raw/3b70f3933bc246b035354b172a0459ffc96b0343/vtk-9.1.0.dev0-cp310-cp310-win_amd64.whl diff --git a/tools/github_actions_dependencies.sh b/tools/github_actions_dependencies.sh index df3f69d4133..579d9841383 100755 --- a/tools/github_actions_dependencies.sh +++ b/tools/github_actions_dependencies.sh @@ -17,7 +17,7 @@ else echo "PyQt5" pip install $STD_ARGS --pre --only-binary ":all:" --no-deps --extra-index-url https://www.riverbankcomputing.com/pypi/simple PyQt5 PyQt5-sip PyQt5-Qt5 echo "NumPy/SciPy/pandas etc." - pip install $STD_ARGS --pre --only-binary ":all:" --no-deps -i "https://pypi.anaconda.org/scipy-wheels-nightly/simple" numpy scipy pandas scikit-learn statsmodels dipy + pip install $STD_ARGS --pre --only-binary ":all:" --no-deps --default-timeout=60 -i "https://pypi.anaconda.org/scipy-wheels-nightly/simple" numpy scipy pandas scikit-learn statsmodels dipy echo "H5py, pillow, matplotlib" pip install $STD_ARGS --pre --only-binary ":all:" --no-deps -f "https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com" h5py pillow matplotlib # We don't install Numba here because it forces an old NumPy version