Add return_indices to local_thickness and porosimetry for compact output - #1164
Add return_indices to local_thickness and porosimetry for compact output#1164ma-sadeghi wants to merge 2 commits into
return_indices to local_thickness and porosimetry for compact output#1164Conversation
…drainage_dt` The default float64 output of `local_thickness`/`porosimetry` becomes the peak-memory bottleneck on large tomograms (e.g. 21 GB for a 1500x1500x1200 volume). With `return_indices=True` these return `(sizes, indices)` instead, where `indices` is a `uint8`/`uint16` image and `sizes[indices]` recovers the float result. Memory drops 8x or more on the output. To save memory inside `porosimetry` too (not just the returned array), the underlying `drainage_dt` gained a matching `return_indices` flag that skips allocating the float `im_size` array and writes the step index into a compact `im_seq`. The mode is opt-in and not compatible with `outlets`, since trapping post-processing relies on `im_size`. Only `method='dt'` is supported for the new flag; the other methods raise `NotImplementedError`. Closes #840.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #1164 +/- ##
=====================================
Coverage 70.4% 70.5%
=====================================
Files 45 45
Lines 6460 6488 +28
=====================================
+ Hits 4554 4576 +22
- Misses 1906 1912 +6 🚀 New features to boost your workflow:
|
|
The |
|
I wonder if this is the right way to fix this? The reality is that all spheres drawn in a digital image have integer radii, so writing fractional radii is actually an artifact of the way the sizes are selected. If sizes is given as N, then it pulls out N sizes between 1 and max(dt). We could change the default behavior of the size generator, and then make the output (im_sizes) respect the dtype of the sizes? (i.e. int32) |
Closes #840.
The default float64 output of
local_thickness/porosimetrybecomes the peak-memory bottleneck on large tomograms (~21 GB for a 1500x1500x1200 volume in OP's case). Withreturn_indices=Truethese now return(sizes, indices)whereindicesisuint8/uint16andsizes[indices]recovers the float result. Output memory drops 8x or more.To save memory inside
porosimetrytoo (not just at the API boundary),drainage_dtgained a matchingreturn_indicesflag that skips allocating the floatim_sizearray and writes the step index into a compactim_seq. The mode is opt-in and not compatible withoutlets, since trapping post-processing relies onim_size.Only
method='dt'is supported for now; the other methods raiseNotImplementedError. Easy to extend toconv/bfin a follow-up if needed.Default behaviour is unchanged. Two new tests added; full unit suite green.