Skip to content

Dtype resampling - #140

Open
robert-graf wants to merge 2 commits into
mainfrom
dtype_resampling
Open

Dtype resampling#140
robert-graf wants to merge 2 commits into
mainfrom
dtype_resampling

Conversation

@robert-graf

Copy link
Copy Markdown
Collaborator

feat(nii): out_dtype for resampling + first-class float16/bool arrays

Summary

Adds an out_dtype kwarg to the NII resample surface so callers can pick the target dtype in one step, and teaches the NII wrapper to carry arrays in dtypes NIfTI-1 can't encode (float16, bool) without crashing — the upcast now happens only when we materialise a Nifti1Image (i.e. on save or when handing the underlying nibabel object out). Wires the new kwarg through the VibeSeg nnU-Net pre-processing pipeline so the input tensor fed to inference is 4× smaller.

_resample_from_to (TPTBox/core/internal/nii_help.py)

  • New out_dtype: np.dtype | type | str | None = None kwarg.
  • Forwarded to scipy.ndimage.affine_transform as output=, so the cast is folded into the interpolation write — no extra full-volume copy.
  • scipy.ndimage.affine_transform only accepts u8/u16/i16/i32/f32/f64 for output=. Requesting anything else (notably float16) transparently falls back to resampling into float32 and casting to the requested dtype in a single extra pass — still much cheaper than staying in the source dtype throughout.

NII wrapper wiring (TPTBox/core/nii_wrapper.py)

The out_dtype kwarg is threaded through every public entry point that flows into _resample_from_to:

┌──────────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ method │ note │
├──────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ rescale / rescale_ │ forwards to resample_from_to │
├──────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ resample_from_to / resample_from_to
│ only affects the actual resample path; the identity-skip / reorient-only / pad-only shortcuts keep the source dtype (documented) │
├──────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ rescale_and_reorient / rescale_and_reorient_ │ forwards to rescale; the reorient step is a pure axis relabel and keeps the source dtype │
└──────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

First-class float16 / bool inside a NII

Two new helpers colocated with _resample_from_to:

  • _NIFTI_UNSUPPORTED_DTYPE_UPCAST = {float16 → float32, bool → uint8}
  • _nifti_safe_dtype(dtype) — returns a nibabel-compatible dtype (identity for supported ones).
  • _arr_for_nifti1(arr) — returns arr as-is if the dtype is safe, else a copy in the upcast dtypeage is actually built.

Six call sites in nii_wrapper.py that used to raise HeaderDataError on float16/bool are guarded:

  • nii setter tuple-branch, nii setter no-header branch, nii getter reconstruction path (both Nifti1Image calls + set_data_dtype)
  • set_array — dropped the eager bool → uint8 / float16 → float32 upcasts; header uses _nifti_safe_dtype
  • set_dtype (both unpacked / non-unpacked branches) — header uses safe dtype; array keeps the re
  • save — on-disk copy goes through _arr_for_nifti1 and _nifti_safe_dtype; self._arr is untouched
  • _check_if_nifty_is_lying_about_its_dtype — deduplicated: the hardcoded float16 → float32 rule dtype, so future additions to the map propagate automatically

The caller-visible self.dtype reflects the actual array dtype (float16/bool) — upcasting is a ma

VibeSeg pre-inference (TPTBox/segmentation/VibeSeg/inference_nnunet.py)

  • Reordered squash_so_it_fits_in_float16 before the rescale (any needed intensity divide happens
  • Threaded the new kwarg: i.rescale_(zoom, mode=mode, verbose=True, out_dtype=np.float16).
  • If no zoom is provided, fall back to i.set_dtype(np.float16) so the pipeline always hands nnU-

Verified behaviour

rescale_(zoom, out_dtype=np.float16) → NII.dtype == float16, array bytes ÷4
save+reload float16 → file dtype = float32, max_abs_diff = 0.0
mask = (nii > 100) → NII.dtype == bool (in-memory)
save+reload bool → file dtype = uint8, values preserved
set_dtype(np.float16) → NII.dtype == float16

VibeSeg end-to-end (tutorial MR, RTX-class GPU, 3-fold ensemble)

Intermediate tensor handed to run_inference (measured with a spy on TPTBox.segmentation.nnUnet_utils.inference_api.run_inference):

┌───────────────────────────────────┬─────────┬────────────────────────────────┐
│ variant │ dtype │ array bytes │
├───────────────────────────────────┼─────────┼────────────────────────────────┤
│ baseline (source dtype preserved) │ float64 │ 40.29 MiB │
├───────────────────────────────────┼─────────┼────────────────────────────────┤
│ new (out_dtype=float16) │ float16 │ 10.07 MiB │
├───────────────────────────────────┼─────────┼────────────────────────────────┤
│ saved │ │ 30.22 MiB, −75% (4× reduction) │
└───────────────────────────────────┴─────────┴────────────────────────────────┘

Wall time: 7.8 s vs 7.9 s (≈ ±2%, GPU-inference dominates and hides the pre-processing delta). S: 99.9945% voxel-identical, no label with Dice < 0.999 — expected, because run_inference already
does an unconditional .astype(np.float16) on the input at inference_api.py:333, so the numbers rical between the two paths. The change simply earlier the cast and skips the float64 intermediates
in between (crop, pad, get_array).

The real payoff is on large clinical volumes: the same 4× saving is ~600 MiB on a 500×400×400 float64 input, which matters for the est_full_mb > total_ram_mb * 0.5 gate in run_inference_on_file that decides whether to fall
back to CPU-chunked inference.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

Benchmark comparison

Speed (wall time per call)

baseline afc748d vs head afc748d · 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_erode_msk 6.50 ±0.12 6.32 ±0.08 -2.8% 0.020
nii_load_img 10.98 ±0.10 10.78 ±0.07 -1.9% 0.025
nii_dilate_msk 126.06 ±0.56 123.83 ±0.45 -1.8% 0.000
nii_filter_connected_components 4.46 ±0.03 4.40 ±0.06 -1.5% 0.403
nii_fill_holes 4.72 ±0.06 4.66 ±0.12 -1.3% 0.543
… 31 more measurements
Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
nii_rescale_seg 3.26 ±0.05 3.22 ±0.11 -1.1% 0.589
poi_calc_poi_from_subreg_vert 12.77 ±0.14 12.90 ±0.26 +1.1% 0.638
poi_calc_centroids_nocrop 4.39 ±0.10 4.36 ±0.07 -0.8% 0.407
nii_resample_from_to 42.04 ±0.09 41.99 ±0.32 -0.1% 0.817
nii_save 11.79 ±0.16 11.80 ±0.07 +0.1% 0.807
nii_rescale 39.89 ±0.22 39.90 ±0.31 +0.0% 0.501
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_extract_label 0.49 ±0.02 0.42 ±0.03 -14.1% (noise) 0.002
nii_apply_crop 0.78 ±0.04 0.68 ±0.06 -12.5% (noise) 0.012
nii_get_array 0.06 ±0.01 0.05 ±0.00 -8.6% (noise) 0.048
poi_rescale 0.24 ±0.02 0.25 ±0.03 +6.7% (noise) 0.867
nii_compute_crop 0.35 ±0.01 0.33 ±0.02 -6.5% (noise) 0.082
nii_pad_to 0.78 ±0.04 0.73 ±0.06 -6.4% (noise) 0.073
nii_set_dtype 0.55 ±0.02 0.51 ±0.03 -6.0% (noise) 0.008
nii_unique 0.72 ±0.01 0.68 ±0.02 -5.1% (noise) 0.002
nii_map_labels 1.08 ±0.02 1.03 ±0.02 -4.7% (noise) 0.001
poi_load 1.00 ±0.04 1.04 ±0.08 +3.9% (noise) 0.289
poi_resample_from_to 0.74 ±0.03 0.71 ±0.04 -3.4% (noise) 0.732
poi_map_labels 0.19 ±0.02 0.20 ±0.02 +2.9% (noise) 0.928
poi_calc_centroids 2.57 ±0.07 2.51 ±0.05 -2.5% (noise) 0.522
poi_save 0.47 ±0.03 0.48 ±0.03 +2.2% (noise) 0.381
nii_get_connected_components 2.32 ±0.02 2.27 ±0.03 -2.1% (noise) 0.022
nii_center_of_masses 1.76 ±0.01 1.73 ±0.01 -1.8% (noise) 0.000
nii_volumes 1.91 ±0.03 1.88 ±0.02 -1.5% (noise) 0.055
nii_load_seg 2.88 ±0.09 2.83 ±0.12 -1.5% (noise) 0.204
poi_local_to_global_arr 0.32 ±0.02 0.33 ±0.01 +1.4% (noise) 0.991
nii_reorient 0.87 ±0.05 0.86 ±0.06 -0.9% (noise) 0.512
poi_reorient 0.43 ±0.03 0.44 ±0.03 +0.8% (noise) 0.727
poi_to_global 0.23 ±0.01 0.23 ±0.01 +0.5% (noise) 0.836

ct_2d — shape (73, 47, 1)

Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
nii_resample_from_to 7.78 ±0.11 7.38 ±0.13 -5.1% 0.001
nii_rescale 5.78 ±0.14 5.50 ±0.18 -5.0% 0.016
nii_dilate_msk 14.94 ±0.09 14.49 ±0.06 -3.0% 0.000
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_apply_crop 0.76 ±0.03 0.69 ±0.02 -8.5% (noise) 0.002
poi_save 0.52 ±0.02 0.56 ±0.05 +8.5% (noise) 0.248
nii_unique 0.14 ±0.02 0.13 ±0.01 -8.4% (noise) 0.137
nii_get_array 0.02 ±0.00 0.02 ±0.00 -7.1% (noise) 0.207
nii_compute_crop 0.16 ±0.01 0.15 ±0.00 -3.9% (noise) 0.178
nii_map_labels 0.53 ±0.02 0.55 ±0.02 +3.8% (noise) 0.097
nii_get_connected_components 0.70 ±0.03 0.68 ±0.01 -3.7% (noise) 0.091
poi_calc_centroids_nocrop 1.24 ±0.05 1.20 ±0.02 -3.3% (noise) 0.038
nii_set_dtype 0.46 ±0.01 0.47 ±0.04 +3.2% (noise) 0.330
poi_to_global 0.26 ±0.01 0.25 ±0.01 -3.1% (noise) 0.053
nii_reorient 0.89 ±0.04 0.91 ±0.04 +2.9% (noise) 0.591
nii_extract_label 0.46 ±0.01 0.48 ±0.02 +2.6% (noise) 0.336
nii_filter_connected_components 0.88 ±0.03 0.91 ±0.05 +2.4% (noise) 0.195
nii_load_img 1.63 ±0.07 1.60 ±0.05 -2.4% (noise) 0.384
poi_reorient 0.49 ±0.02 0.50 ±0.01 +2.3% (noise) 0.243
nii_erode_msk 1.04 ±0.01 1.06 ±0.03 +2.2% (noise) 0.111
nii_rescale_seg 0.85 ±0.03 0.84 ±0.02 -2.1% (noise) 0.187
nii_load_seg 1.76 ±0.09 1.79 ±0.07 +1.9% (noise) 0.944
nii_volumes 0.31 ±0.01 0.30 ±0.01 -1.8% (noise) 0.242
nii_center_of_masses 0.22 ±0.01 0.22 ±0.01 -1.8% (noise) 0.200
nii_fill_holes 0.94 ±0.03 0.93 ±0.02 -1.0% (noise) 0.904
nii_pad_to 0.61 ±0.02 0.61 ±0.03 +1.0% (noise) 0.557
poi_calc_centroids 1.00 ±0.05 0.99 ±0.01 -1.0% (noise) 0.152
nii_save 1.47 ±0.03 1.46 ±0.08 -1.0% (noise) 0.944
poi_load 1.10 ±0.03 1.11 ±0.03 +0.9% (noise) 0.440
poi_rescale 0.28 ±0.00 0.28 ±0.02 +0.7% (noise) 0.392
poi_map_labels 0.22 ±0.01 0.22 ±0.01 -0.3% (noise) 0.715
poi_local_to_global_arr 0.34 ±0.02 0.34 ±0.01 -0.2% (noise) 0.418
poi_resample_from_to 0.79 ±0.01 0.79 ±0.02 -0.1% (noise) 0.803

mri_3d — shape (68, 52, 67)

Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
nii_load_seg 3.07 ±0.10 2.96 ±0.06 -3.8% 0.024
nii_filter_connected_components 4.91 ±0.06 4.74 ±0.07 -3.5% 0.012
nii_fill_holes 5.64 ±0.06 5.48 ±0.06 -2.7% 0.002
nii_dilate_msk 164.09 ±1.35 159.94 ±1.04 -2.5% 0.001
poi_calc_centroids_nocrop 8.95 ±0.14 8.76 ±0.13 -2.1% 0.017
… 31 more measurements
Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
nii_rescale 38.11 ±0.15 37.57 ±0.35 -1.4% 0.013
nii_resample_from_to 40.30 ±0.44 39.74 ±0.49 -1.4% 0.090
nii_rescale_seg 3.26 ±0.07 3.22 ±0.11 -1.3% 0.828
nii_erode_msk 7.99 ±0.10 7.90 ±0.13 -1.0% 0.228
poi_calc_poi_from_subreg_vert 12.28 ±0.04 12.18 ±0.19 -0.7% 0.165
nii_load_img 9.01 ±0.07 8.98 ±0.08 -0.3% 0.616
nii_save 9.65 ±0.07 9.64 ±0.17 -0.1% 0.466
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 0.06 ±0.01 0.05 ±0.00 -10.0% (noise) 0.097
poi_local_to_global_arr 0.36 ±0.01 0.34 ±0.01 -7.5% (noise) 0.003
poi_save 0.58 ±0.02 0.62 ±0.02 +6.1% (noise) 0.039
nii_map_labels 1.09 ±0.04 1.03 ±0.02 -5.2% (noise) 0.005
poi_map_labels 0.27 ±0.03 0.26 ±0.01 -4.9% (noise) 0.248
poi_to_global 0.31 ±0.01 0.29 ±0.01 -4.4% (noise) 0.357
poi_rescale 0.32 ±0.01 0.33 ±0.02 +3.9% (noise) 0.181
poi_calc_centroids 2.89 ±0.07 2.79 ±0.03 -3.7% (noise) 0.022
nii_unique 0.70 ±0.02 0.67 ±0.02 -3.5% (noise) 0.248
nii_pad_to 0.79 ±0.02 0.77 ±0.03 -3.4% (noise) 0.069
poi_load 2.27 ±0.03 2.33 ±0.03 +2.5% (noise) 0.034
nii_apply_crop 0.79 ±0.04 0.77 ±0.01 -2.2% (noise) 0.253
nii_volumes 2.01 ±0.02 1.97 ±0.02 -1.8% (noise) 0.054
nii_extract_label 0.52 ±0.02 0.51 ±0.02 -1.7% (noise) 0.922
poi_reorient 0.52 ±0.01 0.53 ±0.06 +1.7% (noise) 0.366
poi_resample_from_to 0.86 ±0.03 0.84 ±0.07 -1.6% (noise) 0.874
nii_set_dtype 0.57 ±0.02 0.58 ±0.02 +1.2% (noise) 0.690
nii_compute_crop 0.36 ±0.02 0.36 ±0.01 -0.9% (noise) 0.265
nii_center_of_masses 2.01 ±0.02 1.99 ±0.04 -0.8% (noise) 0.846
nii_get_connected_components 2.28 ±0.03 2.26 ±0.07 -0.8% (noise) 0.642
nii_reorient 0.98 ±0.05 0.98 ±0.18 +0.0% (noise) 0.431

mri_2d — shape (68, 52, 1)

Measurement baseline ms (median ±½·range) head ms (median ±½·range) Δ % p
nii_resample_from_to 7.88 ±0.10 7.59 ±0.14 -3.6% 0.003
nii_dilate_msk 19.85 ±0.07 19.23 ±0.07 -3.1% 0.000
nii_rescale 5.49 ±0.10 5.42 ±0.08 -1.2% 0.150
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_volumes 0.49 ±0.03 0.45 ±0.02 -6.4% (noise) 0.079
nii_rescale_seg 0.89 ±0.14 0.83 ±0.02 -6.3% (noise) 0.141
nii_load_seg 1.81 ±0.03 1.91 ±0.09 +5.4% (noise) 0.432
poi_calc_centroids 1.18 ±0.01 1.24 ±0.08 +4.9% (noise) 0.152
nii_set_dtype 0.42 ±0.01 0.44 ±0.02 +4.7% (noise) 0.218
nii_reorient 0.93 ±0.02 0.89 ±0.04 -4.3% (noise) 0.483
poi_local_to_global_arr 0.35 ±0.01 0.34 ±0.02 -4.2% (noise) 0.054
nii_get_array 0.02 ±0.00 0.02 ±0.00 +4.1% (noise) 0.755
nii_pad_to 0.63 ±0.02 0.61 ±0.01 -4.0% (noise) 0.028
nii_fill_holes 1.19 ±0.04 1.15 ±0.02 -3.4% (noise) 0.091
nii_get_connected_components 0.68 ±0.02 0.66 ±0.03 -3.4% (noise) 0.195
nii_center_of_masses 0.41 ±0.02 0.42 ±0.02 +3.2% (noise) 0.884
nii_extract_label 0.47 ±0.05 0.46 ±0.01 -2.6% (noise) 0.212
poi_save 0.55 ±0.02 0.57 ±0.03 +2.5% (noise) 0.677
nii_filter_connected_components 0.95 ±0.02 0.93 ±0.01 -2.4% (noise) 0.313
poi_calc_centroids_nocrop 1.51 ±0.07 1.48 ±0.03 -2.1% (noise) 0.146
nii_load_img 1.58 ±0.06 1.55 ±0.12 -1.9% (noise) 0.570
poi_to_global 0.28 ±0.01 0.29 ±0.00 +1.7% (noise) 0.646
poi_map_labels 0.26 ±0.02 0.27 ±0.01 +1.6% (noise) 0.907
poi_load 2.00 ±0.03 1.97 ±0.04 -1.6% (noise) 0.204
poi_resample_from_to 0.81 ±0.03 0.80 ±0.03 -1.3% (noise) 0.285
nii_unique 0.14 ±0.00 0.13 ±0.00 -1.1% (noise) 0.210
poi_rescale 0.31 ±0.01 0.31 ±0.00 -1.1% (noise) 0.426
nii_apply_crop 0.76 ±0.02 0.76 ±0.04 -1.0% (noise) 0.671
nii_erode_msk 1.36 ±0.03 1.37 ±0.01 +1.0% (noise) 0.800
poi_reorient 0.52 ±0.02 0.51 ±0.02 -0.9% (noise) 0.669
nii_map_labels 0.53 ±0.03 0.53 ±0.04 +0.4% (noise) 0.864
nii_save 1.43 ±0.03 1.43 ±0.03 -0.4% (noise) 0.746
nii_compute_crop 0.16 ±0.01 0.16 ±0.01 -0.2% (noise) 0.334

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 afc748d vs head afc748d · 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
nii_extract_label 5.43 ±0.00 5.37 ±0.00 -1.2%
nii_rescale_seg 6.01 ±0.00 5.95 ±0.00 -1.1%
nii_rescale 6.24 ±0.00 6.17 ±0.00 -1.1%
nii_resample_from_to 6.36 ±0.00 6.30 ±0.00 -1.0%
nii_erode_msk 5.93 ±0.00 5.95 ±0.00 +0.3%
… 31 more measurements
Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_load_img 3.57 ±0.00 3.56 ±0.00 -0.2%
nii_load_seg 6.02 ±0.00 6.01 ±0.00 -0.1%
nii_center_of_masses 3.28 ±0.00 3.27 ±0.00 -0.1%
nii_volumes 3.53 ±0.00 3.52 ±0.00 -0.1%
nii_save 3.71 ±0.00 3.71 ±0.00 -0.1%
nii_set_dtype 5.25 ±0.00 5.24 ±0.00 -0.1%
nii_pad_to 5.43 ±0.00 5.43 ±0.00 -0.1%
nii_map_labels 5.50 ±0.00 5.49 ±0.00 -0.1%
nii_reorient 5.91 ±0.00 5.91 ±0.00 -0.1%
nii_dilate_msk 5.93 ±0.00 5.93 ±0.00 -0.1%
nii_fill_holes 6.29 ±0.00 6.28 ±0.00 -0.1%
nii_get_connected_components 6.62 ±0.00 6.62 ±0.00 -0.1%
poi_calc_poi_from_subreg_vert 7.11 ±0.00 7.12 ±0.00 +0.1%
nii_apply_crop 5.87 ±0.00 5.87 ±0.00 +0.0%
nii_filter_connected_components 6.87 ±0.00 6.87 ±0.00 +0.0%
poi_calc_centroids 6.06 ±0.00 6.06 ±0.00 +0.0%
poi_calc_centroids_nocrop 5.93 ±0.00 5.93 ±0.00 +0.0%
poi_reorient 3.84 ±0.00 3.84 ±0.00 +0.0%
poi_to_global 3.09 ±0.00 3.09 ±0.00 +0.0%
poi_resample_from_to 5.28 ±0.00 5.28 ±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.2% (noise)
nii_compute_crop 2.90 ±0.00 2.90 ±0.00 -0.1% (noise)
nii_unique 2.96 ±0.00 2.96 ±0.00 -0.1% (noise)
poi_rescale 2.61 ±0.00 2.61 ±0.00 +0.0% (noise)
poi_local_to_global_arr 2.96 ±0.00 2.96 ±0.00 +0.0% (noise)
poi_save 1.41 ±0.00 1.41 ±0.00 +0.0% (noise)
poi_map_labels 1.78 ±0.00 1.78 ±0.00 +0.0% (noise)
poi_load 1.62 ±0.00 1.62 ±0.00 +0.0% (noise)

ct_2d — shape (73, 47, 1)

Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_extract_label 5.37 ±0.00 5.30 ±0.00 -1.2%
nii_rescale_seg 5.95 ±0.00 5.88 ±0.00 -1.1%
nii_rescale 6.17 ±0.00 6.11 ±0.00 -1.0%
nii_resample_from_to 6.30 ±0.00 6.24 ±0.00 -0.9%
nii_erode_msk 5.86 ±0.00 5.88 ±0.06 +0.3% 0.838
… 30 more measurements
Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_load_img 3.50 ±0.00 3.50 ±0.00 +0.0%
nii_load_seg 5.95 ±0.00 5.95 ±0.00 +0.0%
nii_save 3.65 ±0.00 3.65 ±0.00 +0.0%
nii_set_dtype 5.18 ±0.00 5.18 ±0.00 +0.0%
nii_reorient 5.84 ±0.00 5.84 ±0.00 +0.0%
nii_apply_crop 5.80 ±0.00 5.80 ±0.00 +0.0%
nii_pad_to 5.36 ±0.00 5.36 ±0.00 +0.0%
nii_volumes 3.46 ±0.00 3.46 ±0.00 +0.0%
nii_center_of_masses 3.21 ±0.00 3.21 ±0.00 +0.0%
nii_map_labels 5.43 ±0.00 5.43 ±0.00 +0.0%
nii_dilate_msk 5.87 ±0.00 5.87 ±0.00 +0.0%
nii_fill_holes 6.22 ±0.00 6.22 ±0.00 +0.0%
nii_get_connected_components 6.55 ±0.00 6.55 ±0.00 +0.0%
nii_filter_connected_components 6.80 ±0.00 6.80 ±0.00 +0.0%
poi_calc_centroids 5.99 ±0.00 5.99 ±0.00 +0.0%
poi_calc_centroids_nocrop 5.93 ±0.00 5.93 ±0.00 +0.0%
poi_reorient 3.77 ±0.00 3.77 ±0.00 +0.0%
poi_to_global 3.02 ±0.00 3.02 ±0.00 +0.0%
poi_resample_from_to 5.21 ±0.00 5.21 ±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.84 ±0.00 2.84 ±0.00 +0.0% (noise)
nii_unique 2.90 ±0.00 2.90 ±0.00 +0.0% (noise)
poi_rescale 2.54 ±0.00 2.54 ±0.00 +0.0% (noise)
poi_local_to_global_arr 2.89 ±0.00 2.89 ±0.00 +0.0% (noise)
poi_save 1.34 ±0.00 1.34 ±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
nii_extract_label 5.37 ±0.00 5.30 ±0.00 -1.2%
nii_rescale_seg 5.95 ±0.00 5.88 ±0.00 -1.1%
nii_rescale 6.17 ±0.00 6.11 ±0.00 -1.0%
nii_resample_from_to 6.30 ±0.00 6.23 ±0.00 -1.0%
nii_erode_msk 5.86 ±0.00 5.88 ±0.00 +0.3%
… 31 more measurements
Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_load_img 3.56 ±0.00 3.56 ±0.00 +0.0%
nii_load_seg 5.95 ±0.00 5.95 ±0.00 +0.0%
nii_save 3.65 ±0.00 3.65 ±0.00 +0.0%
nii_set_dtype 5.24 ±0.00 5.24 ±0.00 +0.0%
nii_reorient 5.84 ±0.00 5.84 ±0.00 +0.0%
nii_apply_crop 5.80 ±0.00 5.80 ±0.00 +0.0%
nii_pad_to 5.36 ±0.00 5.36 ±0.00 +0.0%
nii_volumes 3.46 ±0.00 3.46 ±0.00 +0.0%
nii_center_of_masses 3.21 ±0.00 3.21 ±0.00 +0.0%
nii_map_labels 5.43 ±0.00 5.43 ±0.00 +0.0%
nii_dilate_msk 5.87 ±0.00 5.87 ±0.00 +0.0%
nii_fill_holes 6.22 ±0.00 6.22 ±0.00 +0.0%
nii_get_connected_components 6.55 ±0.00 6.55 ±0.00 +0.0%
nii_filter_connected_components 6.80 ±0.00 6.80 ±0.00 +0.0%
poi_calc_centroids 5.99 ±0.00 5.99 ±0.00 +0.0%
poi_calc_centroids_nocrop 5.86 ±0.00 5.86 ±0.00 +0.0%
poi_reorient 3.77 ±0.00 3.77 ±0.00 +0.0%
poi_to_global 3.02 ±0.00 3.02 ±0.00 +0.0%
poi_resample_from_to 5.21 ±0.00 5.21 ±0.00 +0.0%
poi_calc_poi_from_subreg_vert 7.11 ±0.00 7.11 ±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.84 ±0.00 2.84 ±0.00 +0.0% (noise)
nii_unique 2.90 ±0.00 2.90 ±0.00 +0.0% (noise)
poi_rescale 2.54 ±0.00 2.54 ±0.00 +0.0% (noise)
poi_local_to_global_arr 2.89 ±0.00 2.89 ±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_2d — shape (68, 52, 1)

Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_extract_label 5.37 ±0.00 5.30 ±0.00 -1.2%
nii_rescale_seg 5.95 ±0.00 5.88 ±0.00 -1.1%
nii_rescale 6.17 ±0.00 6.11 ±0.00 -1.0%
nii_resample_from_to 6.30 ±0.00 6.23 ±0.00 -1.0%
nii_erode_msk 5.86 ±0.00 5.88 ±0.00 +0.3%
… 30 more measurements
Measurement baseline MiB (median ±½·range) head MiB (median ±½·range) Δ % p
nii_load_img 3.56 ±0.00 3.56 ±0.00 +0.0%
nii_load_seg 5.95 ±0.00 5.95 ±0.00 +0.0%
nii_save 3.65 ±0.00 3.65 ±0.00 +0.0%
nii_set_dtype 5.24 ±0.00 5.24 ±0.00 +0.0%
nii_reorient 5.84 ±0.00 5.84 ±0.00 +0.0%
nii_apply_crop 5.80 ±0.00 5.80 ±0.00 +0.0%
nii_pad_to 5.36 ±0.00 5.36 ±0.00 +0.0%
nii_volumes 3.46 ±0.00 3.46 ±0.00 +0.0%
nii_center_of_masses 3.21 ±0.00 3.21 ±0.00 +0.0%
nii_map_labels 5.43 ±0.00 5.43 ±0.00 +0.0%
nii_dilate_msk 5.87 ±0.00 5.87 ±0.00 +0.0%
nii_fill_holes 6.22 ±0.00 6.22 ±0.00 +0.0%
nii_get_connected_components 6.55 ±0.00 6.55 ±0.00 +0.0%
nii_filter_connected_components 6.80 ±0.00 6.80 ±0.00 +0.0%
poi_calc_centroids 5.99 ±0.00 5.99 ±0.00 +0.0%
poi_calc_centroids_nocrop 5.93 ±0.00 5.93 ±0.00 +0.0%
poi_reorient 3.77 ±0.00 3.77 ±0.00 +0.0%
poi_to_global 3.02 ±0.00 3.02 ±0.00 +0.0%
poi_resample_from_to 5.21 ±0.00 5.21 ±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.84 ±0.00 2.84 ±0.00 +0.0% (noise)
nii_unique 2.90 ±0.00 2.90 ±0.00 +0.0% (noise)
poi_rescale 2.54 ±0.00 2.54 ±0.00 +0.0% (noise)
poi_local_to_global_arr 2.89 ±0.00 2.89 ±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)

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant