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

Anonymized raw can't be saved: mne.io.anonymize_info() doesn't seem to work on the annotations #7575

Closed
adam2392 opened this issue Apr 7, 2020 · 3 comments · Fixed by #7587

Comments

@adam2392
Copy link
Member

adam2392 commented Apr 7, 2020

Describe the bug

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:

  1. better warning/error message
  2. 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

Additional information

Using v0.20

@agramfort
Copy link
Member

agramfort commented Apr 7, 2020 via email

@bloyl
Copy link
Contributor

bloyl commented Apr 7, 2020 via email

@adam2392
Copy link
Member Author

adam2392 commented Apr 8, 2020

Awesome. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants