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¶
- Create a new file in this directory (e.g., boris_behavior.py)
- Use label_converter_template.py as a starting point
- Implement the converter class with required attributes:
- src_format: str (must match tracks_raw/index.csv)
- label_kind: str (e.g., "behavior", "id_tags")
- label_format: str (version identifier)
- Implement the convert() method
- Decorate with @register_label_converter
- 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 ... )