python_on_layers: optional ROI (sub-cube) for finer scale, local-only#16
Open
davidackerman wants to merge 1 commit into
Open
python_on_layers: optional ROI (sub-cube) for finer scale, local-only#16davidackerman wants to merge 1 commit into
davidackerman wants to merge 1 commit into
Conversation
Adds an optional 'roi' arg: {min_nm:[a,b,c], max_nm:[a,b,c]} in
array-axis order (matches layer.spacing). When supplied, only the
sub-cube is read into Python AND the auto-picker budgets against the
ROI's voxel count instead of the full array — so a smaller ROI unlocks
a finer scale that wouldn't otherwise fit the runtime budget.
Touchpoints:
- agent.ts: parse + validate roi; per-layer voxel-coord conversion;
ROI-aware scale picker; pass through to worker as 'roiVoxel' on each
layer; shift the Python-side offset_nm to the ROI's world origin so
reported positions stay absolute.
- analysis_worker.ts: readLayerArray now accepts roiVoxel and applies
zarr.slice on spatial axes; computed offsets shift accordingly.
- System prompt: documents 'roi', including the requirement to fill in
all six coords (use describe_dataset for unconstrained axes).
Scope intentionally narrow for v1:
- Local Pyodide path only — HF backend (tensorstore slicing) is the
follow-up PR; needs an HF subtree push to test.
- Zarr only — precomputed-volume ROI is also follow-up.
- NG annotation auto-detection deferred; the agent reads 'roi' from
its tool args today.
Deploying tourguide with
|
| Latest commit: |
d3ed342
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c77ddf81.tourguide-8j4.pages.dev |
| Branch Preview URL: | https://feat-roi-subregion.tourguide-8j4.pages.dev |
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 an optional `roi` argument to `python_on_layers` so the agent can restrict an analysis to a sub-cube of the volume. When a ROI is supplied:
Shape
```json
{ "min_nm": [a, b, c], "max_nm": [a, b, c] }
```
Array-axis order (typically z, y, x — same convention as `layers[var].spacing`). All six coords required; for axes the user didn't constrain, the agent fills in the layer's full extent from `describe_dataset`.
Scope
Deliberately narrow for v1 — validate the value-add before broadening.
Why now
User flagged "we could do higher res as long as it's a smaller ROI" — without this arg, every analysis fights the auto-picker's full-volume budget, which forces coarse scales on big datasets even when only a tiny region is interesting.