Skip to content

mopipe.core.data.collator

collator.py

This module contains the Mocap Data Collator class, which is used to collate data from multiple sources and save it.

MocapDataCollator Objects

class MocapDataCollator()

MocapDataCollator

The MocapDataCollator class is used to collate data from multiple sources and save it.

__init__

def __init__(output_dir: Path, output_name: str)

Initialize the MocapDataCollator.

Parameters

output_dir : Path The directory to save the collated data in. output_name : str The base name to save the collated data under.

readers

@property
def readers() -> list[AbstractReader]

The readers to be used to read the data.

output_dir

@property
def output_dir() -> Path

The directory to save the collated data in.

output_name

@property
def output_name() -> str

The name to save the collated data under.

primary_reader

@property
def primary_reader() -> int

Index of the primary reader that determines the output sample rate.

set_primary_reader

def set_primary_reader(index: int) -> None

Set the primary reader by index.

Parameters

index : int The index of the reader to set as primary.

Raises

IndexError If the index is out of range.

add_reader

def add_reader(reader: AbstractReader, *, is_primary: bool = False) -> int

Add a reader to the collator.

Parameters

reader : AbstractReader The reader to be added. is_primary : bool, optional Whether this reader should be the primary reader (determines output sample rate). Defaults to False.

Returns

int The reader index.

collate

def collate(method: str = "linear") -> EmpiricalData

Collate the data from the readers.

Reads data from all readers, resamples non-primary data to match the primary reader's sample rate, truncates to the shortest length, and concatenates along columns.

Parameters

method : str, optional Interpolation method for resampling: 'linear', 'cubic', or 'nearest'. Defaults to 'linear'.

Returns

EmpiricalData The collated data with combined metadata.

Raises

ValueError If no readers have been added or sample rates cannot be determined.