feat(atlas): multi-region get_mesh and batched atlas mesh prefetch - #448
Open
FelipeCybis wants to merge 7 commits into
Open
FelipeCybis wants to merge 7 commits into
FelipeCybis wants to merge 7 commits into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
|
📖 Doc preview: https://confusius.tools/pr-preview/pr-448/ |
Member
Author
|
@sdiebolt this should be good to be reviewed! |
FelipeCybis
force-pushed
the
atlas-mesh
branch
from
September 24, 2026 17:23
200876e to
daa2ec9
Compare
FelipeCybis
force-pushed
the
atlas-mesh
branch
from
September 24, 2026 17:47
efaa213 to
70e90b4
Compare
get_atlas_mesh's clip step materialized the full lazily derived z/y/x coordinate grids of an oblique atlas only to reduce them to per-axis min/max. Add get_bounding_box, which maps the 8 corners of the voxel-coordinate box through the voxel-to-world affine (identical bounds, O(1) in grid size), and clip meshes with it. Closes #444
…dict
`get_mesh`/`get_atlas_mesh` now mirror `get_masks`: `regions` and `sides`
broadcast through a shared `_normalize_regions_and_sides` helper, all vertices
are warped through `world_to_base` in one batched pass, and the result is a
`{acronym: (vertices, faces)}` dict with `_L`/`_R` keys for single-hemisphere
requests.
The atlas fixtures move to `tests/unit/conftest.py` so other test modules can
build on the same mock atlas, and the child region gains its own mesh so a
multi-region call that mis-splits the batched vertex transform cannot pass.
BrainGlobe 3 downloads each region mesh lazily on first access, one S3 `exists` + `get` round trip per region (about a second each). On the first fetch of an atlas, `fetch_brainglobe_atlas` now lists the remote mesh directory once and pulls every missing mesh in a single concurrent `s3fs.get` call (839 Allen mouse meshes in ~20 s instead of ~14 min), so `get_mesh` works offline afterwards. Regions with no remote mesh (e.g. RSPd4 in the Allen mouse atlas) and an unreachable bucket both warn and fall back to BrainGlobe's lazy download, and a failed batch removes any partially written file, as BrainGlobe does, since it treats any existing file as a valid cached mesh.
Both now return a dict of meshes, so the plural name matches the API.
FelipeCybis
force-pushed
the
atlas-mesh
branch
from
September 25, 2026 18:18
70e90b4 to
45be268
Compare
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.
Stacked on #446; #263 stacks on top of this one.
What
get_mesh/get_atlas_meshnow takeregionsandsideslikeget_masks(one region or a sequence, one side for all or one per region) and return a{acronym: (vertices, faces)}dict, with_L/_R-suffixed keys for single-hemisphere requests. All vertices go throughworld_to_basein one batched pass.fetch_brainglobe_atlasprefetches every region mesh on the first fetch of an atlas. BrainGlobe 3 downloads meshes lazily, one S3exists+getround trip per region (about 1 s each). We list the remote mesh directory once and pull every missing mesh in a single concurrents3fs.getcall: the 839 Allen mouse meshes take about 20 s instead of about 14 min, andget_meshworks offline afterwards.Notes
remote_url_s3andV3_MESHES_DIRECTORYinbrainglobe_atlasapi.descriptors. Upstream has no bulk download API yet ([Feature] Allow users to force download individual atlas components on install brainglobe/brainglobe-atlasapi#784).tests/unit/conftest.pyso other test modules can reuse the mock atlas.