crowsetta.formats.seq.notmat.NotMat#

class crowsetta.formats.seq.notmat.NotMat(onsets: ndarray, offsets: ndarray, labels: ndarray, annot_path: Path, audio_path: Path)[source]#

Bases: object

Class that represents annotations from .not.mat files produced by evsonganaly GUI.

name#

Shorthand name for annotation format: 'notmat'.

Type:

str

ext#

Extension of files in annotation format: '.not.mat'.

Type:

str

onsets#

Onset times of segments, in seconds.

Type:

numpy.ndarray

offsets#

Offset times of segments, in seconds.

Type:

numpy.ndarray

labels#

Labels for segments.

Type:

numpy.ndarray

annot_path#

Path to .not.mat file from which annotations were loaded.

Type:

str, pathlib.Path

audio_path#

Path to audio file that annot_path annotates.

Type:

str, pathlib.Path

Notes

This class uses the Python package evfuncs to load the annotations. NickleDave/evfuncs

__init__(onsets: ndarray, offsets: ndarray, labels: ndarray, annot_path: Path, audio_path: Path) None#

Method generated by attrs for class NotMat.

Methods

__init__(onsets, offsets, labels, ...)

Method generated by attrs for class NotMat.

from_file(annot_path)

load annotations from .not.mat file

to_annot([round_times, decimals])

Convert this .not.mat annotation to a crowsetta.Annotation.

to_file(samp_freq, threshold, min_syl_dur, ...)

Save as a .not.mat file that can be read by evsonganaly (MATLAB GUI for annotating vocalizations).

to_seq([round_times, decimals])

Convert this .not.mat annotation to a crowsetta.Sequence.

Attributes

onsets

offsets

labels

annot_path

audio_path

ext

name

classmethod from_file(annot_path: PathLike) Self[source]#

load annotations from .not.mat file

Parameters:

annot_path (str, pathlib.Path) – Path to a .not.mat file saved by the evsonganaly GUI.

Examples

>>> example = crowsetta.data.get('notmat')
>>> notmat = crowsetta.formats.seq.NotMat.from_file(example.annot_path)
to_annot(round_times: bool = True, decimals: int = 3) Annotation[source]#

Convert this .not.mat annotation to a crowsetta.Annotation.

Parameters:
  • round_times (bool) – If True, round times of onsets and offsets. Default is True.

  • decimals (int) – Number of decimals places to round floating point numbers to. Only meaningful if round_times is True. Default is 3, so that times are rounded to milliseconds.

Returns:

annot

Return type:

crowsetta.Annotation

Examples

>>> example = crowsetta.data.get('notmat')
>>> notmat = crowsetta.formats.seq.NotMat.from_file(example.annot_path)
>>> annot = notmat.to_annot()

Notes

The round_times and decimals arguments are provided to reduce differences across platforms due to floating point error, e.g. when loading annotation files and then sending them to a csv file, the result should be the same on Windows and Linux.

to_file(samp_freq: int, threshold: int, min_syl_dur: float, min_silent_dur: float, fname: str | bytes | PathLike | Path | None = None, dst: str | bytes | PathLike | Path | None = None, other_vars: Dict | None = None) None[source]#

Save as a .not.mat file that can be read by evsonganaly (MATLAB GUI for annotating vocalizations).

Parameters:
  • samp_freq (int) – Sampling frequency of audio file.

  • threshold (int) – Value above which amplitude is considered part of a segment. Default is 5000.

  • min_syl_dur (float) – Minimum duration of a segment. Default is 0.02, i.e. 20 ms.

  • min_silent_dur (float) – Minimum duration of silent gap between segment. Default is 0.002, i.e. 2 ms.

  • fname (str, pathlib.Path) – Name of audio file associated with .not.mat, will be used as base of name for .not.mat file. e.g., if filename is ‘bl26lb16!912l26lb16_190412_0721.20144.cbin’ then the .not.mat file will be ‘bl26lb16!912l26lb16_190412_0721.20144.cbin.not.mat’ Default is None, in which case self.audio_path.name is used.

  • dst (str, pathlib.Path) – Directory where .not.mat should be saved. Default is None, in which case it is saved in the parent directory of fname.

  • other_vars (dict) – Mapping from variable names to other variables that should be saved in the .not.mat file, e.g., if you need to add a variable named ‘pitches’ that is an numpy array of float values.

to_seq(round_times: bool = True, decimals: int = 3) Sequence[source]#

Convert this .not.mat annotation to a crowsetta.Sequence.

Parameters:
  • round_times (bool) – If True, round times of onsets and offsets. Default is True.

  • decimals (int) – Number of decimals places to round floating point numbers to. Only meaningful if round_times is True. Default is 3, so that times are rounded to milliseconds.

Returns:

seq

Return type:

crowsetta.Sequence

Examples

>>> example = crowsetta.data.get('notmat')
>>> notmat = crowsetta.formats.seq.NotMat.from_file(example.annot_path)
>>> seq = notmat.to_seq()

Notes

The round_times and decimals arguments are provided to reduce differences across platforms due to floating point error, e.g. when loading annotation files and then sending them to a csv file, the result should be the same on Windows and Linux.