bnl.core.Segment
- class bnl.core.Segment(bs, labels=<factory>, *, name=None)[source]
Bases:
TimeSpanAn ordered sequence of boundaries that partition a span into labeled sections.
Represents one layer of annotation. While it inherits from TimeSpan, its start and end attributes are automatically derived from the provided boundaries.
Public Data Attributes:
Label Agreement Matrix
bslabelsstartendPublic Methods:
A list of all the labeled time spans that compose the segment.
itvlsfrom_jams(segment_annotation[, name])Data Ingestion from jams format.
from_itvls(itvls, labels[, name])Data Ingestion from mir_eval format of boundaries and labels.
from_bs(bs[, labels, name])Creates a Segment from a sequence of boundaries and labels.
plot([colorscale, hatch])Plots the segment on a plotly figure by warpping it in a MultiSegment.
scrub_labels([replace_with])Scrubs the labels of the Segment by replacing them with empty strings.
align(span)Align with a TimeSpan object.
- Parameters:
bs (Sequence[Boundary])
labels (Sequence[str])
name (str | None)
- property sections: Sequence[TimeSpan]
A list of all the labeled time spans that compose the segment.
- property lam: ndarray
Label Agreement Matrix
- Returns:
The label agreement matrix.
- Return type:
np.ndarray
- classmethod from_jams(segment_annotation, name=None)[source]
Data Ingestion from jams format.
- Parameters:
segment_annotation (Annotation)
name (str | None)
- Return type:
- classmethod from_itvls(itvls, labels, name=None)[source]
Data Ingestion from mir_eval format of boundaries and labels.
- Parameters:
itvls (Sequence[Sequence[float]])
labels (Sequence[str])
name (str | None)
- Return type:
- classmethod from_bs(bs, labels=None, name=None)[source]
Creates a Segment from a sequence of boundaries and labels.
- plot(colorscale='D3', hatch=True)[source]
Plots the segment on a plotly figure by warpping it in a MultiSegment.
- Parameters:
colorscale (str | list[str])
hatch (bool)
- Return type:
Figure