crowsetta.formats.bbox.raven.Raven#
- class crowsetta.formats.bbox.raven.Raven(df: DataFrame, annot_path: Path, annot_col: str, audio_path=None)[source]#
Bases:
objectClass that represents txt annotation files from Raven (https://ravensoundsoftware.com/software/), created by exporting a Selection Table.
- df#
with annotations loaded into it
- Type:
- annot_path#
Path to Raven txt file from which annotations were loaded.
- Type:
- audio_path#
Path to audio file that the Raven txt file annotates.
Examples
>>> raven = crowsetta.example('Recording1') >>> print(raven) Raven(df= Selection View Channel begin_time_s end_time_s low_freq_hz high_freq_hz annotation 0 1 Spectrogram 1 1 154.387793 154.911598 2878.2 4049.0 EATO 1 2 Spectrogram 1 1 167.526598 168.173020 2731.9 3902.7 EATO 2 3 Spectrogram 1 1 183.609637 184.097752 2878.2 3975.8 EATO 3 4 Spectrogram 1 1 250.527481 251.160711 2756.2 3951.4 EATO 4 5 Spectrogram 1 1 277.887243 278.480896 2707.5 3975.8 EATO 5 6 Spectrogram 1 1 295.529708 296.110168 2951.4 3975.8 EATO, annot_path=PosixPath('/Users/davidnicholson/Documents/repos/vocalpy/crowsetta/src/crowsetta/examples/Recording_1_Segment_02.Table.1.selections.txt'), annot_col='Species', audio_path=None) # noqa: E501
- Type:
str. pathlib.Path
- __init__(df: DataFrame, annot_path: Path, annot_col: str, audio_path=None) None#
Method generated by attrs for class Raven.
Methods
__init__(df, annot_path, annot_col[, audio_path])Method generated by attrs for class Raven.
from_file(annot_path[, annot_col, audio_path])Load annotations from a Raven annotation file, created by exporting a Selection Table.
to_annot()Convert this Raven annotation to a
crowsetta.Annotation.to_bbox()Convert this Raven annotation to a
listofcrowsetta.Bboxinstances.to_file(annot_path)Make a txt file that can be read by Raven from this annotation
Attributes
annot_colCOLUMNS_MAP- classmethod from_file(annot_path: str | bytes | PathLike | Path, annot_col: str = 'Annotation', audio_path: str | bytes | PathLike | Path | None = None) Self[source]#
Load annotations from a Raven annotation file, created by exporting a Selection Table.
- Parameters:
annot_path (str, pathlib.Path) – Path to a txt file exported from Raven.
annot_col (str) – Name of column that contains annotations.
audio_path (str, pathlib.Path) – Path to audio file that the Raven txt file annotates. Optional, defaults to None.
Examples
>>> path = crowsetta.example('Recording1', return_path=True) >>> raven = crowsetta.formats.bbox.Raven.from_file(path, annot_col="Species") >>> print(raven) Raven(df= Selection View Channel begin_time_s end_time_s low_freq_hz high_freq_hz annotation 0 1 Spectrogram 1 1 154.387793 154.911598 2878.2 4049.0 EATO 1 2 Spectrogram 1 1 167.526598 168.173020 2731.9 3902.7 EATO 2 3 Spectrogram 1 1 183.609637 184.097752 2878.2 3975.8 EATO 3 4 Spectrogram 1 1 250.527481 251.160711 2756.2 3951.4 EATO 4 5 Spectrogram 1 1 277.887243 278.480896 2707.5 3975.8 EATO 5 6 Spectrogram 1 1 295.529708 296.110168 2951.4 3975.8 EATO, annot_path=PosixPath('/Users/davidnicholson/Documents/repos/vocalpy/crowsetta/src/crowsetta/examples/Recording_1_Segment_02.Table.1.selections.txt'), annot_col='Species', audio_path=None) # noqa: E501
- to_annot() Annotation[source]#
Convert this Raven annotation to a
crowsetta.Annotation.- Returns:
annot
- Return type:
Examples
>>> path = crowsetta.example('Recording1') >>> raven = crowsetta.formats.bbox.Raven.from_file(path) >>> annot = raven.to_annot()
- to_bbox() List[BBox][source]#
Convert this Raven annotation to a
listofcrowsetta.Bboxinstances.- Returns:
bboxes – A
listofcrowsetta.BBoxinstances.- Return type:
Examples
>>> path = crowsetta.example('Recording1') >>> raven = crowsetta.formats.bbox.Raven.from_file(path) >>> bboxes = raven.to_bbox()