mednet.config.temporal.data.angioreport.hyperftype_seq

Temporal AngioReport dataset (HyperF_Type multiclass task, FA modality).

Uses config/temporal_hyperftype.json when available; each listed frame carries its elapsed_seconds in the split JSON. The frame-selection strategy is read from MEDNET_TEMPORAL_FRAME_SPAN (default uniform).

# SPDX-FileCopyrightText: Copyright © 2026 Idiap Research Institute <contact@idiap.ch>
#
# SPDX-License-Identifier: GPL-3.0-or-later
""":py:mod:`Temporal AngioReport dataset <mednet.data.temporal.seq_angioreport>`
(HyperF_Type multiclass task, FA modality).

Uses ``config/temporal_hyperftype.json`` when available; each listed frame carries
its ``elapsed_seconds`` in the split JSON. The frame-selection strategy is read from
``MEDNET_TEMPORAL_FRAME_SPAN`` (default ``uniform``).
"""

import importlib.resources
import os
import typing
from pathlib import Path

from mednet.data.temporal.seq_angioreport import DataModule


def _resolve_split_path():
    env = os.environ.get(
        "MEDNET_TEMPORAL_SPLIT_PATH", "config/temporal_hyperftype.json"
    ).strip()
    env_path = Path(env)
    if env_path.is_file():
        return env_path.resolve()

    for parent in Path(__file__).resolve().parents:
        candidate = parent / "config" / "temporal_hyperftype.json"
        if candidate.is_file():
            return candidate.resolve()

    packaged_temporal = (
        importlib.resources.files("mednet.config.temporal.data.angioreport")
        / "temporal_hyperftype.json"
    )
    if packaged_temporal.is_file():
        return packaged_temporal

    return (
        importlib.resources.files("mednet.config.classify.data.angioreport")
        / "hyperftype.json"
    )


def _resolve_frame_span_strategy() -> typing.Literal[
    "uniform", "last", "phase_stratified", "one_per_phase"
]:
    raw = os.environ.get("MEDNET_TEMPORAL_FRAME_SPAN", "uniform")
    if raw not in {"uniform", "last", "phase_stratified", "one_per_phase"}:
        return "uniform"
    return typing.cast(
        typing.Literal["uniform", "last", "phase_stratified", "one_per_phase"], raw
    )


datamodule = DataModule(
    split_path=_resolve_split_path(),
    num_classes=5,
    problem_type="multiclass",
    modality="FA",
    max_frames=12,
    max_frames_span=_resolve_frame_span_strategy(),
)