Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed string subID bug #1291

Merged
merged 8 commits into from
Aug 24, 2024
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
5 changes: 4 additions & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ authors:
orcid: 'https://orcid.org/0000-0001-6364-7272'
- given-names: Thomas
family-names: Hartmann
affiliation: 'Paris-Lodron-University Salzburg, Centre for Cogntitive Neuroscience, Department of Psychology, Salzburg, Austria'
affiliation: 'Paris-Lodron-University Salzburg, Centre for Cognitive Neuroscience, Department of Psychology, Salzburg, Austria'
orcid: 'https://orcid.org/0000-0002-8298-8125'
- given-names: Aaron
family-names: Earle-Richardson
affiliation: 'Duke University School of Medicine, Department of Neurology'
- 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
@@ -1,3 +1,4 @@
.. _Aaron Earle-Richardson: https://github.com/Aaronearlerichardson
.. _Mainak Jas: https://jasmainak.github.io/
.. _Teon Brooks: https://teonbrooks.com
.. _Chris Holdgraf: https://bids.berkeley.edu/people/chris-holdgraf
Expand Down
4 changes: 3 additions & 1 deletion doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ Version 0.16 (unreleased)

The following authors contributed for the first time. Thank you so much! 🤩

* `Kaare Mikkelsen`_
* `Aaron Earle-Richardson`_
* `Amaia Benitez`_
* `Kaare Mikkelsen`_
* `Thomas Hartmann`_

The following authors had contributed before. Thank you for sticking around! 🤘
Expand Down Expand Up @@ -53,6 +54,7 @@ Detailed list of changes
^^^^^^^^^^^^

- When anonymizing the date of a recording, MNE-BIDS will no longer error during `~mne_bids.write_raw_bids` if passing a `~mne.io.Raw` instance to ``empty_room``, by `Daniel McCloy`_ (:gh:`1270`)
- Dealing with alphanumeric ``sub`` entity labels is now fixed for :func:`~mne_bids.write_raw_bids`, by `Aaron Earle-Richardson`_ (:gh:`1291`)

⚕️ Code health
^^^^^^^^^^^^^^
Expand Down
7 changes: 4 additions & 3 deletions mne_bids/tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,16 @@ def test_write_participants(_bids_validate, tmp_path):
_to_tsv(data, participants_tsv)

# write in now another subject
bids_path.update(subject="03")
# (use alphanumeric label to test for GH-1291)
bids_path.update(subject="D03")
write_raw_bids(raw, bids_path, verbose=False)
data = _from_tsv(participants_tsv)

# hand should have been written properly with now 'n/a' for sub-01 and
# sub-03, but 'L' for sub-03
# sub-02, but 'L' for sub-D03
assert data["hand"][data["participant_id"].index("sub-01")] == "n/a"
assert data["hand"][data["participant_id"].index("sub-02")] == "n/a"
assert data["hand"][data["participant_id"].index("sub-03")] == "L"
assert data["hand"][data["participant_id"].index("sub-D03")] == "L"

# check to make sure participant data is overwritten, but keeps the fields
# if there are extra fields that were user defined
Expand Down
4 changes: 2 additions & 2 deletions mne_bids/tsv_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def _contains_row(data, row_data):
# Cast row_value to the same dtype as data_value to avoid a NumPy
# FutureWarning, see
# https://github.com/mne-tools/mne-bids/pull/372
row_value = np.array(row_value, dtype=data_value.dtype)

if data_value.size > 0:
row_value = np.array(row_value, dtype=data_value.dtype)
column_mask = np.isin(data_value, row_value)
mask = column_mask if mask is None else (mask & column_mask)
return np.any(mask)
Expand Down