cellmap_flow.finetune.rank

The rank score lives in cellmap_flow.portable.rank, the Python both modes run; this module keeps the import path the finetune package had for it.

Attributes

CUTOFFS

NARROW_WINDOW

RANK_BLOCKS

RANK_SMOOTHING

WINDOW_MARGIN

Functions

empty_tallies(channels) → List[dict]

One channel's agreement with the paint per channel: the targets

paint_edges(labels) → numpy.ndarray

The painted voxels of labels (z, y, x; 0 unpainted, 1 background,

rank_score(tallies, channels, affinity) → Optional[dict]

The score of tallies: an affinity model's over its channels

spread(items, count) → list

count of items, spread evenly over them in their order; all of them when there are no more.

tally(tallies, target, mask, logits[, skip]) → None

Add one painted block to tallies: target and mask (C, z, y, x)

windowed(norm, lo, hi) → Optional[List[dict]]

norm (normalizer specs, {"name": ..., ...}) with its

Module Contents

cellmap_flow.finetune.rank.CUTOFFS
cellmap_flow.finetune.rank.NARROW_WINDOW = 0.25
cellmap_flow.finetune.rank.RANK_BLOCKS = 32
cellmap_flow.finetune.rank.RANK_SMOOTHING = 0.1
cellmap_flow.finetune.rank.WINDOW_MARGIN = 0.03
cellmap_flow.finetune.rank.empty_tallies(channels: int) → List[dict]

One channel’s agreement with the paint per channel: the targets counted, their logits binned against CUTOFFS (bin b: above b of them), and the loss summed, apart for object and background targets.

cellmap_flow.finetune.rank.paint_edges(labels: numpy.ndarray) → numpy.ndarray

The painted voxels of labels (z, y, x; 0 unpainted, 1 background, 2 and up objects) that touch a painted voxel of the other class along z, y or x: the strokes’ edges, which a binary model’s score leaves out.

cellmap_flow.finetune.rank.rank_score(tallies: List[dict], channels: Sequence[str], affinity: bool) → dict | None

The score of tallies: an affinity model’s over its channels together (channel and channel_index None), a binary model’s best channel’s (by the score, then the lower loss), channel its name in channels (“channel <i>” past them) and channel_index its index, as select_channel takes it; with channel_matches, every channel’s {channel, channel_index, matches}, the best first, which says why that one (organelle close behind mito, say). None when nothing was counted.

cellmap_flow.finetune.rank.spread(items: Sequence, count: int) → list

count of items, spread evenly over them in their order; all of them when there are no more.

cellmap_flow.finetune.rank.tally(tallies: List[dict], target: numpy.ndarray, mask: numpy.ndarray, logits: numpy.ndarray, skip: numpy.ndarray | None = None) → None

Add one painted block to tallies: target and mask (C, z, y, x) as the finetune’s target transform makes them, logits the model’s on the same voxels (NaN where it was not read), and skip (z, y, x) the voxels not to count (paint_edges), or None.

cellmap_flow.finetune.rank.windowed(norm: Sequence[dict], lo: float, hi: float) → List[dict] | None

norm (normalizer specs, {"name": ..., ...}) with its MinMaxNormalizer set to the raw’s window [lo, hi], or None: no MinMaxNormalizer, no window (lo = hi), or one not narrower than NARROW_WINDOW of the normalizer’s own range.