Skip to content

Commit 8bc956a

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 56b079a commit 8bc956a

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

doc/authors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@
6161
.. _William Turner: https://bootstrapbill.github.io/
6262
.. _Yorguin Mantilla: https://github.com/yjmantilla
6363
.. _Julius Welzel: https://github.com/JuliusWelzel
64-
.. _Kalle Mäkelä: https://github.com/Kallemakela
64+
.. _Kalle Mäkelä: https://github.com/Kallemakela

mne_bids/read.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,9 @@ def _handle_channels_reading(channels_fname, raw, ch_name_mismatch="raise"):
853853
raise RuntimeError(
854854
f"Channel mismatch between {channels_fname} and the raw data file detected."
855855
)
856-
warn(f"Channel mismatch between {channels_fname} and the raw data file detected. Using mismatch strategy: {ch_name_mismatch}.")
856+
warn(
857+
f"Channel mismatch between {channels_fname} and the raw data file detected. Using mismatch strategy: {ch_name_mismatch}."
858+
)
857859
if ch_name_mismatch == "reorder":
858860
raw.reorder_channels(ch_names_tsv)
859861
elif ch_name_mismatch == "rename":
@@ -901,7 +903,12 @@ def _handle_channels_reading(channels_fname, raw, ch_name_mismatch="raise"):
901903

902904
@verbose
903905
def read_raw_bids(
904-
bids_path, extra_params=None, *, return_event_dict=False, ch_name_mismatch="raise", verbose=None
906+
bids_path,
907+
extra_params=None,
908+
*,
909+
return_event_dict=False,
910+
ch_name_mismatch="raise",
911+
verbose=None,
905912
):
906913
"""Read BIDS compatible data.
907914
@@ -1104,7 +1111,9 @@ def read_raw_bids(
11041111
bids_path, suffix="channels", extension=".tsv", on_error="warn"
11051112
)
11061113
if channels_fname is not None:
1107-
raw = _handle_channels_reading(channels_fname, raw, ch_name_mismatch=ch_name_mismatch)
1114+
raw = _handle_channels_reading(
1115+
channels_fname, raw, ch_name_mismatch=ch_name_mismatch
1116+
)
11081117

11091118
# Try to find an associated electrodes.tsv and coordsystem.json
11101119
# to get information about the status and type of present channels

mne_bids/tests/test_read.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
)
3434
from mne_bids.path import _find_matching_sidecar
3535
from mne_bids.read import (
36+
_handle_channels_reading,
3637
_handle_events_reading,
3738
_handle_scans_reading,
38-
_handle_channels_reading,
3939
_read_raw,
4040
events_file_to_annotation_kwargs,
4141
get_head_mri_trans,
@@ -1548,7 +1548,14 @@ def _setup_nirs_channel_mismatch(tmp_path):
15481548
channels_fname = tmp_path / "channels.tsv"
15491549
_to_tsv(channels_dict, channels_fname)
15501550

1551-
return raw, ch_order_snirf, ch_order_bids, channels_fname, orig_name_to_loc, orig_name_to_data
1551+
return (
1552+
raw,
1553+
ch_order_snirf,
1554+
ch_order_bids,
1555+
channels_fname,
1556+
orig_name_to_loc,
1557+
orig_name_to_data,
1558+
)
15521559

15531560

15541561
def test_channel_mismatch_raise(tmp_path):
@@ -1561,14 +1568,18 @@ def test_channel_mismatch_raise(tmp_path):
15611568

15621569

15631570
def test_channel_mismatch_reorder(tmp_path):
1564-
raw, _, ch_order_bids, channels_fname, orig_name_to_loc, orig_name_to_data = _setup_nirs_channel_mismatch(tmp_path)
1571+
raw, _, ch_order_bids, channels_fname, orig_name_to_loc, orig_name_to_data = (
1572+
_setup_nirs_channel_mismatch(tmp_path)
1573+
)
15651574
with (
15661575
pytest.warns(
15671576
RuntimeWarning,
15681577
match=r"Channel mismatch between .*channels\.tsv and the raw data file detected\. Using mismatch strategy: reorder\.",
15691578
),
15701579
):
1571-
raw_out = _handle_channels_reading(channels_fname, raw, ch_name_mismatch="reorder")
1580+
raw_out = _handle_channels_reading(
1581+
channels_fname, raw, ch_name_mismatch="reorder"
1582+
)
15721583
assert raw_out.ch_names == ch_order_bids
15731584
for i, new_name in enumerate(raw_out.ch_names):
15741585
np.testing.assert_allclose(
@@ -1580,14 +1591,23 @@ def test_channel_mismatch_reorder(tmp_path):
15801591

15811592

15821593
def test_channel_mismatch_rename(tmp_path):
1583-
raw, ch_order_snirf, ch_order_bids, channels_fname, orig_name_to_loc, orig_name_to_data = _setup_nirs_channel_mismatch(tmp_path)
1594+
(
1595+
raw,
1596+
ch_order_snirf,
1597+
ch_order_bids,
1598+
channels_fname,
1599+
orig_name_to_loc,
1600+
orig_name_to_data,
1601+
) = _setup_nirs_channel_mismatch(tmp_path)
15841602
with (
15851603
pytest.warns(
15861604
RuntimeWarning,
15871605
match=r"Channel mismatch between .*channels\.tsv and the raw data file detected\. Using mismatch strategy: rename\.",
15881606
),
15891607
):
1590-
raw_out_rename = _handle_channels_reading(channels_fname, raw.copy(), ch_name_mismatch="rename")
1608+
raw_out_rename = _handle_channels_reading(
1609+
channels_fname, raw.copy(), ch_name_mismatch="rename"
1610+
)
15911611
assert raw_out_rename.ch_names == ch_order_bids
15921612
for i in range(len(ch_order_bids)):
15931613
orig_name_at_i = ch_order_snirf[i]

0 commit comments

Comments
 (0)