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

Write onsets and durations with more decimal digits #72

Open
wants to merge 5 commits into
base: eph/mne-tests
Choose a base branch
from

Conversation

ericphanson
Copy link
Member

Both Onset and Duration can contain a dot ('.') but only if the fraction of a second is specified (up to arbitrary accuracy).

https://www.edfplus.info/specs/edfplus.html#tal

We are currently subjecting our onsets and durations to the strict 8-char limitation of EDF headers, but that does not seem necessary.

Note this is mostly orthogonal to #70, since that PR does not use scientific notation in TALs anyway (but it does allow underflow-to-zero there, which we can get rid of this way).

# Modify it to have a start time with high precision
edf_high = @set edf.signals[end].records[1][2].onset_in_seconds = 1e-7
@test edf_high.signals[end].records[1][2].onset_in_seconds == 1e-7
py = mne_read(edf_high)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this errors on main (or rather, on #71) because we hit the failed to fit number into EDF's 8 ASCII character limit path in _edf_repr here when going through EDF.write. On this branch it does not error because we just write it out with all digits, even if MNE will round them down later.

@ericphanson
Copy link
Member Author

ericphanson commented Oct 16, 2023

I've realized this totally contradicts the docstring of TimestampAnnotatedList which explicitly rounds for supposed EDF+ compliance. However I keep trying to find where in the spec it says these onsets and durations must be 8 ascii characters and fail to do so. Would love some help @ararslan

@@ -81,7 +81,7 @@ const DATADIR = joinpath(@__DIR__, "data")
[TimestampedAnnotationList(4.0, nothing, String[""]), TimestampedAnnotationList(2.5, 2.5, ["type A"])],
[TimestampedAnnotationList(5.0, nothing, String[""])]]
@test all(signal.records .== expected)
@test AnnotationsSignal(signal.records).samples_per_record == 16
@test AnnotationsSignal(signal.records).samples_per_record == 20
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more bytes per TAL (since more digits) means a higher number here, IIUC

test/runtests.jl Outdated Show resolved Hide resolved
@ericphanson
Copy link
Member Author

This does not help with my actual bug (#74) although I do think we should make sure small durations / onsets are supported. IMO that doesn't need to write them in full precision like this PR though.

@ericphanson
Copy link
Member Author

I incorporated this into #75, there choosing 100ms precision matching EDFlib. But we could allow more precision there too.

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 this pull request may close these issues.

1 participant