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
{{ message }}
Repository navigation
Anonymized raw can't be saved: mne.io.anonymize_info() doesn't seem to work on the annotations #7575
When I instantiate a raw object, attach annotations, and I perform mne.io.anonymize_info() after I get an error. I believe this is due to the fact that anonymization doesn't "alter" the annotations. It works fine if I call anonymization before setting annotations.
Possible solutions:
better warning/error message
anonymization to alter the annotations - origtime as well
Steps to reproduce
When I run:
# set a measurement date to allow anonymization to run
raw.set_meas_date(meas_date=datetime.datetime.now(tz=datetime.timezone.utc))
mne.io.anonymize_info(raw.info)
raw.save(tmpfpath)
Actual results
I get the following:
File "/Users/adam2392/Documents/SPORF/mtsmorf/io/run_bids_conversion.py", line 56, in convert_mat_to_bids
raw.save(tmpfpath)
File "<decorator-gen-155>", line 21, in save
File "/Users/adam2392/miniconda3/envs/rf/lib/python3.8/site-packages/mne/io/base.py", line 1345, in save
_write_raw(fname, self, info, picks, fmt, data_type, reset_range,
File "/Users/adam2392/miniconda3/envs/rf/lib/python3.8/site-packages/mne/io/base.py", line 1834, in _write_raw
sk_onsets, sk_ends = _annotations_starts_stops(raw, 'bad_acq_skip')
File "/Users/adam2392/miniconda3/envs/rf/lib/python3.8/site-packages/mne/annotations.py", line 521, in _annotations_starts_stops
onsets = _sync_onset(raw, onsets)
File "/Users/adam2392/miniconda3/envs/rf/lib/python3.8/site-packages/mne/annotations.py", line 495, in _sync_onset
assert raw.info['meas_date'] == raw.annotations.orig_time
`anonymize_info` only anonymizes the `meas_info` object. If you want to
anonymize the `raw` (both the `meas_info` and `annotations`) you need to
call `raw.anonymize()`
Activity
agramfort commentedon Apr 7, 2020
bloyl commentedon Apr 7, 2020
adam2392 commentedon Apr 8, 2020
Awesome. Thanks!