Skip to content

Commit

Permalink
Merge branch 'main' into mp
Browse files Browse the repository at this point in the history
  • Loading branch information
sappelhoff committed Jul 30, 2024
2 parents 88c6dff + 3cbdbab commit 1b1ef5d
Show file tree
Hide file tree
Showing 31 changed files with 107 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.4
rev: v0.5.5
hooks:
- id: ruff
name: ruff mne_bids/
Expand Down
4 changes: 4 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ authors:
family-names: Mikkelsen
affiliation: 'Department of Electrical and Computer Engineering, Aarhus University, Denmark'
orcid: 'https://orcid.org/0000-0002-7360-8629'
- given-names: Amaia
family-names: Benitez
affiliation: 'Magnetoencephalography Core, National Institutes of Health, Bethesda, Maryland, USA'
orcid: 'https://orcid.org/0000-0001-6364-7272'
- given-names: Alexandre
family-names: Gramfort
affiliation: 'Université Paris-Saclay, Inria, CEA, Palaiseau, France'
Expand Down
1 change: 1 addition & 0 deletions doc/authors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@
.. _Mara Wolter: https://github.com/marakw
.. _Julius Welzel: https://github.com/JuliusWelzel
.. _Kaare Mikkelsen: https://github.com/kaare-mikkelsen
.. _Amaia Benitez: https://github.com/AmaiaBA
3 changes: 1 addition & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import sys
from datetime import date

import sphinx_gallery # noqa: F401
from sphinx.config import is_serializable

import mne_bids
Expand Down Expand Up @@ -96,7 +95,7 @@
# General information about the project.
project = "MNE-BIDS"
today = date.today().isoformat()
copyright = f"2017, The MNE-BIDS developers. Last updated on {today}"
copyright = f"2017, The MNE-BIDS developers. Last updated on {today}" # noqa: A001

author = "The MNE-BIDS developers"

Expand Down
5 changes: 4 additions & 1 deletion doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Version 0.16 (unreleased)
The following authors contributed for the first time. Thank you so much! 🤩

* `Kaare Mikkelsen`_
* `Amaia Benitez`_

The following authors had contributed before. Thank you for sticking around! 🤘

Expand All @@ -36,7 +37,8 @@ Detailed list of changes
🧐 API and behavior changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^

- nothing yet
- :func:`mne_bids.read_raw_bids` no longer warns about unit changes in channels upon reading, as that information is taken from ``channels.tsv`` and judged authorative, by `Stefan Appelhoff`_ (:gh:`1282`)
- MEG OPM channels are now experimentally included, by `Amaia Benitez`_ (:gh:`1222`)

🛠 Requirements
^^^^^^^^^^^^^^^
Expand All @@ -52,6 +54,7 @@ Detailed list of changes
^^^^^^^^^^^^^^

- Keep MNE-BIDS up to date with recent changes on participant birthday date handling in MNE-Python, by `Eric Larson`_ (gh:1278:)
- Make rules for linting more strict, make quality assessment exceptions less permissive, by `Stefan Appelhoff`_ (gh:1283:)

:doc:`Find out what was new in previous releases <whats_new_previous_releases>`

Expand Down
2 changes: 1 addition & 1 deletion examples/bidspath.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
BIDSPath is MNE-BIDS's working horse when it comes to file and folder
operations. Learn here how to use it.
"""
""" # noqa: D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
3 changes: 1 addition & 2 deletions examples/convert_eeg_to_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
.. _BrainVision format: https://www.brainproducts.com/support-resources/brainvision-core-data-format-1-0/
.. _CapTrak: https://www.fieldtriptoolbox.org/faq/coordsys/#details-of-the-captrak-coordinate-system
""" # noqa: E501
""" # noqa: E501 D205 D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
2 changes: 1 addition & 1 deletion examples/convert_empty_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
This example demonstrates how to store empty room data "manually" in the BIDS
format and how to retrieve them.
"""
""" # noqa: E501 D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
3 changes: 2 additions & 1 deletion examples/convert_group_studies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
=====================================
05. BIDS conversion for group studies
=====================================
Here, we show how to do BIDS conversion for group studies.
We will use the
`EEG Motor Movement/Imagery Dataset <https://doi.org/10.13026/C28G6P>`_
available on the PhysioBank database.
We recommend that you go through the more basic BIDS conversion example before
checking out this group conversion example: :ref:`ex-convert-mne-sample`
"""
""" # noqa: E501 D205 D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
3 changes: 1 addition & 2 deletions examples/convert_ieeg_to_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
.. _appendix VIII: https://bids-specification.readthedocs.io/en/stable/appendices/coordinate-systems.html
.. _background on FreeSurfer: https://mne.tools/dev/auto_tutorials/source-modeling/plot_background_freesurfer_mne
.. _MNE-Python coordinate frames: https://mne.tools/dev/auto_tutorials/source-modeling/plot_source_alignment.html
""" # noqa: E501
""" # noqa: E501 D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
2 changes: 1 addition & 1 deletion examples/convert_mne_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.. _BIDS dataset_description.json definition: https://bids-specification.readthedocs.io/en/latest/modality-agnostic-files.html#dataset-description
.. _ds000248 dataset_description.json: https://github.com/sappelhoff/bids-examples/blob/master/ds000248/dataset_description.json
""" # noqa: D400 D205 E501
""" # noqa: D400 E501

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
3 changes: 1 addition & 2 deletions examples/convert_mri_and_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
.. note:: For this example you will need to install ``matplotlib`` and
``nilearn`` on top of your usual ``mne-bids`` installation.
"""
""" # noqa: E501 D205 D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
3 changes: 1 addition & 2 deletions examples/convert_nirs_to_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
4. Cite ``mne-bids``.
.. currentmodule:: mne_bids
""" # noqa: E501
""" # noqa: E501 D205 D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
2 changes: 1 addition & 1 deletion examples/create_bids_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
You may automatically convert Raw objects to BIDS-compatible files with
``write_raw_bids``. This example is for manually creating files/folders.
"""
""" # noqa: E501 D205 D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
2 changes: 1 addition & 1 deletion examples/mark_bad_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can use MNE-BIDS interactively inspect your MEG or (i)EEG data.
Problematic channels can be marked as "bad", for example if the connected
sensor produced mostly noise or no signal at all. Similarly, you can declare
sensor produced mostly noise - or no signal at all. Similarly, you can declare
channels as "good", should you discover they were incorrectly marked as bad.
Bad channel selection can also be performed non-interactively.
Expand Down
3 changes: 1 addition & 2 deletions examples/read_bids_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
In this tutorial, we show how ``read_raw_bids`` can be used to load and
inspect BIDS-formatted data.
"""
""" # noqa: D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
2 changes: 1 addition & 1 deletion examples/rename_brainvision_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
for the :ref:`Python Command Line Interface <python_cli>`.
.. _BrainVision data format: https://www.brainproducts.com/support-resources/brainvision-core-data-format-1-0/
""" # noqa:E501
""" # noqa: E501 D205 D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
2 changes: 1 addition & 1 deletion examples/update_bids_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
In this tutorial, we show how ``update_sidecar_json`` can be used to update and
modify BIDS-formatted data.
"""
""" # noqa: D205 D400

# Authors: The MNE-BIDS developers
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
6 changes: 3 additions & 3 deletions mne_bids/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
ALLOWED_SPACES["anat"] = None
ALLOWED_SPACES["beh"] = None

# See: https://bids-specification.readthedocs.io/en/latest/appendices/entity-table.html#encephalography-eeg-ieeg-and-meg # noqa
# See: https://bids-specification.readthedocs.io/en/latest/appendices/entity-table.html#encephalography-eeg-ieeg-and-meg # noqa: E501
ENTITY_VALUE_TYPE = {
"subject": "label",
"session": "label",
Expand All @@ -340,8 +340,8 @@
"ElektaNeuromag": "head",
"ChietiItab": "head",
"CapTrak": "head",
"ACPC": "ras", # assumes T1 is ACPC-aligned, if not the coordinates are lost # noqa
"fsaverage": "mni_tal", # XXX: note fsaverage and MNI305 are the same # noqa
"ACPC": "ras", # assumes T1 is ACPC-aligned, if not the coordinates are lost
"fsaverage": "mni_tal", # XXX: note fsaverage and MNI305 are the same
"MNI305": "mni_tal",
}

Expand Down
8 changes: 4 additions & 4 deletions mne_bids/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,13 +1869,13 @@ def get_datatypes(root, verbose=None):
"""
# Take all possible data types from "entity" table
# (Appendix in BIDS spec)
# https://bids-specification.readthedocs.io/en/latest/appendices/entity-table.html # noqa
# https://bids-specification.readthedocs.io/en/latest/appendices/entity-table.html
datatype_list = ("anat", "func", "dwi", "fmap", "beh", "meg", "eeg", "ieeg", "nirs")
datatypes = list()
for root, dirs, files in os.walk(root):
for dir in dirs:
if dir in datatype_list and dir not in datatypes:
datatypes.append(dir)
for _dir in dirs:
if _dir in datatype_list and _dir not in datatypes:
datatypes.append(_dir)

return datatypes

Expand Down
5 changes: 5 additions & 0 deletions mne_bids/pick.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def get_coil_types():
FIFF.FIFFV_COIL_NM_122,
FIFF.FIFFV_COIL_MAGNES_MAG,
FIFF.FIFFV_COIL_BABY_MAG,
# support for OPM data
FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG, # QuSpin v1
FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG2, # QuSpin v2
FIFF.FIFFV_COIL_FIELDLINE_OPM_MAG_GEN1, # FieldLine v1
FIFF.FIFFV_COIL_KERNEL_OPM_MAG_GEN1, # Kernel
),
megrefmag=(
FIFF.FIFFV_COIL_KIT_REF_MAG,
Expand Down
6 changes: 4 additions & 2 deletions mne_bids/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def _handle_channels_reading(channels_fname, raw):

if updated_ch_type is None:
# XXX Try again with uppercase spelling – this should be removed
# XXX once https://github.com/bids-standard/bids-validator/issues/1018 # noqa:E501
# XXX once https://github.com/bids-standard/bids-validator/issues/1018
# XXX has been resolved.
# XXX x-ref https://github.com/mne-tools/mne-bids/issues/481
updated_ch_type = bids_to_mne_ch_types.get(ch_type.upper(), None)
Expand Down Expand Up @@ -683,7 +683,9 @@ def _handle_channels_reading(channels_fname, raw):
f"Cannot set channel type for the following channels, as they "
f'are missing in the raw data: {", ".join(sorted(ch_diff))}'
)
raw.set_channel_types(channel_type_bids_mne_map_available_channels)
raw.set_channel_types(
channel_type_bids_mne_map_available_channels, on_unit_change="ignore"
)

# Set bad channels based on _channels.tsv sidecar
if "status" in channels_dict:
Expand Down
4 changes: 2 additions & 2 deletions mne_bids/report/_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def _pretty_str(listed):
return "{}, and {}".format(", ".join(listed[:-1]), listed[-1])


def _range_str(minval, maxval, meanval, stdval, n_unknown, type):
def _range_str(minval, maxval, meanval, stdval, n_unknown, typ):
if minval == "n/a":
return "ages all unknown"

if n_unknown > 0:
unknown_str = f"; {n_unknown} with unknown {type}"
unknown_str = f"; {n_unknown} with unknown {typ}"
else:
unknown_str = ""
return (
Expand Down
4 changes: 2 additions & 2 deletions mne_bids/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def test_parse_ext():
[
"sub-01_ses-02_task-test_run-3_split-1_meg.fif",
"sub-01_ses-02_task-test_run-3_split-1",
"/bids_root/sub-01/ses-02/meg/sub-01_ses-02_task-test_run-3_split-1_meg.fif", # noqa: E501
"/bids_root/sub-01/ses-02/meg/sub-01_ses-02_task-test_run-3_split-1_meg.fif",
"sub-01/ses-02/meg/sub-01_ses-02_task-test_run-3_split-1_meg.fif",
],
)
Expand Down Expand Up @@ -898,7 +898,7 @@ def test_make_filenames():
assert (
basename.basename
== "sub-one_ses-two_task-three_acq-four_run-1_proc-six_rec-seven_ieeg.h5"
) # noqa
)

# what happens with scans.tsv file
with pytest.raises(ValueError, match="scans.tsv file name can only contain"):
Expand Down
Loading

0 comments on commit 1b1ef5d

Please sign in to comment.