Skip to main content

multi_scan

Criteria that read a set of a patient's scans, relative to the scan being judged.

A multi_scan node in a criteria_tree evaluates its child on other scans of the same patient (the peers) and combines those results with a quantifier. The scan being judged is the anchor: each scan is in turn the candidate study eye, and a peer is selected relative to it.

Module​

Functions​

parse_study_date​

def parse_study_date(raw: str | None) ‑> datetime.date | None:

Read a scan's study date.

Arguments

  • raw: The study date as recorded, for example "20260811" (DICOM) or "2026-08-11 00:00:00".

Returns The calendar date, or None if it is missing or cannot be read.

quantify​

def quantify(    states: Sequence[CriterionState],    quantifier: MultiScanQuantifier,    on_empty: MultiScanOnEmpty,) ‑> CriterionState:

Combine the selected scans' states into the node's state.

na counts as unknown. any: pass if one passes, fail if every one fails, else unknown. all: fail if one fails, pass if every one passes, else unknown.

Arguments

  • states: One state per selected scan.
  • quantifier: How to combine them.
  • on_empty: The state when no scan is selected.

Returns The node's state.

settled_state​

def settled_state(    state: CriterionState,) ‑> CriterionState:

A peer's state as a multi_scan node counts it: na is unknown.

Classes​

Peer​

class Peer(identity: SubjectIdentity, leaf_outcomes: Mapping[str, CriterionOutcome]):

One scan row that a multi_scan node can read.

Arguments

  • identity: The row's subject: patient, scan, date and eye.
  • leaf_outcomes: The row's own outcome for each tree leaf, by leaf id.

Variables​

PeerView​

class PeerView(scan_peers: ScanPeers, anchor_index: int):

The peers of one anchor row, as evaluate_criterion_tree reads them.

Arguments

  • scan_peers: Every row of the call.
  • anchor_index: The anchor's index in those rows.

Variables​

  • anchor_eye_known : bool - Whether the anchor's eye resolves to left or right.

    Without it, fellow_eye selects nothing, whatever other scans there are.

  • anchor_index : int

Methods​


select​

def select(    self, selector: MultiScanSelector,) ‑> list[Peer]:

The anchor's peers that selector names.

ScanPeers​

class ScanPeers(rows: Sequence[Peer]):

The scan rows of one criteria_matching call, grouped by patient.

Waves are cut by patient, so one call holds every in-scope scan of each patient in it. Selection is relative to an anchor row, given by its index in the rows passed in.

Methods​


anchor_eye_known​

def anchor_eye_known(self, anchor_index: int) ‑> bool:

Whether the anchor row's eye resolves to left or right.

select​

def select(    self, anchor_index: int, selector: MultiScanSelector,) ‑> list[Peer]:

The peers of the anchor row that selector names, in row order.

A scan ID appearing on several rows is one peer (the first row); rows with no scan ID are never merged.

Arguments

  • anchor_index: The anchor's index in the rows.
  • selector: Which peers to select.

Returns The selected peers; empty when the anchor has no patient ID or no resolvable eye.

Raises

  • ValueError: For a selector this module does not implement.

view​

def view(self, anchor_index: int) ‑> PeerView:

The peers of one anchor row.