Skip to content

fix: apply missing mm-to-µm conversion factor for PhysicalSizeZ#516

Merged
Alpaca233 merged 1 commit intoCephla-Lab:masterfrom
maragall:bugfix/missing-PhysicalSizeZ-conversion-factor-mm-to-um
Mar 21, 2026
Merged

fix: apply missing mm-to-µm conversion factor for PhysicalSizeZ#516
Alpaca233 merged 1 commit intoCephla-Lab:masterfrom
maragall:bugfix/missing-PhysicalSizeZ-conversion-factor-mm-to-um

Conversation

@maragall
Copy link
Copy Markdown
Contributor

@maragall maragall commented Mar 18, 2026

Summary

  • self._physical_size_z_um was assigned self.deltaZ without unit conversion. deltaZ is stored in mm (via set_deltaZ(um) / 1000), so OME-TIFF metadata was recording PhysicalSizeZ 1000× too small (e.g. 0.0015 µm instead of 1.5 µm).
  • Added * 1000 on multi_point_worker.py line 144 to convert mm → µm.
  • This is consistent with the same pattern already used in the worker: self.z_piezo_um += self.deltaZ * 1000.

Test plan

  • Run a z-stack acquisition and verify dz(um) in acquisition_parameters.json matches PhysicalSizeZ in the OME-XML header of the output TIFF (e.g. set dz = 1.5 µm, confirm PhysicalSizeZ="1.5" in the metadata).
  • Confirm z-stack movement is unaffected (only metadata was changed).

🤖 Generated with Claude Code

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>
@maragall maragall changed the title fix: missing PhysicalSizeZ conversion factor from mm to µm fix: apply missing mm-to-µm conversion factor for PhysicalSizeZ Mar 18, 2026
@Alpaca233 Alpaca233 requested a review from Copilot March 21, 2026 02:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 computing physical_size_z_um for acquisition metadata.
  • Ensure PhysicalSizeZ metadata uses a positive step size via abs(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
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

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
)

Copilot uses AI. Check for mistakes.
@Alpaca233 Alpaca233 merged commit e7aaef8 into Cephla-Lab:master Mar 21, 2026
6 checks passed
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.

3 participants