Skip to content

Commit

Permalink
add recording as optional field to OndaEDF.PlanV[12] (#63)
Browse files Browse the repository at this point in the history
* add `recording` as optional field to OndaEDF.PlanV[12]

* whoops

* need UUIDs

* fix test

* restrict ismissing check to only encoding relevant fields
  • Loading branch information
kleinschmidt authored Jan 27, 2023
1 parent 0a6a5c8 commit 8892400
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
3 changes: 2 additions & 1 deletion OndaEDFSchemas.jl/Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name = "OndaEDFSchemas"
uuid = "9c87d999-769b-4741-85b2-6f554d09e731"
authors = ["Beacon Biosignals, Inc."]
version = "0.2.1"
version = "0.2.2"

[deps]
Legolas = "741b9549-f6ed-4911-9fbf-4a1c0c97f0cd"
Onda = "e853f5be-6863-11e9-128d-476edb89bfb5"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Legolas = "0.5.5"
Expand Down
14 changes: 9 additions & 5 deletions OndaEDFSchemas.jl/src/OndaEDFSchemas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using Onda: LPCM_SAMPLE_TYPE_UNION, onda_sample_type_from_julia_type,
convert_number_to_lpcm_sample_type, _validate_signal_channel,
_validate_signal_sensor_label, _validate_signal_sensor_type,
AnnotationV1
using UUIDs

export PlanV1, PlanV2, FilePlanV1, FilePlanV2, EDFAnnotationV1

Expand All @@ -23,7 +24,8 @@ export PlanV1, PlanV2, FilePlanV1, FilePlanV2, EDFAnnotationV1
samples_per_record::Int16
# EDF.FileHeader field
seconds_per_record::Float64
# Onda.SamplesInfoV1 fields (channels -> channel), may be missing
# Onda.SignalV1 fields (channels -> channel), may be missing
recording::Union{UUID,Missing} = lift(UUID, recording)
kind::Union{Missing,AbstractString} = lift(String, kind)
channel::Union{Missing,AbstractString} = lift(String, channel)
sample_unit::Union{Missing,AbstractString} = lift(String, sample_unit)
Expand All @@ -48,7 +50,8 @@ end
samples_per_record::Int16
# EDF.FileHeader field
seconds_per_record::Float64
# Onda.SamplesInfoV2 fields (channels -> channel), may be missing
# Onda.SignalV2 fields (channels -> channel), may be missing
recording::Union{UUID,Missing} = lift(UUID, recording)
sensor_type::Union{Missing,AbstractString} = lift(_validate_signal_sensor_type, sensor_type)
sensor_label::Union{Missing,AbstractString} = lift(_validate_signal_sensor_label,
coalesce(sensor_label, sensor_type))
Expand Down Expand Up @@ -78,7 +81,8 @@ const PLAN_DOC_TEMPLATE = """
samples_per_record::Int16
# EDF.FileHeader field
seconds_per_record::Float64
# Onda.SamplesInfo fields (channels -> channel), may be missing
# Onda.SignalV{{ VERSION }} fields (channels -> channel), may be missing
recording::Union{UUID,Missing} = passmissing(UUID)
{{ SAMPLES_INFO_UNIQUE_FIELDS }}
channel::Union{Missing,AbstractString}
sample_unit::Union{Missing,AbstractString}
Expand All @@ -94,8 +98,8 @@ A Legolas-generated record type describing a single EDF signal-to-Onda channel
conversion. The columns are the union of
- fields from `EDF.SignalHeader` (all mandatory)
- the `seconds_per_record` field from `EDF.FileHeader` (mandatory)
- fields from `Onda.SamplesInfoV{{ VERSION }}` (optional, may be `missing` to indicate failed
conversion)
- fields from `Onda.SignalV{{ VERSION }}` (optional, may be `missing` to indicate failed
conversion), except for `file_path`
- `error`, which is `nothing` for a conversion that is or is expected to be
successful, and a `String` describing the source of the error (with backtrace)
in the case of a caught error.
Expand Down
1 change: 1 addition & 0 deletions OndaEDFSchemas.jl/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function mock_plan(; v, rng=GLOBAL_RNG)
sample_type=ingested ? "float32" : missing,
sample_rate=ingested ? 1/128 : missing,
error=errored ? "Error blah blah" : nothing,
recording= (ingested && rand(rng, Bool)) ? uuid4() : missing,
specific_kwargs...)
end

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OndaEDF"
uuid = "e3ed2cd1-99bf-415e-bb8f-38f4b42a544e"
authors = ["Beacon Biosignals, Inc."]
version = "0.11.0"
version = "0.11.1"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
9 changes: 8 additions & 1 deletion src/import_edf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,14 @@ is thrown. If sample rates/offests are not equal, then `pick_offset` and
This is an internal function and is not meant to be called direclty.
"""
function promote_encodings(encodings; pick_offset=(_ -> 0.0), pick_resolution=minimum)
if any(any(ismissing, row) for row in encodings)
encoding_fields = (:sample_rate,
:sample_offset_in_unit,
:sample_resolution_in_unit,
:sample_type)
if any(ismissing,
getproperty(row, p)
for p in encoding_fields
for row in encodings)
return (; sample_type=missing,
sample_offset_in_unit=missing,
sample_resolution_in_unit=missing,
Expand Down

4 comments on commit 8892400

@kleinschmidt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=OndaEDFSchemas.jl

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/76532

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a OndaEDFSchemas.jl-v0.2.2 -m "<description of version>" 8892400d83e1aa5f093808bf29bfa4ac952e264b
git push origin OndaEDFSchemas.jl-v0.2.2

@kleinschmidt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/76533

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.1 -m "<description of version>" 8892400d83e1aa5f093808bf29bfa4ac952e264b
git push origin v0.11.1

Please sign in to comment.