Skip to content

inventory

What a run writes, by name: the stages, their arrays and the axes of each.

The whole vocabulary of data references: a stage's noun is its group in a run's results/<name>.h5 and the prefix of every reference to its output (ADR-0029, ADR-0034), so the loader checks every reference against it and a typo fails at load with the alternatives listed.

STAGE_ARRAYS module-attribute

STAGE_ARRAYS: dict[str, dict[str, tuple]] = {
    "pose2d": {
        "points": ("N", *VTK2),
        "conf": ("N", *VTK),
        "crops": ("N", *VT4),
        "candidates/xy": ("N", "V", "T", "K", "C", 2),
        "candidates/score": ("N", "V", "T", "K", "C"),
        "centers": ("N", "T", 3),
        "track_flags": ("N", "T"),
        "center_candidates": ("V", "T", "C", 3),
    },
    "bundle_adjustment": {
        "reproj_before": VTK,
        "reproj_after": VTK,
    },
    "pose3d": {
        "points": ("N", *TK3),
        "reproj_error": ("N", *VTK),
        "inliers": ("N", *VTK),
        "support": ("N", "T", "K"),
        "selected/points": ("N", *VTK2),
        "selected/conf": ("N", *VTK),
    },
    "smoothing": {
        "points": ("N", *TK3),
        "var": ("N", *TK3),
        "smooth_param": ("N", "K"),
    },
    "correction": {"points": ("N", *TK3)},
    "ik": {
        "angles": ("N", *TD),
        "points": ("N", *TK3),
        "chain_scale": ("N", "C"),
        "chain_offset": ("N", "C", 3),
    },
    "ball": {
        "center": ("T", 3),
        "center_sd": ("T", 3),
        "radius": (),
        "rotation": ("T", 3),
        "step": ("T", 3),
        "axes": (3, 3),
        "tracks": TD,
    },
    "render": {},
}

Per stage, the arrays it writes into a run's results/<name>.h5 and their axes.

Every per-animal array leads with N (ADR-0052); those without it describe the recording: the center peaks, the bundle adjustment residuals, fitted on animal 0, and the treadmill ball.

fill_value

fill_value(ref: str, kind: str) -> float | int | bool

The value a "stage/array" reference holds where nothing was written.

kind is the array's numpy dtype kind ("f", "u", "b", ...): a float array without an entry in FILL is NaN there, anything else zero.

Source code in src/deeperfly/inventory.py
def fill_value(ref: str, kind: str) -> float | int | bool:
    """The value a `"stage/array"` reference holds where nothing was written.

    `kind` is the array's numpy dtype kind (`"f"`, `"u"`, `"b"`, ...): a float array
    without an entry in `FILL` is NaN there, anything else zero.
    """
    if ref in FILL:
        return FILL[ref]
    if kind in "fc":
        return float("nan")
    return False if kind == "b" else 0

without_animal_axis

without_animal_axis(axes: tuple) -> tuple

axes without a leading N, for a check written against one animal.

Source code in src/deeperfly/inventory.py
def without_animal_axis(axes: tuple) -> tuple:
    """`axes` without a leading `N`, for a check written against one animal."""
    return axes[1:] if axes[:1] == ("N",) else axes