Skip to content

vc_render_tifxyz: make voxel metadata flags optional with sane fallback and emit physical OME‑Zarr scales#737

Open
giorgioangel wants to merge 1 commit intomainfrom
codex/github-mention-vc_render_tifxyz-support-proper-scales-in-o
Open

vc_render_tifxyz: make voxel metadata flags optional with sane fallback and emit physical OME‑Zarr scales#737
giorgioangel wants to merge 1 commit intomainfrom
codex/github-mention-vc_render_tifxyz-support-proper-scales-in-o

Conversation

@giorgioangel
Copy link
Copy Markdown
Member

Motivation

  • Ensure --voxel-size / --voxel-unit are truly optional and provide a sensible default when volume metadata is absent or invalid so tools like Neuroglancer get usable physical scale information.
  • Avoid hard failures on missing/incorrect metadata while preserving the ability to explicitly set a validated physical voxel size.

Description

  • Clarified the --voxel-size help text to document the fallback order (CLI value → volume metadata voxelsize → default 1.0).
  • Added readVolumeVoxelSize and updated voxel-size resolution in vc_render_tifxyz.cpp to use --voxel-size if present (validated positive), else use metadata when valid, else fall back to 1.0 while emitting a warning/info message.
  • Extended writeZarrAttrs signature and implementation to accept baseVoxelSize and voxelUnit and to emit multiscales.axes[*].unit and per-level coordinateTransformations.scale as physical voxel spacings (files changed: volume-cartographer/apps/src/vc_render_tifxyz.cpp, volume-cartographer/core/include/vc/core/util/Zarr.hpp, volume-cartographer/core/src/Zarr.cpp).
  • Small include cleanup to enable std::optional usage (#include <optional> added).

Testing

  • Attempted a full CMake configure with cmake -S volume-cartographer -B /tmp/vcbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, which failed due to external dependency fetch being blocked by the environment (git clone of xtl returned HTTP 403), so a full build/test could not be completed.
  • Performed automated repository inspections and diffs (git commands and nl/sed checks) to verify option definitions, new readVolumeVoxelSize helper, fallback behavior, and that calls to writeZarrAttrs now pass the computed base_voxel_size * ds_scale and voxel_unit; these checks succeeded.
  • No unit or integration tests were added or run in this change; recommend running a full build and validating produced .zattrs with a small vc_render_tifxyz invocation such as vc_render_tifxyz --pre --zarr-output <out> --volume <vol> --group-idx <g> --voxel-size <value> --voxel-unit <unit> once dependencies are available.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
scrollprize-org Ignored Ignored Preview Feb 21, 2026 7:03am

Request Review

@giorgioangel giorgioangel linked an issue Feb 21, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef75af3ff7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

writeZarrAttrs(outFile, vol_path, group_idx, baseZ, slice_step, accum_step,
accum_type_str, accumOffsets.size(), attrXY, baseZ, CH, CW);
accum_type_str, accumOffsets.size(), attrXY, baseZ, CH, CW,
base_voxel_size * ds_scale, voxel_unit);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Compute output voxel scale using source level spacing

ds_scale is 2^-group_idx (used earlier to map full-resolution coordinates into the chosen downsampled source group), so multiplying base_voxel_size by it inverts the physical spacing: for group_idx > 0, coarser source levels are written with smaller voxel sizes. This makes .zattrs physical metadata wrong by large factors (e.g. group 2 writes 1/4 instead of 4x), which miscalibrates downstream measurement/viewing even when --voxel-size is explicitly provided.

Useful? React with 👍 / 👎.

for (int l = 0; l <= 5; l++) {
double s = std::pow(2.0, l);
const double levelScale = std::pow(2.0, l);
const double physicalScale = baseVoxelSize * levelScale;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep emitted multiscale scales compatible with Volume loader

This now writes arbitrary physical values into coordinateTransformations.scale, but the repo’s reader in core/src/Volume.cpp:188-196 still requires each dataset scale to be an isotropic power-of-two and throws otherwise. As soon as baseVoxelSize is not exactly a power-of-two (the normal case for real voxel units), rendered outputs become unreadable by code paths that reopen Zarr via Volume::zarrOpen (including VC3D volume loading).

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vc_render_tifxyz: support proper scales in ome-zarr metadata

1 participant