question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] set_annotations fails for data with a meas_date prior to 1970

See original GitHub issue

Try 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:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sappelhoffcommented, Aug 5, 2019

@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_days would be set to a sensible default but could also be given as an input to raw.annonymize(anonymization_offset_days=36500)

I briefly discussed this with @larsoner at the last MNE sprint, maybe he wants to weigh in

1reaction
agramfortcommented, Aug 2, 2019

If there is no limitations with fif files to have negative time stamps we should handle these files smoothly

Read more comments on GitHub >

github_iconTop Results From Across the Web

Time formatting and storage bugs - Wikipedia
In computer science, time formatting and storage bugs are a class of software bugs that may cause time and date calculation or display...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found