-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: eph/mne-tests
Are you sure you want to change the base?
Changes from 4 commits
7dc31ca
9b08549
c5cd5c1
644dc04
d2bd69c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
end | ||
end | ||
|
||
|
@@ -108,6 +108,23 @@ const DATADIR = joinpath(@__DIR__, "data") | |
@test pyconvert(Float64, ann["duration"]) == 0.256 | ||
@test pyconvert(String, ann["description"]) == "type A" | ||
|
||
# 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this errors on main (or rather, on #71) because we hit the |
||
ann = py.annotations[0] | ||
# MNE drops the precision, but doesn't error | ||
@test pyconvert(Float64, ann["onset"]) == 0 | ||
@test pyconvert(Float64, ann["duration"]) == 0 | ||
|
||
edf_high = @set edf.signals[end].records[1][2].onset_in_seconds = 0.1055043123123120 | ||
@test edf_high.signals[end].records[1][2].onset_in_seconds == 0.1055043123123120 | ||
py = mne_read(edf_high) | ||
ann = py.annotations[0] | ||
# MNE doesn't read it in with the last digit, but it also doesn't error: | ||
@test pyconvert(Float64, ann["onset"]) == 0.105504 | ||
@test pyconvert(Float64, ann["duration"]) == 0 | ||
|
||
# test that EDF.write(::IO, ::EDF.File) errors if file is | ||
# discontiguous w/o an AnnotationsSignal present | ||
bad_file = EDF.File(IOBuffer(), | ||
|
@@ -133,13 +150,6 @@ const DATADIR = joinpath(@__DIR__, "data") | |
@test eof(io) | ||
end | ||
|
||
@test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-0.0023405432)) == "-0.00234" | ||
@test EDF._edf_repr(EDF._nearest_representable_edf_time_value(0.0023405432)) == "0.002340" | ||
@test EDF._edf_repr(EDF._nearest_representable_edf_time_value(1.002343)) == "1.002343" | ||
@test EDF._edf_repr(EDF._nearest_representable_edf_time_value(1011.05432)) == "1011.054" | ||
@test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-1011.05432)) == "-1011.05" | ||
@test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-1013441.5)) == "-1013442" | ||
@test EDF._edf_repr(EDF._nearest_representable_edf_time_value(-1013441.3)) == "-1013441" | ||
@test EDF._edf_repr(34577777) == "34577777" | ||
@test EDF._edf_repr(0.0345) == "0.034500" | ||
@test EDF._edf_repr(-0.02) == "-0.02000" | ||
|
@@ -267,7 +277,7 @@ const DATADIR = joinpath(@__DIR__, "data") | |
edf = EDF.read(joinpath(DATADIR, "test_float_extrema.edf")) | ||
@test edf.signals[1].header.digital_minimum ≈ -32767.0f0 | ||
edf = @set edf.signals[1].header.digital_minimum = -32767 * 2 | ||
|
||
@test edf.signals[1].header.digital_minimum == -32767 * 2 # double-check it got set | ||
ericphanson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
py = mne_read(edf) | ||
@test isempty(py.annotations) | ||
end | ||
|
There was a problem hiding this comment.
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