Skip to content

Commit a2e9b53

Browse files
committed
better channel indexing in _get_summary_metadata
1 parent 692e2a7 commit a2e9b53

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

iohub/ndtiff.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ def __init__(self, data_path: Path | str):
8282
self.dtype = self.dataset.dtype
8383

8484
self._all_position_keys = self._parse_all_position_keys()
85+
self._ndtiff_channel_names = list(self._axes.get("channel", [None]))
8586
self._mm_meta = self._get_summary_metadata()
86-
self.channel_names = list(self.dataset.get_channel_names())
87-
if not self.channel_names:
87+
self.channel_names = self._ndtiff_channel_names
88+
if not self.channel_names[0]:
8889
self.channel_names = [f"Channel{i}" for i in range(self.channels)]
8990
_logger.warning(
9091
"No channel names found in metadata. Using defaults: "
@@ -127,18 +128,21 @@ def _get_summary_metadata(self):
127128
pm_metadata = self.dataset.summary_metadata
128129
pm_metadata["MicroManagerVersion"] = "pycromanager"
129130
pm_metadata["Positions"] = len(self)
131+
132+
p_idx = self._all_position_keys[0]
133+
c_idx = self._ndtiff_channel_names[0]
130134
img_metadata = self.get_image_metadata(
131-
self._all_position_keys[0], 0, 0, 0
135+
p_idx, 0, c_idx, 0
132136
)
133137

134138
pm_metadata["z-step_um"] = None
135139
if "ZPosition_um_Intended" in img_metadata.keys():
136140
pm_metadata["z-step_um"] = np.around(
137141
abs(
138-
self.get_image_metadata(0, 0, 0, 1)[
142+
self.get_image_metadata(p_idx, 0, c_idx, 1)[
139143
"ZPosition_um_Intended"
140144
]
141-
- self.get_image_metadata(0, 0, 0, 0)[
145+
- self.get_image_metadata(p_idx, 0, c_idx, 0)[
142146
"ZPosition_um_Intended"
143147
]
144148
),
@@ -149,7 +153,7 @@ def _get_summary_metadata(self):
149153
if "position" in self._axes:
150154
for position in self._axes["position"]:
151155
position_metadata = {}
152-
img_metadata = self.get_image_metadata(position, 0, 0, 0)
156+
img_metadata = self.get_image_metadata(position, 0, c_idx, 0)
153157

154158
if img_metadata is not None and all(
155159
key in img_metadata.keys()

0 commit comments

Comments
 (0)