Skip to content

Commit

Permalink
use try/except when calculating pm_metadata["z-step_um"]
Browse files Browse the repository at this point in the history
  • Loading branch information
ieivanov committed Dec 6, 2024
1 parent 8a7618f commit 361c8c9
Showing 1 changed file with 12 additions and 11 deletions.
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
except (KeyError, ValueError):
pm_metadata["z-step_um"] = None

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

0 comments on commit 361c8c9

Please sign in to comment.