crowsetta.formats.seq.generic.GenericSeq#
- class crowsetta.formats.seq.generic.GenericSeq(annots: List[Annotation])[source]#
Bases:
objectClass that represents annotations from a generic format, meant to be an abstraction of any sequence-like format.
Consists of
crowsetta.Annotation`s, each with a :class:`crowsetta.Sequencemade up of :class:`crowsetta.Segment`s.Other formats that convert to :class:`~crowsetta.Annotation`s with :class:`~crowsetta.Sequence`s can be converted to this format.
- annots#
A
listofcrowsetta.Annotationinstances.- Type:
- __init__(annots: List[Annotation]) None#
Method generated by attrs for class GenericSeq.
Methods
__init__(annots)Method generated by attrs for class GenericSeq.
from_file(annot_path)Load annotations in 'generic-seq' format from a csv file.
to_annot()Returns this set of
crowsetta.Annotationinstances as alist.to_df([abspath, basename])Convert these annotations to a
pandas.DataFrame.to_file(annot_path[, abspath, basename])Write these annotations to a csv file in
'generic-seq'format.to_seq()Return a
listofcrowsetta.Sequenceinstances, one for every annotation.Attributes
- classmethod from_file(annot_path: str | bytes | PathLike | Path) Self[source]#
Load annotations in ‘generic-seq’ format from a csv file.
- Parameters:
annot_path (str, pathlib.Path) – Path to csv file containing annotations saved in the
'generic-seq'format.
Examples
>>> path = crowsetta.example('bird1.csv', return_path=True) >>> generic = crowsetta.formats.seq.GenericSeq.from_file(path)
- to_annot() List[Annotation][source]#
Returns this set of
crowsetta.Annotationinstances as alist.This is the same as accessing the
listofcrowsetta.Annotationinstances directly. The method is implemented so that this class conforms with thecrowsetta.interface.seq.SeqLikeinterface.Examples
>>> path = crowsetta.example('bird1.csv', return_path=True) >>> generic = crowsetta.formats.seq.GenericSeq.from_file(path) >>> annots = generic.to_annot()
- to_df(abspath: bool = False, basename: bool = False) DataFrame[source]#
Convert these annotations to a
pandas.DataFrame.- abspathbool
If True, converts filename for each audio file into absolute path. Default is False.
- basenamebool
If True, discard any information about path and just use file name. Default is False.
- to_file(annot_path: str | bytes | PathLike | Path, abspath: bool = False, basename: bool = False) None[source]#
Write these annotations to a csv file in
'generic-seq'format.- Parameters:
annot_path (str, pathlib.Path) – Path including filename of csv file to write to, will be created (or overwritten if it exists already)
abspath (bool) – If True, converts filename for each audio file into absolute path. Default is False.
basename (bool) – If True, discard any information about path and just use file name. Default is False.