register_loader#

movement.io.load.register_loader(source_software, *, file_validators=None)[source]#

Register a loader function for a given source software.

The decorator also handles file validation using any provided file validator(s).

Parameters:
  • source_software (Literal['DeepLabCut', 'SLEAP', 'LightningPose', 'Anipose', 'NWB', 'VIA-tracks']) – The name of the source software.

  • file_validators (type[ValidFile] | list[type[ValidFile]] | None) – File validator(s) to validate the input file path and content.

Returns:

A decorator that registers the loader function.

Return type:

Callable[[Callable[[Concatenate[TypeVar(TInputFile, Path, str, NWBFile), ParamSpec(P, bound= None)]], Dataset]], Callable[[Concatenate[TypeVar(TInputFile, Path, str, NWBFile), ParamSpec(P, bound= None)]], Dataset]]

Notes

If file validators are provided, the file argument passed to the decorated loader function will be an instance of the appropriate movement.validators.files.ValidFile subclass, instead of the original file path or pynwb.file.NWBFile object.

Examples

>>> from movement.io.load import register_loader
>>> from movement.validators.files import (
...     ValidDeepLabCutH5,
...     ValidDeepLabCutCSV,
... )
>>> @register_loader(
...     "DeepLabCut",
...     file_validators=[ValidDeepLabCutH5, ValidDeepLabCutCSV],
... )
... def from_dlc_file(file: str | Path, fps=None, **kwargs):
...     pass