Skip to content

fix(precomputed): sort scales by resolution - #1086

Draft
AKnassa wants to merge 1 commit into
google:masterfrom
AKnassa:rocky/issue-237-sort-precomputed-scales
Draft

fix(precomputed): sort scales by resolution#1086
AKnassa wants to merge 1 commit into
google:masterfrom
AKnassa:rocky/issue-237-sort-precomputed-scales

Conversation

@AKnassa

@AKnassa AKnassa commented Jul 28, 2026

Copy link
Copy Markdown

Fixes #237

What this does

Neuroglancer now sorts the resolution levels of a precomputed volume instead of trusting the order they appear in the file.

Why

The format says the levels must be listed finest-first, but files that list them the other way round do turn up in practice. When that happened, Neuroglancer treated the lowest resolution level as the reference: the volume was reported at the wrong size and with the wrong bounds, and the sharper levels never rendered. This matches what was suggested in the issue thread.

What changed

  • The levels are sorted by voxel size before anything else uses them.
  • Files that already follow the spec are unaffected — sorting them changes nothing at all.
  • Graphene volumes share this code, so they get the same fix.

How to see it

There is a new reversed_scales test fixture holding the same volume as the existing one_channel fixture, but with the levels listed coarsest-first. Its metadata snapshot is now identical to one_channel's apart from the URL. Before this change the two differed by 112 lines.

The format requires the x, y and z `"resolution"` values not to decrease
as the index into `"scales"` increases, but files that list the scales in
another order do occur in practice.  `parseMultiscaleVolumeInfo` took
`scales[0]` as the base scale and `getSources` returned the scales in
file order, so such a file made the coarsest scale define the model
coordinate space: the volume was reported at the coarsest resolution and
with its bounds, and every relative scale came out below one, leaving the
higher-resolution scales unrendered.

Sort the scales by voxel volume before the base scale is taken.  This is
a no-op for conforming files: `Array.prototype.sort` is stable, and the
voxel volume cannot decrease while no individual resolution does.
Graphene reuses `parseMultiscaleVolumeInfo` and is fixed with it.

Adds a `reversed_scales` test fixture holding the same volume as
`one_channel` with the scales listed coarsest first; its metadata
snapshot is now identical to `one_channel`'s apart from the URL.

Fixes google#237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scales ordering in precomputed info file

1 participant