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

Improve schema version docstrings #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
51 changes: 27 additions & 24 deletions src/annotations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

@schema "onda.annotation" Annotation

"""
AnnotationV1

A [Legolas](https://github.com/beacon-biosignals/Legolas.jl)-generated record type
implementing the [`onda.annotation@1`](https://github.com/beacon-biosignals/Onda.jl##ondaannotation1)
specification as described by the [Onda Format Specification](https://github.com/beacon-biosignals/Onda.jl#the-onda-format-specification).

# Required Fields

- `recording::UUID`: The UUID identifying the recording with which the annotation is
associated.
- `id::UUID`: The UUID identifying the annotation.
- `span::TimeSpan`: The annotation's time span within the recording.
"""
AnnotationV1

@version AnnotationV1 begin
recording::UUID = UUID(recording)
id::UUID = UUID(id)
Expand All @@ -12,19 +28,6 @@ end

Legolas.accepted_field_type(::AnnotationV1SchemaVersion, ::Type{TimeSpan}) = Union{NamedTupleTimeSpan,TimeSpan}

"""
@version AnnotationV1 begin
recording::UUID
id::UUID
span::TimeSpan
end

A Legolas-generated record type representing an [`onda.annotation` as described by the Onda Format Specification](https://github.com/beacon-biosignals/Onda.jl##ondaannotation1).

See https://github.com/beacon-biosignals/Legolas.jl for details regarding Legolas record types.
"""
AnnotationV1

"""
validate_annotations(annotations)

Expand All @@ -45,24 +48,24 @@ validate_annotations(annotations) = _fully_validate_legolas_table(:validate_anno

@schema "onda.merged-annotation" MergedAnnotation

@version MergedAnnotationV1 > AnnotationV1 begin
from::Vector{UUID}
end

"""
@version MergedAnnotationV1 > AnnotationV1 begin
from::Vector{UUID}
end
MergedAnnotationV1 > AnnotationV1

A [Legolas](https://github.com/beacon-biosignals/Legolas.jl)-generated record type
representing an annotation derived from "merging" one or more existing annotations.

A Legolas-generated record type representing an annotation derived from "merging" one or more existing annotations.
# Required Fields

This record type extends `AnnotationV1` with a single additional required field, `from::Vector{UUID}`, whose entries
are the `id`s of the annotation's source annotation(s).
All fields required by [`AnnotationV1`](@ref), and:

See https://github.com/beacon-biosignals/Legolas.jl for details regarding Legolas record types.
- `from::Vector{UUID}`: The `id`s of the annotation's source annotation(s).
"""
MergedAnnotationV1

@version MergedAnnotationV1 > AnnotationV1 begin
from::Vector{UUID}
end

"""
merge_overlapping_annotations([predicate=TimeSpans.overlaps,] annotations)

Expand Down
86 changes: 45 additions & 41 deletions src/signals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,29 @@ end

@schema "onda.samples-info" SamplesInfo

"""
SamplesInfoV2

A [Legolas](https://github.com/beacon-biosignals/Legolas.jl)-generated record type
representing the bundle of [`onda.signal@2`](https://github.com/beacon-biosignals/Onda.jl#ondasignal2)
fields that are intrinsic to a signal's sample data, leaving out extrinsic file or recording
information. This is useful when the latter information is irrelevant or does not yet exist
(e.g. if sample data is being constructed/manipulated in-memory without yet having been
serialized).

# Required Fields

- `sensor_type::String`
- `sensor_type::String`
- `channels::Vector{String}`
- `sample_unit::String`
- `sample_resolution_in_unit::Float64`
- `sample_offset_in_unit::Float64`
- `sample_type::String`
- `sample_rate::Float64`
"""
SamplesInfoV2

@version SamplesInfoV2 begin
sensor_type::String
channels::Vector{String}
Expand All @@ -86,26 +109,6 @@ end
Legolas.accepted_field_type(::SamplesInfoV2SchemaVersion, ::Type{String}) = AbstractString
Legolas.accepted_field_type(::SamplesInfoV2SchemaVersion, ::Type{Vector{String}}) = AbstractVector{<:AbstractString}

"""
@version SamplesInfoV2 begin
sensor_type::String
channels::Vector{String}
sample_unit::String
sample_resolution_in_unit::Float64
sample_offset_in_unit::Float64
sample_type::String = onda_sample_type_from_julia_type(sample_type)
sample_rate::Float64
end

A Legolas-generated record type representing the bundle of `onda.signal` fields that are intrinsic to a
signal's sample data, leaving out extrinsic file or recording information. This is useful when the latter
information is irrelevant or does not yet exist (e.g. if sample data is being constructed/manipulated in-memory
without yet having been serialized).

See https://github.com/beacon-biosignals/Legolas.jl for details regarding Legolas record types.
"""
SamplesInfoV2

# xref https://github.com/beacon-biosignals/Legolas.jl/issues/61
Base.copy(info::SamplesInfoV2) = SamplesInfoV2(; info.sensor_type, channels=copy(info.channels),
info.sample_unit, info.sample_resolution_in_unit,
Expand All @@ -118,6 +121,28 @@ Base.copy(info::SamplesInfoV2) = SamplesInfoV2(; info.sensor_type, channels=copy

@schema "onda.signal" Signal

"""
SignalV2 > SamplesInfoV2

A [Legolas](https://github.com/beacon-biosignals/Legolas.jl)-generated record type
implementing the [`onda.signal@2`](https://github.com/beacon-biosignals/Onda.jl##ondasignal2)
specification as described by the [Onda Format Specification](https://github.com/beacon-biosignals/Onda.jl#the-onda-format-specification).

# Required Fields

All fields required by [`SamplesInfoV2`](@ref), and:

- `recording::UUID`
- `file_path::(<:Any)`
- `file_format::String`
- `span::TimeSpan`
- `sensor_label::String`
- `sensor_type::String`
- `channels::Vector{String}`
- `sample_unit::String`
"""
SignalV2

@version SignalV2 > SamplesInfoV2 begin
recording::UUID = UUID(recording)
file_path::(<:Any)
Expand All @@ -133,27 +158,6 @@ Legolas.accepted_field_type(::SignalV2SchemaVersion, ::Type{TimeSpan}) = Union{N
Legolas.accepted_field_type(::SignalV2SchemaVersion, ::Type{String}) = AbstractString
Legolas.accepted_field_type(::SignalV2SchemaVersion, ::Type{Vector{String}}) = AbstractVector{<:AbstractString}

"""
@version SignalV2 > SamplesInfoV2 begin
recording::UUID
file_path::(<:Any)
file_format::String
span::TimeSpan
sensor_label::String
sensor_type::String
channels::Vector{String}
sample_unit::String
end

A Legolas-generated record type representing an [`onda.signal` as described by the Onda Format Specification](https://github.com/beacon-biosignals/Onda.jl##ondasignal2).

Note that some fields documented as required fields of `onda.signal@2` in the Onda Format Specification
are captured via this schema version's extension of `SamplesInfoV2`.

See https://github.com/beacon-biosignals/Legolas.jl for details regarding Legolas record types.
"""
SignalV2

"""
validate_signals(signals)

Expand Down