Skip to content

Label Library

Label format converters for importing behavior annotations from external tools into mosaic's standardized NPZ format.

Supported formats include CalMS21, BORIS aggregated CSV/TSV, and BORIS Pandas pickle. Converters are registered via @register_label_converter.

label_library

Label converter library for behavior datasets.

This module provides a plugin architecture for converting various label formats to the standardized behavior dataset format. Converters are automatically registered via the @register_label_converter decorator.

Adding a New Label Converter

  1. Create a new file in this directory (e.g., boris_behavior.py)
  2. Use label_converter_template.py as a starting point
  3. Implement the converter class with required attributes:
  4. src_format: str (must match tracks_raw/index.csv)
  5. label_kind: str (e.g., "behavior", "id_tags")
  6. label_format: str (version identifier)
  7. Implement the convert() method
  8. Decorate with @register_label_converter
  9. Import the module here to register it

Available Converters

After importing, converters are registered in LABEL_CONVERTERS dict accessible from mosaic.core.dataset module.

Usage

from mosaic.core import Dataset dataset = Dataset("/path/to/dataset")

Convert CalMS21 labels

dataset.convert_all_labels( ... kind="behavior", ... source_format="calms21_npy", ... group_from="filename" ... )

Convert BORIS aggregated CSV/TSV labels

dataset.convert_all_labels( ... kind="behavior", ... source_format="boris_aggregated_csv", ... delimiter=" ", # Use " " for TSV, "," for CSV ... fps=None, # Auto-detect from file ... )

Convert BORIS Pandas pickle labels

dataset.convert_all_labels( ... kind="behavior", ... source_format="boris_pandas_pickle", ... fps=None, # Auto-detect from DataFrame ... )