Add SliceJitterTransform: inter-slice misalignment augmentation (#201)#1099
Draft
HanWax wants to merge 2 commits into
Draft
Add SliceJitterTransform: inter-slice misalignment augmentation (#201)#1099HanWax wants to merge 2 commits into
HanWax wants to merge 2 commits into
Conversation
…llPrize#201) Models the per-slice in-plane misalignment of CT reconstruction (stage drift, sample settling, sub-volume stitching): i.i.d. per-slice jitter plus a smooth low-frequency drift along the slice axis. Geometric transform (image + labels move together), single on-device grid_sample with reflection padding, following the Squeeze/Warp/Decohesion template. Self-test: identity at p=0, shape/label preservation, per-slice misalignment present, within-slice rigidity, drift smoothness, and a speed benchmark (119 ms/sample CPU at 160^3, same class as WarpTransform's 93 ms; sub-ms on GPU). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@HanWax is attempting to deploy a commit to the scroll Team on Vercel. A member of the Team first needs to authorize it. |
BasicTransform.apply routes regression_target through _apply_to_segmentation,
which uses mode_seg ('nearest' by default) -- correct for discrete label maps
but wrong for continuous regression targets, which were being quantized. Add an
apply() override that runs regression_target through the bilinear
_apply_to_regr_target path (previously unreachable dead code), and add a
self-test asserting the regression path differs from the nearest seg path.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SliceJitterTransformto the batchgeneratorsv2 fork, for issue #201 ("any additional augmentations that may improve performance are welcome"). It simulates the inter-slice in-plane misalignment of CT reconstruction — stage drift, sample settling, and sub-volume stitching leave adjacent slices slightly shifted, so geometrically smooth sheets appear jagged/stair-stepped in cross-section. This was floated earlier in the issue thread (as "inter-slice z-jitter") but not implemented.Model: displacement of slice k along the scan axis = i.i.d. per-slice in-plane shift (uniform,
jittervoxels) + smooth low-frequency wander (driftvoxels, coarse control points linearly upsampled). Annotations are drawn on the already-misaligned reconstruction, so this is a geometricBasicTransform— image and labels move together (bilinear / nearest), same as Squeeze/Warp.Implementation: follows the Squeeze/Warp/Decohesion template — randomness sampled once in
get_parameters, fully on-device (no CPU/NumPy round-trip), singlegrid_samplewith reflection padding (per the edge-striping finding in #1025), vendored grid helpers for the identical coordinate convention. Regression targets are resampled with bilinear (not the nearest-neighbour pathBasicTransform.applysends them to by default, which would quantize continuous targets) via a smallapply()override.How it differs from existing transforms: elastic deformation is smooth and isotropic — it cannot produce a field that is rigid within a slice yet discontinuous between slices;
WarpTransformis the opposite regime (coherent bend, constant along the normal axis). No existing transform produces slice-wise misalignment.Self-test
python batchgeneratorsv2/transforms/spatial/slice_jitter.py(same convention as the other scroll transforms):Speed
119 ms/sample at 160³ image+seg on CPU vs 93 ms for the merged
WarpTransformin the same environment — same cost class (both are a singlegrid_sample; sub-ms on GPU).Status / TODO (draft until complete)
Closes nothing on its own; contributes to #201.
🤖 Generated with Claude Code