You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
calling write_raw_bids(..., anonymize=dict(daysback=<some_positive_integer>), empty_room=<some_Raw_object>) fails, because the ERM will be written at sub-emptyroom/ses-<some_date_far_in_the_past>, but the subsequent call to actually write the Raw data file will try to find the empty room based on the value of the ERM's BidsPath before anonymization.
In [1]: importmneIn [2]: frommne_bidsimportwrite_raw_bids, BIDSPathIn [3]: fdir=mne.datasets.sample.data_path()
In [4]: fpath= (fdir/'MEG'/'sample'/'sample_audvis_raw.fif')
In [5]: raw=mne.io.read_raw(fpath, preload=False, verbose=False)
In [6]: erm=raw.copy() # fake ERM just for demo purposesIn [7]: bp=BIDSPath(subject="sample", root=".", task="foo")
In [8]: write_raw_bids(raw=raw, empty_room=erm, bids_path=bp, anonymize=dict(daysback=23456))
Expected results
writing succeeds
Actual results
Here's the output and traceback
<ipython-input-8-84bb36779bc7>:1: RuntimeWarning: `daysback` is too small; the measurement date is after 1925, which is not recommended by BIDS.The minimum `daysback` value for changing the measurement date of this data to before this date is 28461
write_raw_bids(raw=raw, empty_room=erm, bids_path=bp, anonymize=dict(daysback=23456))
Writing './README'...
Writing './participants.tsv'...
Writing 'participants.json'...
Writing of electrodes.tsv is not supported for data type "meg". Skipping ...
Writing './dataset_description.json'...
Writing 'sub-emptyroom/ses-19380914/meg/sub-emptyroom_ses-19380914_task-noise_meg.json'...
Writing 'sub-emptyroom/ses-19380914/meg/sub-emptyroom_ses-19380914_task-noise_channels.tsv'...
Copying data files to sub-emptyroom_ses-19380914_task-noise_meg.fif
Reserving possible split file sub-emptyroom_ses-19380914_task-noise_split-01_meg.fif
Writing /home/drmccloy/sub-emptyroom/ses-19380914/meg/sub-emptyroom_ses-19380914_task-noise_meg.fif
Closing /home/drmccloy/sub-emptyroom/ses-19380914/meg/sub-emptyroom_ses-19380914_task-noise_meg.fif
[done]
Writing 'sub-emptyroom/ses-19380914/sub-emptyroom_ses-19380914_scans.tsv'...
Wrote sub-emptyroom/ses-19380914/sub-emptyroom_ses-19380914_scans.tsv entry with meg/sub-emptyroom_ses-19380914_task-noise_meg.fif.
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[8], line 1
----> 1 write_raw_bids(raw=raw, empty_room=erm, bids_path=bp, anonymize=dict(daysback=23456))
File <decorator-gen-447>:12, in write_raw_bids(raw, bids_path, events, event_id, anonymize, format, symlink, empty_room, allow_preload, montage, acpc_aligned, overwrite, events_data, verbose)
File /opt/mne/bids/mne_bids/write.py:1854, in write_raw_bids(raw, bids_path, events, event_id, anonymize, format, symlink, empty_room, allow_preload, montage, acpc_aligned, overwrite, events_data, verbose)
1852 if associated_er_path is not None:
1853 if not associated_er_path.exists():
-> 1854 raise FileNotFoundError(
1855 f"Empty-room data file not found: " f"{associated_er_path}"
1856 )
1858 # Turn it into a path relative to the BIDS root
1859 associated_er_path = Path(
1860 str(associated_er_path).replace(str(bids_path.root), "")
1861 )
FileNotFoundError: Empty-room data file not found: sub-emptyroom/ses-20021203/meg/sub-emptyroom_ses-20021203_task-noise_meg.fif
Description of the problem
calling
write_raw_bids(..., anonymize=dict(daysback=<some_positive_integer>), empty_room=<some_Raw_object>)
fails, because the ERM will be written atsub-emptyroom/ses-<some_date_far_in_the_past>
, but the subsequent call to actually write the Raw data file will try to find the empty room based on the value of the ERM's BidsPath before anonymization.I think the culprit is basically this line:
mne-bids/mne_bids/write.py
Line 1831 in 313fe10
Steps to reproduce
Expected results
writing succeeds
Actual results
Here's the output and traceback
Additional information
The text was updated successfully, but these errors were encountered: