Skip to content

Commit 4e0ce9c

Browse files
committed
fix
1 parent 59cf72a commit 4e0ce9c

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

src/pyXenium/io/partial_xenium_loader.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,40 @@ def _parse_analysis_group(grp) -> Dict[str, Any]:
254254
def _parse_cells_group(grp) -> Dict[str, Any]:
255255
"""Best-effort parser for cells.zarr.zip
256256
Returns a dict to stash under adata.uns["cells"] if available.
257+
Tolerates both Groups and Arrays (some keys like "cell_summary" may be arrays).
257258
"""
258259
out: Dict[str, Any] = {}
260+
261+
def _summarize(node):
262+
try:
263+
# Array-like: has shape/dtype
264+
if hasattr(node, "shape") and hasattr(node, "dtype") and not hasattr(node, "keys"):
265+
return {"type": "array", "shape": tuple(node.shape), "dtype": str(node.dtype)}
266+
# Group-like
267+
keys = []
268+
if hasattr(node, "array_keys"):
269+
keys = sorted(list(node.array_keys()))
270+
elif hasattr(node, "keys"):
271+
keys = sorted(list(node.keys()))
272+
return {"type": "group", "keys": keys}
273+
except Exception as e:
274+
return {"type": "unknown", "error": str(e)}
275+
259276
try:
260-
# Common subgroups observed in Xenium bundles
277+
# Common subgroups/arrays observed in Xenium bundles
261278
for k in ("cell_summary", "masks", "polygon_sets", "polygons", "cells"):
262279
if k in grp:
263-
gk = grp[k]
264-
# Just expose available array keys to help debugging downstream
265-
keys = sorted(list(gk.array_keys()) if hasattr(gk, "array_keys") else list(gk.keys()))
266-
out[k] = {"keys": keys}
280+
out[k] = _summarize(grp[k])
281+
# Also provide a shallow directory of top-level entries for debugging
282+
try:
283+
top_keys = []
284+
if hasattr(grp, "array_keys"):
285+
top_keys = sorted(list(grp.array_keys()))
286+
elif hasattr(grp, "keys"):
287+
top_keys = sorted(list(grp.keys()))
288+
out["__top_level__"] = top_keys
289+
except Exception:
290+
pass
267291
except Exception as e:
268292
_warn(f"Failed to parse cells.zarr.zip: {e}")
269293
return out

0 commit comments

Comments
 (0)