mednet.data.temporal.seq_angioreport

Sequence (multi-frame) data loading for the AngioReport dataset.

This module mirrors mednet.data.classify.angioreport but loads multiple frames per exam so temporal models can process longitudinal signal.

Functions

collate_sequence(batch)

Collate variable-length sequences with zero-padding on the time axis.

Classes

DataModule(split_path, num_classes, problem_type)

Temporal AngioReport dataset with multiple frames per exam.

GroupedJSONSplit(path)

Read a frame-level split JSON and expose one sample per exam.

SequenceRawDataLoader(problem_type[, ...])

A specialized raw-data-loader for temporal AngioReport sequences.

class mednet.data.temporal.seq_angioreport.GroupedJSONSplit(path)[source]

Bases: Mapping[str, Sequence[Any]]

Read a frame-level split JSON and expose one sample per exam.

Supports two split formats:

  1. Legacy frame-level entries: ["Train/Train/<exam>/<frame>.jpg", label] grouped into one sample per exam.

  2. Temporal exam-level entries: {"exam": "Train/Train/<exam>", "label": y, "frames": [...]} where frames is either legacy filenames or objects with file + elapsed_seconds.

Parameters:

path (Path | Traversable) – Path to the split JSON (local file or importlib traversable resource).

class mednet.data.temporal.seq_angioreport.SequenceRawDataLoader(problem_type, modality='FA', max_frames=32, max_frames_span='uniform')[source]

Bases: RawDataLoader

A specialized raw-data-loader for temporal AngioReport sequences.

Per-frame timestamps (and hence phases) come from the split JSON exam rows (see mednet.data.temporal.hyperftype_split).

Parameters:
  • problem_type (Literal['binary', 'multiclass', 'multilabel']) – Problem type for target formatting.

  • modality (Literal['FA', 'ICGA']) – Modality to crop from side-by-side frames.

  • max_frames (int | None) – Optional cap on number of frames per sequence.

  • max_frames_span (Literal['uniform', 'last', 'phase_stratified', 'one_per_phase']) – How to pick frames when the sequence is longer than max_frames: "uniform" keeps an even temporal coverage, "last" keeps the most recent frames, "phase_stratified" balances early/mid/late bins, and "one_per_phase" keeps at most one frame per phase (see _select_one_per_phase_slots).

datadir: Path
sample(sample)[source]

Load whole samples from media.

Parameters:

sample (tuple[str, Any, list[FrameStamp] | None]) – Information about the sample to load. Implementation dependent.

Return type:

Mapping[str, Any]

Returns:

The instantiated sample, which is a dictionary where keys name the sample’s data and metadata.

target(sample)[source]

Load only sample target from its raw representation.

Parameters:

sample (tuple[str, Any, list[FrameStamp] | None]) – A tuple containing the path suffix, within the dataset root folder, where to find the image to be loaded, and an integer, representing the sample target.

Return type:

Tensor

Returns:

The label corresponding to the specified sample, encapsulated as a torch float tensor.

mednet.data.temporal.seq_angioreport.collate_sequence(batch)[source]

Collate variable-length sequences with zero-padding on the time axis.

Parameters:

batch (list[Mapping[str, Any]]) – List of sample dicts from SequenceRawDataLoader.

Returns:

Batched dict with keys image, target, lengths, name, phase_id, and elapsed_seconds.

Return type:

dict[str, Any]

class mednet.data.temporal.seq_angioreport.DataModule(split_path, num_classes, problem_type, modality='FA', max_frames=32, max_frames_span='uniform')[source]

Bases: CachingDataModule

Temporal AngioReport dataset with multiple frames per exam.

Parameters:
  • split_path (Path | Traversable) – Path to the split JSON file.

  • num_classes (int) – Number of output classes.

  • problem_type (Literal['binary', 'multiclass', 'multilabel']) – Target formatting strategy ("binary", "multiclass", or "multilabel").

  • modality (Literal['FA', 'ICGA']) – Modality to crop from side-by-side frames ("FA" or "ICGA").

  • max_frames (int | None) – Cap on the number of frames per sequence; None loads all frames.

  • max_frames_span (Literal['uniform', 'last', 'phase_stratified', 'one_per_phase']) – Strategy for down-sampling when the sequence exceeds max_frames.