Skip to content

Commit

Permalink
expand byte size of samples_per_record
Browse files Browse the repository at this point in the history
  • Loading branch information
haberdashPI committed Jan 28, 2025
1 parent 151f92f commit c4aab2b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function read_signal_headers(io::IO, signal_count)
strip(fields[i, 3]), parse_float(fields[i, 4]),
parse_float(fields[i, 5]), parse_float(fields[i, 6]),
parse_float(fields[i, 7]), strip(fields[i, 8]),
parse(Int16, fields[i, 9])) for i in 1:size(fields, 1)]
parse(Int32, fields[i, 9])) for i in 1:size(fields, 1)]
skip(io, 32 * signal_count) # reserved
return signal_headers
end
Expand Down
10 changes: 5 additions & 5 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct SignalHeader
digital_minimum::Float32
digital_maximum::Float32
prefilter::String
samples_per_record::Int16
samples_per_record::Int32
end

"""
Expand Down Expand Up @@ -133,11 +133,11 @@ Type representing a single EDF Annotations signal.
# Fields
* `samples_per_record::Int16`
* `samples_per_record::Int32`
* `records::Vector{Vector{TimestampedAnnotationList}}`
"""
struct AnnotationsSignal
samples_per_record::Int16
samples_per_record::Int32
records::Vector{Vector{TimestampedAnnotationList}}
end

Expand All @@ -163,11 +163,11 @@ function AnnotationsSignal(records::Vector{Vector{TimestampedAnnotationList}})
# treated similarly, i.e. the `SignalHeader` is overly trusted).
max_bytes_per_record = maximum(sum(write_tal(IOBuffer(), tal) for tal in record)
for record in records)
return AnnotationsSignal(Int16(cld(max_bytes_per_record, 2)), records)
return AnnotationsSignal(Int32(cld(max_bytes_per_record, 2)), records)
end

function SignalHeader(signal::AnnotationsSignal)
return SignalHeader("EDF Annotations", "", "", -1, 1, -32768, 32767,
return SignalHeader("EDF Annotations", "", "", -1, 1, typemin(Int16), typemax(Int16),
"", signal.samples_per_record)
end

Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ end

@testset "BDF+ Files" begin
# This is a `BDF+` file containing only trigger information.
# It is similiar to a `EDF Annotations` file except that
# It is similiar to a `EDF Annotations` file except that
# The `ANNOTATIONS_SIGNAL_LABEL` is `BDF Annotations`.
# The test data has 1081 trigger events, and
# has 180 trials in total, and
# The test data has 1081 trigger events, and
# has 180 trials in total, and
# The annotation `255` signifies the offset of a trial.
# More information, contact: [email protected]
evt = EDF.read(joinpath(DATADIR, "evt.bdf"))
Expand Down

0 comments on commit c4aab2b

Please sign in to comment.