-
Notifications
You must be signed in to change notification settings - Fork 5
Test MNE can read our exports #71
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
base: main
Are you sure you want to change the base?
Changes from 7 commits
1ede0f1
85bcd38
1c43bee
22851be
5654070
ae560b3
fa72af4
e06d13f
b62e8f8
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
style = "yas" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ using EDF: TimestampedAnnotationList, PatientID, RecordingID, SignalHeader, | |
using Dates | ||
using FilePathsBase | ||
using Test | ||
using PyMNE | ||
using Accessors | ||
|
||
##### | ||
##### Testing utilities | ||
|
@@ -33,6 +35,17 @@ end | |
|
||
deep_equal(a::T, b::S) where {T,S} = false | ||
|
||
function mne_read(edf) | ||
tmpfile = joinpath(mktempdir(), "test.edf") | ||
EDF.write(tmpfile, edf) | ||
# Check we can load it and do something with it | ||
py = PyMNE.io.read_raw_edf(tmpfile; verbose=false) | ||
py.load_data(; verbose=false) | ||
data = pyconvert(Array, py.get_data()) | ||
@test data isa Matrix | ||
return py | ||
end | ||
|
||
##### | ||
##### Actual tests | ||
##### | ||
|
@@ -93,6 +106,14 @@ const DATADIR = joinpath(@__DIR__, "data") | |
EDF.read!(file) | ||
@test deep_equal(edf.signals, file.signals) | ||
|
||
# Check we can read it into MNE | ||
py = mne_read(edf) | ||
@test length(py.annotations) == 5 | ||
ann = py.annotations[1] | ||
@test pyconvert(Float64, ann["onset"]) == 0.1344 | ||
@test pyconvert(Float64, ann["duration"]) == 0.256 | ||
@test pyconvert(String, ann["description"]) == "type A" | ||
|
||
# test that EDF.write(::IO, ::EDF.File) errors if file is | ||
# discontiguous w/o an AnnotationsSignal present | ||
bad_file = EDF.File(IOBuffer(), | ||
|
@@ -182,7 +203,7 @@ const DATADIR = joinpath(@__DIR__, "data") | |
@test_logs((:warn, | ||
"Number of data records in file header does not match " * | ||
"file size. Skipping 1 truncated data record(s)."), | ||
EDF.read(truncated_file)) | ||
EDF.read(truncated_file)) | ||
edf = EDF.read(joinpath(DATADIR, full_file)) | ||
truncated_edf = EDF.read(truncated_file) | ||
for field in fieldnames(EDF.FileHeader) | ||
|
@@ -253,6 +274,15 @@ const DATADIR = joinpath(@__DIR__, "data") | |
edf = EDF.File(io) | ||
@test sprint(show, edf) == "EDF.File with 140 16-bit-encoded signals" | ||
end | ||
|
||
@testset "Exports readable by MNE" begin | ||
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 | ||
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. I don't understand what the purpose of this is. If it's necessary for testing a particular behavior, can you add a comment? I think it's the only use of Accessors here so if it's not actually necessary then dropping it would reduce the number of test dependencies. 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 PR was meant to complement #72 which uses Accessors more extensively in the tests however I no longer remember what the point of this line is anymore :/ |
||
|
||
py = mne_read(edf) | ||
@test isempty(py.annotations) | ||
end | ||
end | ||
|
||
@testset "BDF+ Files" begin | ||
|
Uh oh!
There was an error while loading. Please reload this page.