[BUG] set_annotations fails for data with a meas_date prior to 1970
See original GitHub issueTry reading this example_file (800MB) and check out raw.info['meas_date'] --> it will be negative.
That’s because the data has been anonymized (cc @agramfort ) to some time prior 1970.
That’s an issue, because we represent raw.info['meas_date'] in unix time, which is 0 at 1970, and thus negative for all prior years (strictly speaking, it’s even undefined)
A negative meas_date will raise an error when we make an annotation object from scratch and try to set it with raw.set_annotations().
That is because of this code:
in set_annotations: https://github.com/mne-tools/mne-python/blob/368a490f9d7a298050ee04c2aa7882629c9fab21/mne/io/base.py#L792
–> time_of_first_sample will be negative if meas_date is negative
then later we do: https://github.com/mne-tools/mne-python/blob/368a490f9d7a298050ee04c2aa7882629c9fab21/mne/io/base.py#L798-L801
i.e., pass a negative tmin to the crop function, which then raises an error: https://github.com/mne-tools/mne-python/blob/368a490f9d7a298050ee04c2aa7882629c9fab21/mne/annotations.py#L363-L364
cc @massich
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)

Top Related StackOverflow Question
@massich see: https://github.com/mne-tools/mne-bids/issues/193#issue-436776387
I don’t know about how anonymization is currently handled in MNE, but I think the way we SHOULD handle this is to allow for an anonymization by a certain offset in days … this would then be applied to all data recordings of a subject, so that the relative time distances keep their logic.
the
anonymization_offset_dayswould be set to a sensible default but could also be given as an input toraw.annonymize(anonymization_offset_days=36500)I briefly discussed this with @larsoner at the last MNE sprint, maybe he wants to weigh in
If there is no limitations with fif files to have negative time stamps we should handle these files smoothly