Skip to content
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

Expose dither_storage as kwarg #72

Merged
merged 7 commits into from
May 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/import_edf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ grouper(var::Symbol) = grouper((var, ))

# return Samples for each :onda_signal_index
"""
edf_to_onda_samples(edf::EDF.File, plan_table; validate=true)
edf_to_onda_samples(edf::EDF.File, plan_table; validate=true, dither_storage=missing)

Convert Signals found in an EDF File to `Onda.Samples` according to the plan
specified in `plan_table` (e.g., as generated by [`plan_edf_to_onda_samples`](@ref)), returning an
Expand All @@ -507,8 +507,11 @@ not be matched or otherwise caused an error during execution are not returned.

If `validate=true` (the default), the plan is validated against the
[`FilePlanV2`](@ref) schema, and the signal headers in the `EDF.File`.

If `dither_storage=missing` (the default), dither storage is allocated automatically
as specified in the docstring for `Onda.encode`.
kimlaberinto marked this conversation as resolved.
Show resolved Hide resolved
"""
function edf_to_onda_samples(edf::EDF.File, plan_table; validate=true)
function edf_to_onda_samples(edf::EDF.File, plan_table; validate=true, dither_storage=missing)

true_signals = filter(x -> isa(x, EDF.Signal), edf.signals)

Expand Down Expand Up @@ -539,7 +542,7 @@ function edf_to_onda_samples(edf::EDF.File, plan_table; validate=true)
else
signals = [true_signals[row.edf_signal_index] for row in rows]
samples = onda_samples_from_edf_signals(SamplesInfoV2(info), signals,
edf.header.seconds_per_record)
edf.header.seconds_per_record; dither_storage)
end
return (; idx, samples, plan_rows=rows)
catch e
Expand Down Expand Up @@ -620,7 +623,7 @@ a signal, its encoded (usually `Int16`) data is copied directly into the

"""
function onda_samples_from_edf_signals(target::SamplesInfoV2, edf_signals,
edf_seconds_per_record)
edf_seconds_per_record; dither_storage)
kimlaberinto marked this conversation as resolved.
Show resolved Hide resolved
sample_count = length(first(edf_signals).samples)
if !all(length(s.samples) == sample_count for s in edf_signals)
error("mismatched sample counts between `EDF.Signal`s: ", [length(s.samples) for s in edf_signals])
Expand All @@ -639,7 +642,7 @@ function onda_samples_from_edf_signals(target::SamplesInfoV2, edf_signals,
edf_signal.samples)
encoded_samples = Onda.encode(sample_type(target), target.sample_resolution_in_unit,
target.sample_offset_in_unit, decoded_samples,
kimlaberinto marked this conversation as resolved.
Show resolved Hide resolved
missing)
dither_storage)
kimlaberinto marked this conversation as resolved.
Show resolved Hide resolved
else
encoded_samples = edf_signal.samples
end
Expand Down
Loading