Fix registration worker OOM on large images#126
Draft
arjunrajlab wants to merge 2 commits intomasterfrom
Draft
Conversation
Two-part fix for memory exhaustion when processing large images: 1. Auto-crop to center 2048x2048 for registration matrix computation when no reference region is specified and the image is large 2. Use scipy.ndimage.affine_transform with float32 in the output loop instead of pystackreg's sr.transform which internally uses float64, cutting peak memory roughly in half Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers how the worker operates, interface parameters, implementation details (auto-crop, memory-efficient transform, control points), full test inventory, lessons learned from OOM debugging, and future TODOs. Co-Authored-By: Claude Opus 4.6 <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
pystackreg'ssr.transform()(float64) with ascipy.ndimage.affine_transform-based helper using float32 in the output loop, cutting peak memory ~in halfContext
The registration worker crashes with exit code 137 (OOM kill) when processing large images (e.g., 12089x12089 with 7 channels and 2 timepoints).
pystackreg'sStackReg.transform()internally converts to float64, creating ~2.9 GB temporary arrays per frame.Test plan
./build_workers.sh --build-and-run-tests registration)🤖 Generated with Claude Code