Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust calculation of "z-step_um" for ndtiff datasets #263

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions iohub/ndtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,20 @@ def _get_summary_metadata(self):
c_idx = self._ndtiff_channel_names[0]
img_metadata = self.get_image_metadata(p_idx, 0, c_idx, 0)

pm_metadata["z-step_um"] = None
if "ZPosition_um_Intended" in img_metadata.keys():
try:
z0 = self.get_image_metadata(p_idx, 0, c_idx, 0)[
"ZPosition_um_Intended"
]
z1 = self.get_image_metadata(p_idx, 0, c_idx, 1)[
"ZPosition_um_Intended"
]
pm_metadata["z-step_um"] = np.around(
abs(
self.get_image_metadata(p_idx, 0, c_idx, 1)[
"ZPosition_um_Intended"
]
- self.get_image_metadata(p_idx, 0, c_idx, 0)[
"ZPosition_um_Intended"
]
),
decimals=3,
abs(z1 - z0), decimals=3
).astype(float)
# Will raise KeyError if dataset does not have z slices
# Will raise ValueError if dataset has only one z slice
ziw-liu marked this conversation as resolved.
Show resolved Hide resolved
except (KeyError, ValueError):
pm_metadata["z-step_um"] = None

pm_metadata["StagePositions"] = []
if "position" in self._axes:
Expand Down
Loading