fix: apply missing mm-to-µm conversion factor for PhysicalSizeZ#516
Merged
Alpaca233 merged 1 commit intoCephla-Lab:masterfrom Mar 21, 2026
Conversation
self._physical_size_z_um was assigned self.deltaZ directly, but deltaZ is stored in mm (set via set_deltaZ(um)/1000). This caused OME-TIFF metadata to record PhysicalSizeZ 1000× too small (e.g. 0.0015 µm instead of 1.5 µm). Add * 1000 to convert mm → µm, consistent with the same pattern used elsewhere in the worker (e.g. z_piezo_um += self.deltaZ * 1000). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Z-step metadata unit handling in MultiPointWorker so OME-TIFF (and Zarr) metadata reports PhysicalSizeZ in micrometers rather than millimeters.
Changes:
- Convert
deltaZ(stored in mm) to µm when computingphysical_size_z_umfor acquisition metadata. - Ensure
PhysicalSizeZmetadata uses a positive step size viaabs(deltaZ).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self._pixel_size_um = None | ||
| self._time_increment_s = self.dt if self.Nt > 1 and self.dt > 0 else None | ||
| self._physical_size_z_um = self.deltaZ if self.NZ > 1 else None | ||
| self._physical_size_z_um = abs(self.deltaZ) * 1000 if self.NZ > 1 else None |
There was a problem hiding this comment.
If NZ > 1 but deltaZ is 0 (possible since set_deltaZ() accepts 0), this will set physical_size_z_um / z_step_um to 0.0. A 0 Z step is generally invalid for OME metadata and also results in a 0 scale on the Z axis for OME-Zarr coordinate transforms. Consider guarding against this (e.g., set to None when abs(deltaZ) == 0, or validate earlier and prevent NZ > 1 with deltaZ == 0).
Suggested change
| self._physical_size_z_um = abs(self.deltaZ) * 1000 if self.NZ > 1 else None | |
| self._physical_size_z_um = ( | |
| abs(self.deltaZ) * 1000 if self.NZ > 1 and abs(self.deltaZ) > 0 else None | |
| ) |
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
self._physical_size_z_umwas assignedself.deltaZwithout unit conversion.deltaZis stored in mm (viaset_deltaZ(um) / 1000), so OME-TIFF metadata was recordingPhysicalSizeZ1000× too small (e.g.0.0015 µminstead of1.5 µm).* 1000onmulti_point_worker.pyline 144 to convert mm → µm.self.z_piezo_um += self.deltaZ * 1000.Test plan
dz(um)inacquisition_parameters.jsonmatchesPhysicalSizeZin the OME-XML header of the output TIFF (e.g. set dz = 1.5 µm, confirmPhysicalSizeZ="1.5"in the metadata).🤖 Generated with Claude Code