Repository navigation
FIX: Preserve orig_time and onset when loading CSV annotations with orig_time=None (#8573) - #14503
Open
ishaaaan17 wants to merge 1 commit into
Open
ishaaaan17 wants to merge 1 commit into
ishaaaan17 wants to merge 1 commit into
Conversation
ishaaaan17
requested review from
agramfort,
drammock and
larsoner
as code owners
November 6, 2026 20:32
ishaaaan17
force-pushed
the
fix/annotations-save-csv-orig-time
branch
5 times, most recently
from
November 6, 2026 20:52
e49c9a5 to
41203fd
Compare
ishaaaan17
force-pushed
the
fix/annotations-save-csv-orig-time
branch
from
November 6, 2026 21:06
41203fd to
37f266f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
reference issue (if any)
Fixes #8573
what does this implement/fix?
when annotations are created with
orig_time=None,Annotations.to_data_frame()stores onsets in.csvfiles relative to the default1970-01-01 00:00:00epoch.previously,
_read_annotations_csv():if timestamp == pd.Timestamp(_handle_meas_date(0)).astimezone(None):ondf["onset"].values[0]. when the first annotation hadonset[0] > 0(e.g.onset=[2.5]), this check failed, incorrectly assigningorig_time = 1970-01-01 00:00:02.500000+00:00instead ofNone.(onset_dt - onset_dt[0]).dt.total_seconds(), subtracting the first annotation's timestamp from all rows. this corruptedonset[0]to0.0and shifted all subsequent onsets.this pr:
1970-01-01epoch date and restoresorig_time = None.1970-01-01epoch (onset_dt - epoch) whenorig_time is None, preserving the original onset values across csv save/load round-trips.orig_timeis a valid recording timestamp.test_io_annotationtest inmne/tests/test_annotations.pyto assert round-trip equality whenorig_time is Nonewith non-zero onsets.additional information
mne/tests/test_annotations.pyand annotation tests inmne/io/tests/test_raw.pypass.ruff,ty,codespell,rstcheck) and changelog entry names checker.ai assistance disclosure
i used google antigravity to help investigate the root cause in
_read_annotations_csv, draft the minimal patch, and verify the test suite and pre-commit checks locally.