|
4 | 4 |
|
5 | 5 | import zarr |
6 | 6 | from zarr import Group |
7 | | -import numpy as np |
| 7 | +from zarr.core.sync import SyncMixin |
| 8 | +from zarr.core.buffer import default_buffer_prototype |
| 9 | + |
8 | 10 | import dask.array as da |
9 | 11 | from typing import List |
10 | 12 | from vispy.color import Colormap |
| 13 | +from xml.etree import ElementTree as ET |
11 | 14 |
|
12 | | -from typing import Any, Callable, Dict, List, Tuple, Union |
| 15 | +from typing import Any, Dict, List, Tuple, Union |
13 | 16 |
|
14 | 17 | LayerData = Union[Tuple[Any], Tuple[Any, Dict], Tuple[Any, Dict, str]] |
15 | 18 |
|
@@ -133,14 +136,28 @@ def matches(group: Group) -> bool: |
133 | 136 | return "bioformats2raw.layout" in attrs and "plate" not in attrs |
134 | 137 |
|
135 | 138 | def children(self): |
136 | | - # TDOO: lookup children from series of OME/METADATA.xml |
137 | | - childnames = ["0"] |
| 139 | + # lookup children from series of OME/METADATA.xml |
| 140 | + xml_data = SyncMixin()._sync(self.group.store.get("OME/METADATA.ome.xml", prototype=default_buffer_prototype())) |
| 141 | + # print("xml_data", xml_data.to_bytes()) |
| 142 | + root = ET.fromstring(xml_data.to_bytes()) |
138 | 143 | rv = [] |
139 | | - for name in childnames: |
140 | | - g = self.group[name] |
141 | | - if Multiscales.matches(g): |
142 | | - rv.append(Multiscales(g)) |
| 144 | + for child in root: |
| 145 | + # {http://www.openmicroscopy.org/Schemas/OME/2016-06}Image |
| 146 | + print(child.tag) |
| 147 | + node_id = child.attrib.get("ID", "") |
| 148 | + if child.tag.endswith("Image") and node_id.startswith("Image:"): |
| 149 | + print("Image ID", node_id) |
| 150 | + image_path = node_id.replace("Image:", "") |
| 151 | + g = self.group[image_path] |
| 152 | + if Multiscales.matches(g): |
| 153 | + rv.append(Multiscales(g)) |
143 | 154 | return rv |
| 155 | + |
| 156 | + # override to NOT yield self since node has no data |
| 157 | + def iter_nodes(self): |
| 158 | + for child in self.children(): |
| 159 | + for ch in child.iter_nodes(): |
| 160 | + yield ch |
144 | 161 |
|
145 | 162 |
|
146 | 163 | class Plate(Spec): |
|
0 commit comments