Follow-up from the review of #162 (issue #147, tracking #160). Two pre-existing gaps the new um step makes more visible. Line numbers are from main at 2a88a618.
1. Microscopy volumes use micrometers as world units, the ruler assumes millimeters
Every microscopy volume this package loads keeps its world coordinates in micrometers, on purpose: packages/niivue/src/volume/omeTiff.ts:57-66 documents why (a 0.65 um pixel expressed in mm makes scene extents, clip planes and label sizes badly conditioned), and packages/niivue/src/volume/channelVolumeFile.ts:44-52 writes that spacing straight into the NIfTI header, where the rest of the library reads it as mm. The OME-Zarr and Allen atlas loaders do the same.
chooseRulerSize (packages/niivue/src/view/NVRuler.ts:44) treats fovMM as millimeters and labels the bar in cm, mm or um accordingly. On a micrometer-unit volume a field of view of 5000 world units is 5 mm of tissue, but the ruler reads "5 m" after the cm step or "50 cm" at best. The labels are off by a factor of 1000 exactly on the volumes #147 was about.
Proposal: carry the world unit on the volume (a worldUnit: 'mm' | 'um' field set by the microscopy loaders, default 'mm'), and have buildRuler scale fovMM into mm before choosing a size. The same field is what a coordinate readout or a measurement label (#155) will need, so it is worth landing once rather than special-casing the ruler.
2. The built-in scale ruler never draws over the slide plane
The WSI slide plane is composited only in RENDER tiles (packages/niivue/src/gl/NVViewGL.ts:1175-1182, and the WebGPU twin), while selectRulerTile skips every tile that is not axial, coronal or sagittal (NVRuler.ts:8-13 and :26). So a page that shows a slide registered into volume space in a single RENDER tile gets no scale ruler at all, even though the slide's own pixelSpacingMM (packages/niivue/src/slide/NVSlide.ts:69) is known and the view is a flat plane at a known zoom when the camera faces it.
Proposal: when the only tiles are RENDER tiles and a slide plane is present, let the ruler use the slide plane's screen-space scale (mm per canvas pixel from the plane MVP at the plane's depth) instead of returning null. Out of scope if the consensus is that the slide viewer should draw its own ruler; in that case the limitation should at least be documented on NVSlide.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RxnaB17kqcirGHNyAjPbgG
Follow-up from the review of #162 (issue #147, tracking #160). Two pre-existing gaps the new um step makes more visible. Line numbers are from
mainat2a88a618.1. Microscopy volumes use micrometers as world units, the ruler assumes millimeters
Every microscopy volume this package loads keeps its world coordinates in micrometers, on purpose:
packages/niivue/src/volume/omeTiff.ts:57-66documents why (a 0.65 um pixel expressed in mm makes scene extents, clip planes and label sizes badly conditioned), andpackages/niivue/src/volume/channelVolumeFile.ts:44-52writes that spacing straight into the NIfTI header, where the rest of the library reads it as mm. The OME-Zarr and Allen atlas loaders do the same.chooseRulerSize(packages/niivue/src/view/NVRuler.ts:44) treatsfovMMas millimeters and labels the bar in cm, mm or um accordingly. On a micrometer-unit volume a field of view of 5000 world units is 5 mm of tissue, but the ruler reads "5 m" after the cm step or "50 cm" at best. The labels are off by a factor of 1000 exactly on the volumes #147 was about.Proposal: carry the world unit on the volume (a
worldUnit: 'mm' | 'um'field set by the microscopy loaders, default'mm'), and havebuildRulerscalefovMMinto mm before choosing a size. The same field is what a coordinate readout or a measurement label (#155) will need, so it is worth landing once rather than special-casing the ruler.2. The built-in scale ruler never draws over the slide plane
The WSI slide plane is composited only in RENDER tiles (
packages/niivue/src/gl/NVViewGL.ts:1175-1182, and the WebGPU twin), whileselectRulerTileskips every tile that is not axial, coronal or sagittal (NVRuler.ts:8-13and:26). So a page that shows a slide registered into volume space in a single RENDER tile gets no scale ruler at all, even though the slide's ownpixelSpacingMM(packages/niivue/src/slide/NVSlide.ts:69) is known and the view is a flat plane at a known zoom when the camera faces it.Proposal: when the only tiles are RENDER tiles and a slide plane is present, let the ruler use the slide plane's screen-space scale (mm per canvas pixel from the plane MVP at the plane's depth) instead of returning null. Out of scope if the consensus is that the slide viewer should draw its own ruler; in that case the limitation should at least be documented on
NVSlide.🤖 Generated with Claude Code
https://claude.ai/code/session_01RxnaB17kqcirGHNyAjPbgG