Skip to content

feat(NII): split a label at a cumulative-volume fraction or at its center of mass - #146

Open
Hendrik-code wants to merge 1 commit into
mainfrom
feat/nii-split-label-at
Open

feat(NII): split a label at a cumulative-volume fraction or at its center of mass#146
Hendrik-code wants to merge 1 commit into
mainfrom
feat/nii-split-label-at

Conversation

@Hendrik-code

Copy link
Copy Markdown
Owner

Upstreams the two reusable kernels hiding inside paraside's split_ethmoid, which wrapped generic
logic around hard-coded ethmoid label ids (7/8/15/16) and offsets (+100/+200).

What's new

NII.split_label_at_cumulative_volume_fraction(labels, axis, fraction, offset) walks slices inwards
from the axis-most end of a mask, summing voxels until fraction of the total volume is covered,
and adds offset to the labels of that slab. This is a volume fraction, not an extent fraction, so
a structure that is thin at one end is not cut in the middle of its bounding box.

NII.split_label_at_center_of_mass(labels, axis, offset) cuts at the rounded center of mass along
axis and offsets the labels on the axis side of the plane.

eth = seg.extract_label([7, 8, 15, 16], keep_label=True)
eth = eth.split_label_at_cumulative_volume_fraction([7, 8, 15, 16], "P", 1 / 3, 100)  # posterior third
eth = eth.split_label_at_center_of_mass([7, 15], "R", 200)                            # right half of the front

Changes from the source implementation

  • The axis is an anatomical direction resolved against orientation, so the reorient round-trip the
    original did (and the reorient back at the end) is gone. A raw array axis int also works.
  • The center-of-mass rounding happens in the anatomical frame, so the split is identical whichever
    orientation the image is stored in. Rounding in the array frame shifted it by one slice when the
    center of mass landed exactly on a voxel center.
  • The offset is applied through a mask instead of arr[slab] += offset followed by
    arr[arr == offset] = 0, which silently deletes any label equal to the offset. The dtype is
    promoted when the offset would overflow it.
  • fraction=0 yields an empty slab. The original had no such case: its loop left cutoff_slice as
    None when the threshold was never reached and then crashed on an undefined variable.
  • Labels absent from the mask are a no-op instead of a KeyError.

Tests

12 tests in unit_tests/test_nii_extended.py, including orientation invariance for both methods and
a pipeline test that composes them back into the original ethmoid split — the result is
voxel-identical to split_ethmoid.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GFZf44LHBB6N5jaf6YFzhx

…bel_at_center_of_mass

Two reusable label-splitting kernels lifted out of paraside's split_ethmoid,
which hard-coded the ethmoid label ids (7/8/15/16) and offsets (+100/+200)
around otherwise generic logic.

split_label_at_cumulative_volume_fraction walks slices inwards from the
axis-most end of a mask, summing voxels until a given fraction of the total
volume is covered, and adds an offset to the labels of that slab. Note this is
a volume fraction, not an extent fraction, so a structure that is thin at one
end is not cut in the middle of its bounding box.

split_label_at_center_of_mass cuts at the rounded center of mass along an axis
and offsets the labels on the axis side of the plane.

Changes from the source implementation:
- the axis is an anatomical direction resolved against `orientation`, so the
  reorient round-trip the original did (and the reorient back at the end) is
  gone, and either method can also take a raw array axis as an int
- the center-of-mass rounding happens in the anatomical frame, so the split is
  identical whichever orientation the image is stored in; rounding in the array
  frame shifted it by a slice when the center of mass landed on a voxel center
- the offset is applied via a mask instead of `arr[slab] += offset` followed by
  `arr[arr == offset] = 0`, which silently breaks for any label equal to the
  offset, and the dtype is promoted when the offset would overflow it
- fraction 0 now yields an empty slab; the original had no such case and its
  loop left `cutoff_slice` as None when the threshold was never reached, which
  then crashed on an undefined variable
- labels not present in the mask are a no-op instead of a KeyError

A test composes the two into the original ethmoid pipeline; the result is
voxel-identical to split_ethmoid.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GFZf44LHBB6N5jaf6YFzhx
@github-actions

Copy link
Copy Markdown

Benchmark comparison

Speed (wall time per call)

baseline 8b2083a vs head 8b2083a · python 3.11.16 · 5 repeats + 1 warmup

Showing the 5 most-changed measurements per case; the rest are collapsed. Rows with a baseline below 3 ms are tagged (noise) — runner jitter on those swamps any real change.

ct_3d — shape (73, 47, 73)

Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
nii_filter_connected_components 3.45 ±0.02 3.61 ±0.05 +4.5% 0.001
poi_calc_centroids_nocrop 3.71 ±0.05 3.87 ±0.10 +4.1% 0.082
nii_load_img 9.31 ±0.05 9.40 ±0.10 +1.0% 0.039
nii_rescale 31.10 ±0.12 31.36 ±0.38 +0.8% 0.143
nii_fill_holes 3.89 ±0.03 3.92 ±0.01 +0.8% 0.202
… 31 more measurements
Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
poi_calc_poi_from_subreg_vert 9.41 ±0.07 9.48 ±0.09 +0.8% 0.056
nii_save 9.29 ±0.14 9.22 ±0.08 -0.8% 0.128
nii_dilate_msk 92.51 ±0.73 93.16 ±1.06 +0.7% 0.312
nii_erode_msk 5.06 ±0.05 5.09 ±0.06 +0.6% 0.834
nii_resample_from_to 32.66 ±0.08 32.84 ±0.30 +0.5% 0.245
metric_voxels 250463.00 ±0.00 250463.00 ±0.00 +0.0%
metric_labels 3.00 ±0.00 3.00 ±0.00 +0.0%
metric_foreground_pct 14.51 ±0.00 14.51 ±0.00 +0.0%
poi_map_labels 0.15 ±0.02 0.19 ±0.01 +23.7% (noise) 0.052
poi_save 0.38 ±0.04 0.44 ±0.03 +16.8% (noise) 0.017
poi_reorient 0.34 ±0.01 0.39 ±0.02 +15.8% (noise) 0.004
nii_get_array 0.05 ±0.01 0.05 ±0.00 +13.6% (noise) 0.131
poi_rescale 0.20 ±0.02 0.22 ±0.01 +13.1% (noise) 0.070
nii_apply_crop 0.59 ±0.06 0.66 ±0.02 +12.0% (noise) 0.025
poi_resample_from_to 0.53 ±0.04 0.59 ±0.02 +11.5% (noise) 0.013
poi_to_global 0.20 ±0.02 0.22 ±0.02 +11.0% (noise) 0.075
poi_load 0.75 ±0.02 0.80 ±0.02 +7.5% (noise) 0.001
poi_local_to_global_arr 0.22 ±0.01 0.24 ±0.01 +5.6% (noise) 0.104
poi_calc_centroids 2.03 ±0.04 2.15 ±0.06 +5.6% (noise) 0.012
nii_extract_label 0.36 ±0.03 0.34 ±0.03 -5.1% (noise) 0.654
nii_reorient 0.69 ±0.03 0.66 ±0.07 -3.2% (noise) 0.771
nii_volumes 1.62 ±0.02 1.57 ±0.01 -3.1% (noise) 0.001
nii_set_dtype 0.44 ±0.03 0.43 ±0.03 -3.0% (noise) 0.991
nii_get_connected_components 1.72 ±0.01 1.75 ±0.02 +1.8% (noise) 0.013
nii_unique 0.54 ±0.02 0.55 ±0.01 +1.7% (noise) 0.064
nii_load_seg 2.38 ±0.05 2.35 ±0.05 -1.4% (noise) 0.147
nii_rescale_seg 2.55 ±0.05 2.56 ±0.03 +0.6% (noise) 0.921
nii_map_labels 0.74 ±0.05 0.74 ±0.02 -0.5% (noise) 0.622
nii_compute_crop 0.30 ±0.01 0.30 ±0.01 +0.4% (noise) 0.939
nii_pad_to 0.62 ±0.04 0.62 ±0.05 -0.1% (noise) 0.512
nii_center_of_masses 1.47 ±0.01 1.47 ±0.01 +0.0% (noise) 0.175

ct_2d — shape (73, 47, 1)

Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
nii_resample_from_to 6.09 ±0.11 6.06 ±0.37 -0.4% 0.569
nii_dilate_msk 10.85 ±0.10 10.88 ±0.04 +0.3% 0.431
nii_rescale 4.70 ±0.08 4.71 ±0.13 +0.2% 0.725
metric_voxels 3431.00 ±0.00 3431.00 ±0.00 +0.0%
metric_labels 3.00 ±0.00 3.00 ±0.00 +0.0%
… 30 more measurements
Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
metric_foreground_pct 37.60 ±0.00 37.60 ±0.00 +0.0%
nii_compute_crop 0.14 ±0.01 0.16 ±0.02 +18.3% (noise) 0.035
nii_get_array 0.02 ±0.00 0.02 ±0.00 +10.2% (noise) 0.028
poi_to_global 0.26 ±0.01 0.24 ±0.01 -7.3% (noise) 0.249
nii_center_of_masses 0.20 ±0.01 0.22 ±0.01 +5.4% (noise) 0.689
nii_fill_holes 0.80 ±0.01 0.77 ±0.02 -4.1% (noise) 0.002
poi_local_to_global_arr 0.26 ±0.01 0.25 ±0.00 -3.2% (noise) 0.172
nii_set_dtype 0.40 ±0.01 0.41 ±0.01 +3.2% (noise) 0.471
nii_extract_label 0.43 ±0.01 0.44 ±0.02 +3.2% (noise) 0.202
poi_load 0.85 ±0.02 0.87 ±0.02 +2.6% (noise) 0.118
nii_get_connected_components 0.64 ±0.02 0.63 ±0.02 -2.4% (noise) 0.207
nii_rescale_seg 0.74 ±0.06 0.76 ±0.02 +2.4% (noise) 0.995
nii_load_seg 1.46 ±0.05 1.50 ±0.04 +2.3% (noise) 0.265
nii_filter_connected_components 0.79 ±0.02 0.81 ±0.03 +2.2% (noise) 0.062
nii_reorient 0.76 ±0.03 0.77 ±0.02 +1.8% (noise) 0.573
poi_calc_centroids 0.88 ±0.02 0.86 ±0.03 -1.6% (noise) 0.843
poi_save 0.50 ±0.03 0.50 ±0.01 -1.1% (noise) 0.787
nii_erode_msk 0.88 ±0.03 0.87 ±0.02 -1.1% (noise) 0.532
nii_unique 0.13 ±0.01 0.13 ±0.02 +1.0% (noise) 0.664
nii_pad_to 0.57 ±0.02 0.57 ±0.01 +1.0% (noise) 0.400
nii_volumes 0.28 ±0.03 0.29 ±0.03 +1.0% (noise) 0.928
poi_map_labels 0.22 ±0.02 0.22 ±0.01 -1.0% (noise) 0.652
poi_reorient 0.44 ±0.02 0.43 ±0.02 -0.9% (noise) 0.852
nii_apply_crop 0.68 ±0.03 0.68 ±0.02 +0.8% (noise) 0.911
nii_load_img 1.35 ±0.08 1.34 ±0.04 -0.7% (noise) 0.635
poi_rescale 0.26 ±0.02 0.26 ±0.01 +0.7% (noise) 0.320
nii_save 1.25 ±0.05 1.24 ±0.03 -0.6% (noise) 0.751
nii_map_labels 0.51 ±0.03 0.51 ±0.02 -0.4% (noise) 0.205
poi_calc_centroids_nocrop 1.03 ±0.02 1.03 ±0.03 +0.3% (noise) 0.933
poi_resample_from_to 0.69 ±0.02 0.69 ±0.02 +0.1% (noise) 0.930

mri_3d — shape (68, 52, 67)

Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
poi_calc_poi_from_subreg_vert 8.94 ±0.04 9.26 ±0.25 +3.6% 0.035
nii_fill_holes 4.88 ±0.03 5.02 ±0.03 +2.8% 0.001
nii_save 7.64 ±0.07 7.79 ±0.02 +2.0% 0.010
poi_calc_centroids_nocrop 7.38 ±0.09 7.50 ±0.04 +1.6% 0.032
nii_rescale 29.96 ±0.22 30.27 ±0.16 +1.0% 0.065
… 31 more measurements
Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
nii_dilate_msk 120.58 ±0.43 121.51 ±0.40 +0.8% 0.066
nii_load_img 7.76 ±0.02 7.82 ±0.07 +0.8% 0.116
nii_filter_connected_components 3.85 ±0.06 3.82 ±0.04 -0.7% 0.795
nii_resample_from_to 31.49 ±0.09 31.70 ±0.13 +0.7% 0.022
nii_erode_msk 6.61 ±0.07 6.57 ±0.11 -0.5% 0.491
metric_voxels 236912.00 ±0.00 236912.00 ±0.00 +0.0%
metric_labels 8.00 ±0.00 8.00 ±0.00 +0.0%
metric_foreground_pct 18.21 ±0.00 18.21 ±0.00 +0.0%
nii_set_dtype 0.51 ±0.02 0.57 ±0.05 +10.3% (noise) 0.036
nii_reorient 0.81 ±0.02 0.89 ±0.02 +9.8% (noise) 0.000
poi_local_to_global_arr 0.26 ±0.01 0.28 ±0.01 +8.8% (noise) 0.002
poi_resample_from_to 0.71 ±0.03 0.76 ±0.01 +7.7% (noise) 0.004
nii_extract_label 0.46 ±0.01 0.50 ±0.01 +7.5% (noise) 0.009
nii_pad_to 0.72 ±0.04 0.78 ±0.02 +7.4% (noise) 0.011
poi_save 0.54 ±0.02 0.57 ±0.03 +6.5% (noise) 0.040
nii_apply_crop 0.70 ±0.03 0.74 ±0.02 +5.6% (noise) 0.008
nii_load_seg 2.50 ±0.04 2.63 ±0.06 +4.9% (noise) 0.004
nii_unique 0.53 ±0.01 0.56 ±0.01 +4.7% (noise) 0.019
nii_compute_crop 0.34 ±0.01 0.36 ±0.01 +4.7% (noise) 0.099
poi_load 1.72 ±0.02 1.79 ±0.01 +3.9% (noise) 0.000
poi_rescale 0.29 ±0.02 0.30 ±0.01 +3.6% (noise) 0.072
nii_map_labels 0.92 ±0.03 0.95 ±0.01 +3.4% (noise) 0.021
poi_to_global 0.29 ±0.01 0.30 ±0.02 +3.4% (noise) 0.169
nii_rescale_seg 2.57 ±0.02 2.62 ±0.02 +2.2% (noise) 0.001
poi_calc_centroids 2.40 ±0.02 2.45 ±0.02 +2.1% (noise) 0.002
nii_get_connected_components 1.77 ±0.03 1.80 ±0.01 +1.9% (noise) 0.055
poi_reorient 0.46 ±0.01 0.47 ±0.02 +1.6% (noise) 0.493
nii_get_array 0.05 ±0.00 0.05 ±0.01 -0.9% (noise) 0.292
nii_volumes 1.69 ±0.01 1.71 ±0.01 +0.9% (noise) 0.239
nii_center_of_masses 1.70 ±0.02 1.71 ±0.01 +0.3% (noise) 0.916
poi_map_labels 0.25 ±0.01 0.25 ±0.01 -0.2% (noise) 0.934

mri_2d — shape (68, 52, 1)

Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
nii_rescale 4.56 ±0.07 4.78 ±0.08 +4.9% 0.001
nii_resample_from_to 6.00 ±0.08 6.19 ±0.12 +3.2% 0.009
nii_dilate_msk 14.27 ±0.06 14.38 ±0.05 +0.8% 0.051
metric_voxels 3536.00 ±0.00 3536.00 ±0.00 +0.0%
metric_labels 7.00 ±0.00 7.00 ±0.00 +0.0%
… 30 more measurements
Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
metric_foreground_pct 50.17 ±0.00 50.17 ±0.00 +0.0%
nii_get_array 0.02 ±0.00 0.02 ±0.00 +18.3% (noise) 0.030
nii_reorient 0.76 ±0.02 0.85 ±0.03 +12.0% (noise) 0.001
poi_rescale 0.28 ±0.01 0.31 ±0.01 +10.7% (noise) 0.003
nii_compute_crop 0.14 ±0.01 0.16 ±0.01 +10.0% (noise) 0.066
nii_set_dtype 0.41 ±0.02 0.45 ±0.02 +9.6% (noise) 0.022
nii_load_seg 1.45 ±0.03 1.59 ±0.03 +9.6% (noise) 0.000
nii_load_img 1.31 ±0.05 1.43 ±0.02 +9.2% (noise) 0.002
nii_apply_crop 0.66 ±0.02 0.72 ±0.02 +9.0% (noise) 0.002
nii_save 1.25 ±0.04 1.36 ±0.02 +8.5% (noise) 0.001
nii_center_of_masses 0.36 ±0.01 0.38 ±0.01 +5.3% (noise) 0.013
poi_calc_centroids 0.99 ±0.03 1.04 ±0.03 +5.3% (noise) 0.110
poi_reorient 0.46 ±0.02 0.48 ±0.03 +5.1% (noise) 0.206
poi_local_to_global_arr 0.25 ±0.00 0.26 ±0.01 +4.9% (noise) 0.009
poi_to_global 0.27 ±0.01 0.28 ±0.01 +3.5% (noise) 0.088
nii_filter_connected_components 0.79 ±0.01 0.81 ±0.03 +3.5% (noise) 0.131
nii_pad_to 0.54 ±0.02 0.56 ±0.02 +3.4% (noise) 0.132
nii_rescale_seg 0.73 ±0.04 0.75 ±0.02 +3.2% (noise) 0.056
nii_volumes 0.41 ±0.01 0.42 ±0.02 +3.2% (noise) 0.350
nii_get_connected_components 0.61 ±0.01 0.63 ±0.01 +3.0% (noise) 0.072
poi_calc_centroids_nocrop 1.20 ±0.03 1.24 ±0.03 +2.6% (noise) 0.018
poi_save 0.57 ±0.02 0.58 ±0.03 +2.4% (noise) 0.266
poi_load 1.56 ±0.02 1.60 ±0.07 +2.4% (noise) 0.241
nii_fill_holes 0.94 ±0.03 0.92 ±0.04 -1.3% (noise) 0.383
poi_resample_from_to 0.71 ±0.00 0.71 ±0.02 +0.8% (noise) 0.319
nii_unique 0.14 ±0.01 0.14 ±0.01 +0.7% (noise) 0.452
nii_extract_label 0.43 ±0.02 0.43 ±0.02 +0.6% (noise) 0.408
poi_map_labels 0.24 ±0.01 0.24 ±0.01 -0.4% (noise) 0.882
nii_map_labels 0.51 ±0.02 0.51 ±0.02 +0.3% (noise) 0.718
nii_erode_msk 1.05 ±0.02 1.05 ±0.03 +0.3% (noise) 0.370

Gate: a measurement fails when the baseline is ≥ 1 ms, the median grows by ≥ 50%, and Welch's t-test gives p < 0.05. metric_* rows are context only.

Memory (peak RSS growth per call)

baseline 8b2083a vs head 8b2083a · python 3.11.16 · 5 repeats + 1 warmup · sampler proc-status, isolation fork · measurement floor ≈ 0.90 MiB

Showing the 5 most-changed measurements per case; the rest are collapsed. Rows with a baseline below 3 MiB are tagged (noise) — runner jitter on those swamps any real change.

ct_3d — shape (73, 47, 73)

Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
poi_resample_from_to 5.53 ±0.00 5.44 ±0.00 -1.6%
nii_rescale 6.42 ±0.00 6.33 ±0.00 -1.5%
nii_reorient 5.97 ±0.00 5.88 ±0.00 -1.4%
nii_resample_from_to 6.55 ±0.00 6.45 ±0.00 -1.4%
nii_load_seg 6.07 ±0.00 5.99 ±0.00 -1.4%
… 31 more measurements
Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_dilate_msk 6.05 ±0.00 5.99 ±0.00 -1.0%
nii_erode_msk 6.07 ±0.00 6.01 ±0.00 -1.0%
nii_load_img 3.56 ±0.00 3.53 ±0.00 -1.0%
nii_rescale_seg 6.20 ±0.00 6.14 ±0.00 -0.9%
nii_set_dtype 5.37 ±0.00 5.32 ±0.00 -0.9%
nii_pad_to 5.49 ±0.00 5.44 ±0.00 -0.9%
nii_extract_label 5.49 ±0.00 5.45 ±0.00 -0.9%
nii_map_labels 5.55 ±0.00 5.51 ±0.00 -0.8%
nii_apply_crop 5.93 ±0.00 5.88 ±0.00 -0.8%
poi_calc_centroids_nocrop 6.05 ±0.00 6.00 ±0.00 -0.8%
poi_calc_centroids 6.18 ±0.00 6.13 ±0.00 -0.8%
nii_fill_holes 6.41 ±0.00 6.36 ±0.00 -0.7%
nii_get_connected_components 6.68 ±0.00 6.63 ±0.00 -0.7%
nii_filter_connected_components 6.99 ±0.00 6.95 ±0.00 -0.7%
poi_calc_poi_from_subreg_vert 7.30 ±0.00 7.26 ±0.00 -0.6% 0.000
nii_save 3.84 ±0.00 3.84 ±0.00 +0.0%
nii_volumes 3.52 ±0.00 3.52 ±0.00 +0.0%
nii_center_of_masses 3.21 ±0.00 3.21 ±0.00 +0.0%
poi_reorient 3.89 ±0.00 3.89 ±0.00 +0.0%
poi_to_global 3.14 ±0.00 3.14 ±0.00 +0.0%
poi_local_to_global_arr 3.02 ±0.00 3.02 ±0.00 +0.0%
metric_voxels 250463.00 ±0.00 250463.00 ±0.00 +0.0%
metric_labels 3.00 ±0.00 3.00 ±0.00 +0.0%
metric_foreground_pct 14.51 ±0.00 14.51 ±0.00 +0.0%
nii_get_array 1.65 ±0.00 1.65 ±0.00 +0.0% (noise)
nii_compute_crop 2.96 ±0.00 2.96 ±0.00 +0.0% (noise)
nii_unique 2.90 ±0.00 2.90 ±0.00 +0.0% (noise)
poi_rescale 2.61 ±0.00 2.61 ±0.00 +0.0% (noise)
poi_save 1.46 ±0.00 1.46 ±0.00 +0.0% (noise)
poi_map_labels 1.77 ±0.00 1.77 ±0.00 +0.0% (noise)
poi_load 1.61 ±0.00 1.61 ±0.00 +0.0% (noise)

ct_2d — shape (73, 47, 1)

Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
poi_resample_from_to 5.46 ±0.00 5.38 ±0.00 -1.6%
nii_rescale 6.36 ±0.00 6.27 ±0.00 -1.5%
nii_reorient 5.91 ±0.00 5.82 ±0.00 -1.5%
nii_resample_from_to 6.48 ±0.00 6.39 ±0.00 -1.4%
nii_load_seg 6.01 ±0.00 5.93 ±0.00 -1.4%
… 30 more measurements
Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_dilate_msk 5.99 ±0.00 5.93 ±0.00 -1.0%
nii_erode_msk 6.01 ±0.00 5.95 ±0.00 -1.0%
nii_load_img 3.50 ±0.00 3.46 ±0.00 -1.0%
nii_rescale_seg 6.13 ±0.00 6.08 ±0.00 -0.9%
nii_set_dtype 5.30 ±0.00 5.26 ±0.00 -0.9%
nii_pad_to 5.43 ±0.00 5.38 ±0.00 -0.9%
nii_extract_label 5.43 ±0.00 5.38 ±0.00 -0.9%
nii_map_labels 5.49 ±0.00 5.45 ±0.00 -0.9%
nii_apply_crop 5.87 ±0.00 5.82 ±0.00 -0.8%
poi_calc_centroids_nocrop 6.05 ±0.00 6.00 ±0.00 -0.8%
poi_calc_centroids 6.12 ±0.00 6.07 ±0.00 -0.8%
nii_fill_holes 6.34 ±0.00 6.30 ±0.00 -0.7%
nii_get_connected_components 6.62 ±0.00 6.57 ±0.00 -0.7%
nii_filter_connected_components 6.93 ±0.00 6.88 ±0.00 -0.7%
nii_save 3.77 ±0.00 3.77 ±0.00 +0.0%
nii_volumes 3.46 ±0.00 3.46 ±0.00 +0.0%
nii_center_of_masses 3.15 ±0.00 3.15 ±0.00 +0.0%
poi_reorient 3.83 ±0.00 3.83 ±0.00 +0.0%
poi_to_global 3.08 ±0.00 3.08 ±0.00 +0.0%
metric_voxels 3431.00 ±0.00 3431.00 ±0.00 +0.0%
metric_labels 3.00 ±0.00 3.00 ±0.00 +0.0%
metric_foreground_pct 37.60 ±0.00 37.60 ±0.00 +0.0%
nii_get_array 1.59 ±0.00 1.59 ±0.00 +0.0% (noise)
nii_compute_crop 2.90 ±0.00 2.90 ±0.00 +0.0% (noise)
nii_unique 2.84 ±0.00 2.84 ±0.00 +0.0% (noise)
poi_rescale 2.54 ±0.00 2.54 ±0.00 +0.0% (noise)
poi_local_to_global_arr 2.96 ±0.00 2.96 ±0.00 +0.0% (noise)
poi_save 1.40 ±0.00 1.40 ±0.00 +0.0% (noise)
poi_map_labels 1.71 ±0.00 1.71 ±0.00 +0.0% (noise)
poi_load 1.55 ±0.00 1.55 ±0.00 +0.0% (noise)

mri_3d — shape (68, 52, 67)

Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
poi_resample_from_to 5.46 ±0.00 5.38 ±0.00 -1.6%
nii_rescale 6.36 ±0.00 6.27 ±0.00 -1.5%
nii_reorient 5.91 ±0.00 5.82 ±0.00 -1.5%
nii_resample_from_to 6.48 ±0.00 6.39 ±0.00 -1.4%
nii_load_seg 6.01 ±0.00 5.93 ±0.00 -1.4%
… 31 more measurements
Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_dilate_msk 5.99 ±0.00 5.93 ±0.00 -1.0%
nii_erode_msk 6.01 ±0.00 5.95 ±0.00 -1.0%
nii_load_img 3.56 ±0.00 3.53 ±0.00 -1.0%
nii_rescale_seg 6.13 ±0.00 6.08 ±0.00 -0.9%
nii_set_dtype 5.37 ±0.00 5.32 ±0.00 -0.9%
nii_pad_to 5.43 ±0.00 5.38 ±0.00 -0.9%
nii_extract_label 5.43 ±0.00 5.38 ±0.00 -0.9%
nii_map_labels 5.49 ±0.00 5.45 ±0.00 -0.9%
nii_apply_crop 5.87 ±0.00 5.82 ±0.00 -0.8%
poi_calc_centroids_nocrop 5.99 ±0.00 5.94 ±0.00 -0.8%
poi_calc_centroids 6.12 ±0.00 6.07 ±0.00 -0.8%
nii_fill_holes 6.34 ±0.00 6.30 ±0.00 -0.7%
nii_get_connected_components 6.62 ±0.00 6.57 ±0.00 -0.7%
nii_filter_connected_components 6.93 ±0.00 6.88 ±0.00 -0.7%
poi_calc_poi_from_subreg_vert 7.30 ±0.00 7.25 ±0.00 -0.6%
nii_save 3.77 ±0.00 3.77 ±0.00 +0.0%
nii_volumes 3.46 ±0.00 3.46 ±0.00 +0.0%
nii_center_of_masses 3.15 ±0.00 3.15 ±0.00 +0.0%
poi_reorient 3.83 ±0.00 3.83 ±0.00 +0.0%
poi_to_global 3.08 ±0.00 3.08 ±0.00 +0.0%
metric_voxels 236912.00 ±0.00 236912.00 ±0.00 +0.0%
metric_labels 8.00 ±0.00 8.00 ±0.00 +0.0%
metric_foreground_pct 18.21 ±0.00 18.21 ±0.00 +0.0%
nii_get_array 1.59 ±0.00 1.59 ±0.00 +0.0% (noise)
nii_compute_crop 2.90 ±0.00 2.90 ±0.00 +0.0% (noise)
nii_unique 2.84 ±0.00 2.84 ±0.00 +0.0% (noise)
poi_rescale 2.54 ±0.00 2.54 ±0.00 +0.0% (noise)
poi_local_to_global_arr 2.96 ±0.00 2.96 ±0.00 +0.0% (noise)
poi_save 1.46 ±0.00 1.46 ±0.00 +0.0% (noise)
poi_map_labels 1.71 ±0.00 1.71 ±0.00 +0.0% (noise)
poi_load 1.55 ±0.00 1.55 ±0.00 +0.0% (noise)

mri_2d — shape (68, 52, 1)

Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
poi_resample_from_to 5.46 ±0.00 5.38 ±0.00 -1.6%
nii_rescale 6.36 ±0.00 6.27 ±0.00 -1.5%
nii_reorient 5.91 ±0.00 5.82 ±0.00 -1.5%
nii_resample_from_to 6.48 ±0.00 6.39 ±0.00 -1.4%
nii_load_seg 6.01 ±0.00 5.93 ±0.00 -1.4%
… 30 more measurements
Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_dilate_msk 5.99 ±0.00 5.93 ±0.00 -1.0%
nii_erode_msk 6.01 ±0.00 5.95 ±0.00 -1.0%
nii_load_img 3.56 ±0.00 3.53 ±0.00 -1.0%
nii_rescale_seg 6.13 ±0.00 6.08 ±0.00 -0.9%
nii_set_dtype 5.37 ±0.00 5.32 ±0.00 -0.9%
nii_pad_to 5.43 ±0.00 5.38 ±0.00 -0.9%
nii_extract_label 5.43 ±0.00 5.38 ±0.00 -0.9%
nii_map_labels 5.49 ±0.00 5.45 ±0.00 -0.9%
nii_apply_crop 5.87 ±0.00 5.82 ±0.00 -0.8%
poi_calc_centroids_nocrop 6.05 ±0.00 6.00 ±0.00 -0.8%
poi_calc_centroids 6.12 ±0.00 6.07 ±0.00 -0.8%
nii_fill_holes 6.34 ±0.00 6.30 ±0.00 -0.7%
nii_get_connected_components 6.62 ±0.00 6.57 ±0.00 -0.7%
nii_filter_connected_components 6.93 ±0.00 6.88 ±0.00 -0.7%
nii_save 3.77 ±0.00 3.77 ±0.00 +0.0%
nii_volumes 3.46 ±0.00 3.46 ±0.00 +0.0%
nii_center_of_masses 3.15 ±0.00 3.15 ±0.00 +0.0%
poi_reorient 3.83 ±0.00 3.83 ±0.00 +0.0%
poi_to_global 3.08 ±0.00 3.08 ±0.00 +0.0%
metric_voxels 3536.00 ±0.00 3536.00 ±0.00 +0.0%
metric_labels 7.00 ±0.00 7.00 ±0.00 +0.0%
metric_foreground_pct 50.17 ±0.00 50.17 ±0.00 +0.0%
nii_get_array 1.59 ±0.00 1.59 ±0.00 +0.0% (noise)
nii_compute_crop 2.90 ±0.00 2.90 ±0.00 +0.0% (noise)
nii_unique 2.84 ±0.00 2.84 ±0.00 +0.0% (noise)
poi_rescale 2.54 ±0.00 2.54 ±0.00 +0.0% (noise)
poi_local_to_global_arr 2.96 ±0.00 2.96 ±0.00 +0.0% (noise)
poi_save 1.46 ±0.00 1.46 ±0.00 +0.0% (noise)
poi_map_labels 1.71 ±0.00 1.71 ±0.00 +0.0% (noise)
poi_load 1.55 ±0.00 1.55 ±0.00 +0.0% (noise)

Gate: a measurement fails when the baseline is ≥ 1 MiB, the median grows by ≥ 50%, and Welch's t-test gives p < 0.05. metric_* rows are context only.

@Hendrik-code Hendrik-code self-assigned this Aug 31, 2026
@Hendrik-code Hendrik-code added the enhancement New feature or request label Aug 31, 2026
@robert-graf

Copy link
Copy Markdown
Collaborator

Suggestion: partition_segmentation_by_volume
partition_segmentation_by_cms

@robert-graf robert-graf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename and approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants