bnl.core.MultiSegment
- class bnl.core.MultiSegment(raw_layers=<factory>, *, name=None)[source]
Bases:
TimeSpanThe primary input object for analysis, containing multiple Segment layers.
Public Data Attributes:
Returns a list of all the intervals for each layer in the MultiSegment.
Returns a list of all the labels for each layer in the MultiSegment.
A sequence of Segment objects representing different layers of annotation.
startendnamePublic Methods:
Returns the layers aligned to a unified time span.
from_json(json_data[, name])Data Ingestion from adobe json format.
from_itvls(itvls, labels[, name])plot([colorscale, hatch])Plots the MultiSegment on a Plotly figure.
contour([strategy])Calculates boundary salience and converts to a BoundaryContour.
Scrubs the labels of the MultiSegment by replacing them with empty strings.
find_span(layers[, mode])Finds the span of a list of Segment layers.
align(span)Align with a TimeSpan object.
prune_layers([relabel])Prunes identical layers from the MultiSegment.
squeeze_layers([times, relabel])Remove the least informative layer from the MultiSegment according to vmeasure.
- Parameters:
raw_layers (Sequence[Segment])
name (str | None)
- raw_layers: Sequence[Segment]
A sequence of Segment objects representing different layers of annotation.
- property itvls: Sequence[ndarray]
Returns a list of all the intervals for each layer in the MultiSegment.
- property labels: Sequence[Sequence[str]]
Returns a list of all the labels for each layer in the MultiSegment.
- classmethod from_json(json_data, name=None)[source]
Data Ingestion from adobe json format.
- Parameters:
json_data (list) – A list of layers, where each layer is a tuple of (intervals, labels). intervals is a list of [start, end] times, and labels is a list of strings.
name (str, optional) – Name for the created MultiSegment.
- Return type:
- plot(colorscale='D3', hatch=True)[source]
Plots the MultiSegment on a Plotly figure.
- Parameters:
colorscale (str | list[str], optional) – Plotly colorscale to use. Can be a qualitative scale name (e.g., “Set3”, “Pastel”) or a list of colors.
hatch (bool, optional) – Whether to use hatch patterns for different labels. Defaults to True.
- Return type:
Figure
- contour(strategy='depth', **kwargs)[source]
Calculates boundary salience and converts to a BoundaryContour.
- Parameters:
strategy (str)
kwargs (Any)
- Return type:
- scrub_labels()[source]
Scrubs the labels of the MultiSegment by replacing them with empty strings.
- Return type:
- prune_layers(relabel=True)[source]
Prunes identical layers from the MultiSegment.
This also gets rid of layers with no inner boundaries.
- Parameters:
relabel (bool)
- Return type: