Skip to content

Commit

Permalink
correctly track anonymization date of empty room recordings when writ…
Browse files Browse the repository at this point in the history
…ten simultaneously with data (#1270)

* add failing test

* fix bug

* add changelog entry
  • Loading branch information
drammock authored Jul 12, 2024
1 parent f4f903a commit 4c3e753
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The following authors contributed for the first time. Thank you so much! 🤩

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

* `Daniel McCloy`_
* `Stefan Appelhoff`_

Detailed list of changes
Expand All @@ -44,7 +45,7 @@ Detailed list of changes
🪲 Bug fixes
^^^^^^^^^^^^

- nothing yet
- 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`)

⚕️ Code health
^^^^^^^^^^^^^^
Expand Down
5 changes: 4 additions & 1 deletion mne_bids/tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -3151,13 +3151,16 @@ def test_anonymize(subject, dir_name, fname, reader, tmp_path, _bids_validate):
# handle different edge cases
if subject == "emptyroom":
bids_path.update(task="noise", session=raw_date, suffix="meg", datatype="meg")
erm = dict()
else:
bids_path.update(task="task", suffix="eeg", datatype="eeg")
# make sure anonymization works when also writing empty room file
erm = dict(empty_room=raw.copy())
daysback_min, daysback_max = get_anonymization_daysback(raw)
anonymize = dict(daysback=daysback_min + 1)
orig_bids_path = bids_path.copy()
bids_path = write_raw_bids(
raw, bids_path, overwrite=True, anonymize=anonymize, verbose=False
raw, bids_path, overwrite=True, anonymize=anonymize, verbose=False, **erm
)
# emptyroom recordings' session should match the recording date
if subject == "emptyroom":
Expand Down
2 changes: 1 addition & 1 deletion mne_bids/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ def write_raw_bids(
er_bids_path = bids_path.copy().update(
subject="emptyroom", session=er_session, task="noise", run=None
)
write_raw_bids(
er_bids_path = write_raw_bids(
raw=empty_room,
bids_path=er_bids_path,
events=None,
Expand Down

0 comments on commit 4c3e753

Please sign in to comment.