Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into empty_epochs_msg
Browse files Browse the repository at this point in the history
  • Loading branch information
marsipu committed Jul 27, 2023
2 parents a675c20 + 1763fa6 commit 94436ee
Show file tree
Hide file tree
Showing 40 changed files with 908 additions and 644 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ jobs:
name: Install fonts needed for diagrams
command: |
mkdir -p $HOME/.fonts
echo "Source Code Pro"
curl https://codeload.github.com/adobe-fonts/source-code-pro/tar.gz/2.038R-ro/1.058R-it/1.018R-VAR | tar xz -C $HOME/.fonts
curl https://codeload.github.com/adobe-fonts/source-sans-pro/tar.gz/3.028R | tar xz -C $HOME/.fonts
echo "Source Sans Pro"
curl https://codeload.github.com/adobe-fonts/source-sans/tar.gz/3.028R | tar xz -C $HOME/.fonts
fc-cache -f
# Load pip cache
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ jobs:
- os: macos-latest
python: '3.8'
kind: mamba
- os: windows-latest
python: '3.10'
kind: mamba
- os: ubuntu-latest
python: '3.8'
kind: minimal
Expand All @@ -82,9 +85,9 @@ jobs:
# Python (if conda)
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ${{ env.CONDA_ACTIVATE_ENV }}
python-version: ${{ env.PYTHON_VERSION }}
environment-file: ${{ env.CONDA_ENV }}
activate-environment: mne
miniforge-version: latest
miniforge-variant: Mambaforge
use-mamba: ${{ matrix.kind != 'conda' }}
Expand Down
40 changes: 3 additions & 37 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,8 @@ stages:
variables:
MNE_LOGGING_LEVEL: 'warning'
MNE_FORCE_SERIAL: 'true'
OPENBLAS_NUM_THREADS: 1
MKL_NUM_THREADS: 2
OPENBLAS_NUM_THREADS: 2
OMP_DYNAMIC: 'false'
MKL_DYNAMIC: 'false'
PYTHONUNBUFFERED: 1
PYTHONIOENCODING: 'utf-8'
AZURE_CI_WINDOWS: 'true'
Expand All @@ -254,10 +252,6 @@ stages:
strategy:
maxParallel: 4
matrix:
3.10 conda:
PLATFORM: 'x86-64'
TEST_MODE: 'conda'
PYTHON_VERSION: '3.10'
3.9 pip:
TEST_MODE: 'pip'
PYTHON_VERSION: '3.9'
Expand All @@ -270,44 +264,16 @@ stages:
versionSpec: $(PYTHON_VERSION)
architecture: $(PYTHON_ARCH)
addToPath: true
condition: in(variables['TEST_MODE'], 'pip', 'pip-pre')
displayName: 'Get Python'
# https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/anaconda
# https://github.com/MicrosoftDocs/pipelines-anaconda
# https://github.com/ContinuumIO/anaconda-issues/issues/10949
- script: |
echo "##vso[task.prependpath]%CONDA%;%CONDA%\condabin;%CONDA%\Scripts;%CONDA%\Library\bin;%PROGRAMFILES%\Git\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%PROGRAMFILES%\Git\usr\bin"
condition: in(variables['TEST_MODE'], 'conda')
displayName: Add conda to PATH, deal with Qt linking bug
- bash: |
set -e
set -eo pipefail
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
displayName: Install OpenGL
- bash: |
set -e
./tools/azure_dependencies.sh
condition: in(variables['TEST_MODE'], 'pip', 'pip-pre')
- bash: ./tools/azure_dependencies.sh
displayName: Install dependencies with pip
- script: conda install -c conda-forge "mamba!=1.4.9"
condition: eq(variables['TEST_MODE'], 'conda')
displayName: Get mamba
- script: mamba env update --name base --file environment.yml
condition: eq(variables['TEST_MODE'], 'conda')
displayName: Setup MNE environment
# ipympl is not tested on Windows and even its installation interferes
# with basic matplotlib functionality so it must be uninstalled until fixed
- bash: |
set -e
mamba remove -c conda-forge --force -yq mne ipympl
rm /c/Miniconda/Scripts/mne.exe
condition: eq(variables['TEST_MODE'], 'conda')
displayName: Remove old MNE
- script: pip install -e .
displayName: 'Install MNE-Python dev'
- script: pip install --progress-bar off -e .[test]
condition: eq(variables['TEST_MODE'], 'conda')
displayName: Install testing requirements
- script: mne sys_info -pd
displayName: 'Print config'
- script: python -c "import numpy; numpy.show_config()"
Expand Down
16 changes: 16 additions & 0 deletions doc/_static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ html[data-theme="dark"] img {
color: var(--pst-color-link);
}

/* make versionadded smaller and inline with param name */
/* don't do for deprecated / versionchanged; they have extra info (too long to fit) */
div.versionadded > p {
margin-top: 0;
margin-bottom: 0;
}
div.versionadded {
margin: 0;
margin-left: 0.5rem;
display: inline-block;
}
/* when FF supports :has(), change to → dd > p:has(+div.versionadded) */
dd>p {
display: inline;
}

/* **************************************************** sphinx-gallery fixes */

/* backreference links: restore hover decoration that SG removes */
Expand Down
3 changes: 3 additions & 0 deletions doc/changes/latest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Bugs
- Extended test to highlight bug in :func:`mne.stats.permutation_t_test` (:gh:`11575` by :newcontrib:`Joshua Calder-Travis`)
- Fix bug that used wrong indices for line/label styles (sometimes causing an ``IndexError``) in :meth:`mne.preprocessing.ICA.plot_sources` under certain conditions (:gh:`11808` by :newcontrib:`Joshua Calder-Travis`)
- Fix bug with :func:`~mne.io.read_raw_snirf` to handle files with measurement time containing milliseconds (:gh:`11804` by :newcontrib:`Daniel Tse`)
- Fix bug where :func:`mne.io.read_raw_cnt` imports unnecessary durations (:gh:`11828` by `Jacob Woessner`_)
- Fix bug where :meth:`mne.viz.Brain.add_volume_labels` used an incorrect orientation (:gh:`11730` by `Alex Rockhill`_)
- Fix bug with :func:`mne.forward.restrict_forward_to_label` where cortical patch information was not adjusted (:gh:`11694` by `Eric Larson`_)
- Fix bug with PySide6 compatibility (:gh:`11721` by `Eric Larson`_)
Expand All @@ -52,11 +53,13 @@ Bugs
- Fix bug with :func:`mne.io.read_raw_fil` where datasets without sensor positions would not import (:gh:`11733` by `George O'Neill`_)
- Fix bug with :func:`mne.chpi.compute_chpi_snr` where cHPI being off for part of the recording or bad channels being defined led to an error or incorrect behavior (:gh:`11754`, :gh:`11755` by `Eric Larson`_)
- Allow int-like for the argument ``id`` of `~mne.make_fixed_length_events` (:gh:`11748` by `Mathieu Scheltienne`_)
- Fix bug where :func:`mne.io.read_raw_egi` did not properly set the EEG reference location for the reference channel itself (:gh:`11822` by `Eric Larson`_)
- Fix bug with legacy :meth:`~mne.io.Raw.plot_psd` method where passed axes were not used (:gh:`11778` by `Daniel McCloy`_)
- blink :class:`mne.Annotations` read in by :func:`mne.io.read_raw_eyelink` now begin with ``'BAD_'``, i.e. ``'BAD_blink'``, because ocular data are missing during blinks. (:gh:`11746` by `Scott Huberty`_)
- Fix bug where :ref:`mne show_fiff` could fail with an ambiguous error if the file is corrupt (:gh:`11800` by `Eric Larson`_)
- Fix bug where annotation FIF files lacked an end block tag (:gh:`11800` by `Eric Larson`_)
- Fix display of :class:`~mne.Annotations` in `mne.preprocessing.ICA.plot_sources` when the ``raw`` has ``raw.first_samp != 0`` and doesn't have a measurement date (:gh:`11766` by `Mathieu Scheltienne`_)
- Fix bug in read_raw_eyelink, where STATUS information of samples was always assumed to be in the file. Performance and memory improvements were also made. (:gh:`11823` by `Scott Huberty`_)

API changes
~~~~~~~~~~~
Expand Down
6 changes: 5 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import numpy as np
import matplotlib
import sphinx
from sphinx.domains.changeset import versionlabels
from sphinx_gallery.sorting import FileNameSortKey, ExplicitOrder
from numpydoc import docscrape

import mne
from mne.fixes import _compare_version
from mne.tests.test_docstring_parameters import error_ignores
from mne.utils import (
linkcode_resolve, # noqa, analysis:ignore
Expand Down Expand Up @@ -752,6 +752,10 @@ def append_attr_meth_examples(app, what, name, obj, options, lines):
suppress_warnings = ["image.nonlocal_uri"] # we intentionally link outside


# -- Sphinx hacks / overrides ------------------------------------------------

versionlabels["versionadded"] = sphinx.locale._("New in v%s")

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down
9 changes: 5 additions & 4 deletions doc/install/mne_tools_suite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,24 @@ MNE-Python, including packages for:
(`alphaCSC`_)
- independent component analysis (ICA) with good performance on real data
(`PICARD`_)
- automatic labeling of ICA components (`MNE-ICAlabel`_)
- phase-amplitude coupling (`pactools`_)
- representational similarity analysis (`rsa`_)
- microstate analysis (`microstate`_)
- connectivity analysis using dynamic imaging of coherent sources (DICS)
(`conpy`_)
- other connectivity algorithms (`MNE-Connectivity`_)
- general-purpose statistical analysis of M/EEG data (`eelbrain`_)
- post-hoc modification of linear models (`posthoc`_)
- a python implementation of the Preprocessing Pipeline (PREP) for EEG data
(`pyprep`_)
- automatic multi-dipole localization and uncertainty quantification with
the Bayesian algorithm SESAME (`sesameeg`_)
- GLM and group level analysis of near-infrared spectroscopy data (`mne-nirs`_)
- High-level EEG Python library for all kinds of EEG inverse solutions (`invertmeeg`_)
- GLM and group level analysis of near-infrared spectroscopy data (`MNE-NIRS`_)
- high-level EEG Python library for all kinds of EEG inverse solutions (`invertmeeg`_)
- All-Resolutions Inference (ARI) for statistically valid circular inference
and effect localization (`MNE-ARI`_)

- real-time analysis (`MNE-Realtime`_)

What should I install?
^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -109,6 +111,5 @@ Help with installation is available through the `MNE Forum`_. See the
.. _posthoc: https://users.aalto.fi/~vanvlm1/posthoc/python/
.. _pyprep: https://github.com/sappelhoff/pyprep
.. _sesameeg: https://pybees.github.io/sesameeg
.. _mne-nirs: https://github.com/mne-tools/mne-nirs
.. _invertmeeg: https://github.com/LukeTheHecker/invert
.. _MNE-ARI: https://github.com/john-veillette/mne_ari
3 changes: 3 additions & 0 deletions doc/links.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
.. _`MNE-Realtime`: https://mne.tools/mne-realtime
.. _`MNE-MATLAB git repository`: https://github.com/mne-tools/mne-matlab
.. _`MNE-Docker`: https://github.com/mne-tools/mne-docker
.. _`MNE-ICAlabel`: https://github.com/mne-tools/mne-icalabel
.. _`MNE-Connectivity`: https://github.com/mne-tools/mne-connectivity
.. _`MNE-NIRS`: https://github.com/mne-tools/mne-nirs
.. _OpenMEEG: http://openmeeg.github.io
.. _EOSS2: https://chanzuckerberg.com/eoss/proposals/improving-usability-of-core-neuroscience-analysis-tools-with-mne-python
.. _EOSS4: https://chanzuckerberg.com/eoss/proposals/building-pediatric-and-clinical-data-pipelines-for-mne-python/
Expand Down
21 changes: 9 additions & 12 deletions mne/channels/montage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,25 +1171,22 @@ def _backcompat_value(pos, ref_pos):
chs = [info["chs"][ii] for ii in picks]
non_names = [info["chs"][ii]["ch_name"] for ii in non_picks]
del picks
ref_pos = [ch["loc"][3:6] for ch in chs]
ref_pos = np.array([ch["loc"][3:6] for ch in chs])

# keep reference location from EEG-like channels if they
# already exist and are all the same.
custom_eeg_ref_dig = False
# Note: ref position is an empty list for fieldtrip data
if ref_pos:
if (
all([np.equal(ref_pos[0], pos).all() for pos in ref_pos])
and not np.equal(ref_pos[0], [0, 0, 0]).all()
):
eeg_ref_pos = ref_pos[0]
# since we have an EEG reference position, we have
# to add it into the info['dig'] as EEG000
custom_eeg_ref_dig = True
if not custom_eeg_ref_dig:
if len(ref_pos) and ref_pos[0].any() and (ref_pos[0] == ref_pos).all():
eeg_ref_pos = ref_pos[0]
# since we have an EEG reference position, we have
# to add it into the info['dig'] as EEG000
custom_eeg_ref_dig = True
else:
refs = set(ch_pos) & {"EEG000", "REF"}
assert len(refs) <= 1
eeg_ref_pos = np.zeros(3) if not refs else ch_pos.pop(refs.pop())
custom_eeg_ref_dig = False
del ref_pos

# This raises based on info being subset/superset of montage
info_names = [ch["ch_name"] for ch in chs]
Expand Down
4 changes: 4 additions & 0 deletions mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def pytest_configure(config):
warning_line = warning_line.strip()
if warning_line and not warning_line.startswith("#"):
config.addinivalue_line("filterwarnings", warning_line)
# TODO: Fix this with casts?
# https://github.com/numpy/numpy/pull/22449
if check_version("numpy", "1.26"):
np.set_printoptions(legacy="1.25")


# Have to be careful with autouse=True, but this is just an int comparison
Expand Down
8 changes: 8 additions & 0 deletions mne/cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,15 @@ def plot_topomap(
%(sphere_topomap_auto)s
%(image_interp_topomap)s
%(extrapolate_topomap)s
.. versionchanged:: 0.21
- The default was changed to ``'local'`` for MEG sensors.
- ``'local'`` was changed to use a convex hull mask
- ``'head'`` was changed to extrapolate out to the clipping circle.
%(border_topomap)s
.. versionadded:: 0.20
%(res_topomap)s
%(size_topomap)s
%(cmap_topomap)s
Expand Down
2 changes: 2 additions & 0 deletions mne/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class BaseRaw(
(only needed for types that support on-demand disk reads)
"""

_extra_attributes = ()

@verbose
def __init__(
self,
Expand Down
2 changes: 2 additions & 0 deletions mne/io/brainvision/brainvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class RawBrainVision(BaseRaw):
mne.io.Raw : Documentation of attributes and methods.
"""

_extra_attributes = ("impedances",)

@verbose
def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion mne/io/bti/bti.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ def __init__(
sort_by_ch_name=sort_by_ch_name,
eog_ch=eog_ch,
)
self.bti_ch_labels = [c["chan_label"] for c in bti_info["chs"]]
bti_info["bti_ch_labels"] = [c["chan_label"] for c in bti_info["chs"]]
# make Raw repr work if we have a BytesIO as input
if isinstance(pdf_fname, BytesIO):
pdf_fname = repr(pdf_fname)
Expand Down
6 changes: 4 additions & 2 deletions mne/io/bti/tests/test_bti.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,12 @@ def test_info_no_rename_no_reorder_no_pdf():
preload=True,
)

sort_idx = [raw1.bti_ch_labels.index(ch) for ch in raw2.bti_ch_labels]
bti_ch_labels_1 = raw1._raw_extras[0]["bti_ch_labels"]
bti_ch_labels_2 = raw2._raw_extras[0]["bti_ch_labels"]
sort_idx = [bti_ch_labels_1.index(ch) for ch in bti_ch_labels_2]
raw1._data = raw1._data[sort_idx]
assert_array_equal(raw1._data, raw2._data)
assert_array_equal(raw2.bti_ch_labels, raw2.ch_names)
assert_array_equal(bti_ch_labels_2, raw2.ch_names)


def test_no_conversion():
Expand Down
6 changes: 3 additions & 3 deletions mne/io/cnt/cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def _update_bad_span_onset(accept_reject, onset, duration, description):
event_type=type(my_events[0]),
data_format=data_format,
)
duration = np.array(
[getattr(e, "Latency", 0.0) for e in my_events], dtype=float
)
# There is a Latency field but it's not useful for durations, see
# https://github.com/mne-tools/mne-python/pull/11828
duration = np.zeros(len(my_events), dtype=float)
accept_reject = _accept_reject_function(
np.array([e.KeyPad_Accept for e in my_events])
)
Expand Down
18 changes: 8 additions & 10 deletions mne/io/ctf/ctf.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ def __init__(
)
annot = marker_annot if annot is None else annot + marker_annot
self.set_annotations(annot)

if clean_names:
self._clean_names()
_clean_names_inst(self)

def _read_segment_file(self, data, idx, fi, start, stop, cals, mult):
"""Read a chunk of raw data."""
Expand All @@ -222,15 +221,14 @@ def _read_segment_file(self, data, idx, fi, start, stop, cals, mult):
_mult_cal_one(data_view, this_data, idx, cals, mult)
offset += n_read

def _clean_names(self):
"""Clean up CTF suffixes from channel names."""
mapping = dict(zip(self.ch_names, _clean_names(self.ch_names)))

self.rename_channels(mapping)

for comp in self.info["comps"]:
for key in ("row_names", "col_names"):
comp["data"][key] = _clean_names(comp["data"][key])
def _clean_names_inst(inst):
"""Clean up CTF suffixes from channel names."""
mapping = dict(zip(inst.ch_names, _clean_names(inst.ch_names)))
inst.rename_channels(mapping)
for comp in inst.info["comps"]:
for key in ("row_names", "col_names"):
comp["data"][key] = _clean_names(comp["data"][key])


def _get_sample_info(fname, res4, system_clock):
Expand Down
2 changes: 2 additions & 0 deletions mne/io/egi/egi.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def read_raw_egi(
class RawEGI(BaseRaw):
"""Raw object from EGI simple binary file."""

_extra_attributes = ("event_id",)

@verbose
def __init__(
self,
Expand Down
Loading

0 comments on commit 94436ee

Please sign in to comment.