diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000..857c3ae --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1 @@ +style = "yas" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1e05dd..246909a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: version: - - '1.4' # Earliest supported version + - '1.6' # Earliest supported version - '1' # Latest release - 'nightly' os: diff --git a/Project.toml b/Project.toml index 9deffef..4a13b02 100644 --- a/Project.toml +++ b/Project.toml @@ -9,13 +9,17 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" [compat] +Accessors = "0.1" BitIntegers = "0.2" FilePathsBase = "0.9.13" -julia = "1.4" +PyMNE = "0.2.2" +julia = "1.6" [extras] +Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f" +PyMNE = "6c5003b2-cbe8-491c-a0d1-70088e6a0fd6" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["FilePathsBase", "Test"] +test = ["Accessors", "FilePathsBase", "PyMNE", "Test"] diff --git a/test/runtests.jl b/test/runtests.jl index 3a35121..450ecbb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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(), @@ -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 + + py = mne_read(edf) + @test isempty(py.annotations) + end end @testset "BDF+ Files" begin