Repository navigation
implement grapharrayview downscale in Tracks - #301
Draft
TeunHuijben wants to merge 1 commit into
Draft
TeunHuijben wants to merge 1 commit into
TeunHuijben wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #301 +/- ##
==========================================
+ Coverage 93.97% 94.03% +0.06%
==========================================
Files 60 60
Lines 3599 3640 +41
==========================================
+ Hits 3382 3423 +41
Misses 217 217 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
What this branch does
Before, a
Trackshad exactly one segmentation: a full-size label image, one number per pixel, where the number is the node id. Drawing one 3D timepoint of a big dataset means building that whole thing in memory — several gigabytes — and napari rebuilds it every time you click something.This branch adds a second, smaller version of that same picture. You ask for it with
tracks.display_segmentation((1, 4, 4)), meaning "keep every z slice, but shrink y and x by 4". It is built from the same graph, and the cells still carry their own node ids as labels, so clicking one still identifies the right cell. It is just 16x less data to build and draw. Cells too small to survive the shrinking are drawn as a single dot instead of disappearing, which is what keeps them clickable.Three supporting pieces:
tracks.display_scale((1, 4, 4))tells you how big the voxels are in the small picture. Without it, napari would draw the shrunken image at a quarter of its real size.1gives you the original full-size picture, unchanged. So the calling code never needs an if-statement — it just always asks.And one safety rail. The full-size
tracks.segmentationis not only for display: saving segmentation to disk, checking intensity images, and computing overlap between cells all read it. If a shrunken picture ever got put there, saving would silently write a broken file — no error, just wrong output. Sotracks.segmentationnow refuses to accept a shrunken one.The other rule lives on the caller's side: positions read off the small picture are in small-picture coordinates. Never use them to edit. Use the full-size picture for anything you draw or measure.
Breaking changes
None in practice.
tracks.segmentationreads exactly as before — same object, same shape, same dtype, same contents — so existing apps need no change, anddisplay_segmentationis purely opt-in.Technically,
segmentationis a property now rather than a plain attribute. Reading and assigning work as before, and assigning still accepts any full-resolutionGraphArrayVieworNone; the only new rejection is a downscaled view, which nothing predating this PR can construct. The one way it could bite is code reaching intotracks.__dict__["segmentation"], which is now_segmentation_array— nothing in funtracks does that, and nothing pickles aTracks.Worth noting that this has no breaking changes, as
Tracks.segmentationworks the same as before. Only change is that any downstream application that wants to use the downscaling should useTracks.display_sgmentation. for nTE, it should always useTracks.display_segmentation, as the downscale factors default to 1, and in that caseTracks.display_segmentationreturnsTracks.segmentationdirectlyDependency
Pinned to
TeunHuijben/tracksdata@49388d6, which carries royerlab/tracksdata#341 (GraphArrayView(downscale=...)). That commit also carries #340 (GraphView(root_fallback=True)), but nothing here uses it —root_fallbackdefaults toFalseand does not appear insrc/. Repin once #341 lands in a tracksdata release.