API reference¶
Top-level¶
Run all metrics over every case and return an aggregatable result.
Ground-truth spacing is authoritative: if a case does not set spacing
explicitly, the spacing read from the ground-truth file is used for the
distance metrics.
All surface metrics at once, with graceful degradation on empty masks.
Conventions (Metrics Reloaded): * both masks empty -> perfect agreement: distances 0, NSD 1.0 * exactly one empty -> worst case: distances +inf, NSD 0.0
Dice similarity coefficient (== F1 on voxels).
Two empty masks agree perfectly and return 1.0 (Metrics Reloaded convention), since "correctly predicting nothing where there is nothing" is a perfect score, not an undefined one.
Greedy one-to-one lesion matching by IoU.
A predicted component and a ground-truth component may match if their IoU
is at least iou_threshold. Matches are assigned greedily, highest IoU
first, one prediction to one ground-truth lesion. Matched ground-truth
lesions are true positives; unmatched predictions are false positives;
unmatched ground-truth lesions are false negatives.
Percentile bootstrap CI for an aggregate statistic over per-case values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
ArrayLike
|
per-case metric values (e.g. one Dice per patient). |
required |
statistic
|
Callable[[NDArray[float64]], float]
|
aggregate to bootstrap; defaults to the mean. |
mean
|
confidence
|
float
|
two-sided confidence level (0.95 -> 2.5%/97.5%). |
0.95
|
n_resamples
|
int
|
number of bootstrap resamples. |
2000
|
seed
|
int
|
RNG seed; identical inputs always give identical CIs. |
0
|
drop_nonfinite
|
bool
|
drop NaN/inf before resampling (e.g. inf distances from empty-mask cases). The point estimate is over the kept values. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
Estimate
|
class: |
Estimate
|
usable values the interval collapses to the point estimate. |
Loaders¶
Load a binary mask and its voxel spacing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
MaskSource
|
a NumPy array, or a path to |
required |
label
|
int | None
|
if given, keep only voxels equal to this label; otherwise any non-zero voxel is foreground. |
None
|
spacing
|
float | Spacing | None
|
override the spacing. If |
None
|
segment_number
|
int
|
which segment to extract from a DICOM-SEG. |
1
|
Returns:
| Type | Description |
|---|---|
NDArray[bool_]
|
|
Spacing
|
the array axes. |