Writing an .edf File using EDF.jl

Hi, I am trying to create a .edf file using the EDF.jl package , but i run into issues during File creation; I get a Method Error in calling EDF.File

ERROR: MethodError: no method matching EDF.File(::IOStream, ::EDF.FileHeade
r, ::Vector{EDF.Signal{Int16}})
Closest candidates are:
  EDF.File(::I, ::EDF.FileHeader, ::Array{Union{EDF
Signal{T}}, 1}) where {T<:Union{Int16, EDF.Int24}, 

I tried to be as type cautious as possible by initializing explicitly an Array , but to no avail
the File method insists i pass the wrong type.
Minimum Reproducible Examle:

using EDF
using Dates

# some random example data
data_matrix = round.(rand(0.0:400.0,15,9000))

## Header Creation 
header = EDF.FileHeader(
    "0.0",  # EDF version (0.0 for EDF+)
    "Simulation01",  # Patient ID
    "Recording001",  # Recording ID
    now(),  # t0
    true,  #contiguous
    1,  #  num of records 
    9000.0  # Duration
)


## Signals
signal_labels = string.(collect('A':'Z')[1:15])
signals = Array{EDF.Signal{Int16},1}(undef,15)

for (i,label) in enumerate(signal_labels)
    signal_header = EDF.SignalHeader(
        label,                          
        "EEG",                         
        "V",                            
        Float32(-100.0f0),                        
        Float32(100.0f0),                        
        Float32(-32768.0f0),                   
        Float32(32767.0f0),                      
        "No filter",                    
        Int32(9000)                     
    )
    signal = EDF.Signal{Int16}(signal_header,data_matrix[i,:] )
    push!(signals,signal)
end

print(typeof(signals)) # should be fine?!
Vector{EDF.Signal{Int16}} # (alias for Array{EDF.Signal{Int16}, 1})

output_file = "example_data.edf"
io = open(output_file, "w")

edf_file = EDF.File(io, header, signals)
## Method error!!

EDF.write(io, edf_file)
close(io)

here the issue is actually that EDF.jl wants a more flexible type than Vector{EDF.Signal{Int16}}. You can use

signals = collect(Union{EDF.AnnotationsSignal, eltype(signals)}, signals)

to change the type post-hoc, or initialize it as

signals = Array{Union{EDF.AnnotationsSignal, EDF.Signal{Int16}},1}(undef,15)

This is not very ergonomic from EDF.jl but the MethodError is trying to tell you the type isn’t what it expects and that it needs that union:

julia> edf_file = EDF.File(io, header, signals)
ERROR: MethodError: no method matching EDF.File(::IOStream, ::EDF.FileHeader, ::Vector{EDF.Signal{Int16}})
The type `EDF.File` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  EDF.File(::I, ::EDF.FileHeader, ::Array{Union{EDF.AnnotationsSignal, EDF.Signal{T}}, 1}) where {T<:Union{Int16, EDF.Int24}, I<:IO}
   @ EDF ~/.julia/packages/EDF/ueatx/src/types.jl:266
  EDF.File(::IO)
   @ EDF ~/.julia/packages/EDF/ueatx/src/read.jl:204

Stacktrace:
 [1] top-level scope
   @ REPL[13]:1

One other note is that you can use the do-block form of open to automatically close the file even in the case of exceptions:

open(output_file, "w") do io
    edf_file = EDF.File(io, header, signals)
    EDF.write(io, edf_file)
end