From eebb006b4bdf4c22b011214e5c2ffefa4e56a568 Mon Sep 17 00:00:00 2001 From: giovp Date: Sat, 14 Oct 2023 16:51:16 +0200 Subject: [PATCH] change ref to datatree --- .../multiscale_spatial_image.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/multiscale_spatial_image/multiscale_spatial_image.py b/multiscale_spatial_image/multiscale_spatial_image.py index 2e5b7e0..ba40ec9 100644 --- a/multiscale_spatial_image/multiscale_spatial_image.py +++ b/multiscale_spatial_image/multiscale_spatial_image.py @@ -28,7 +28,7 @@ class MultiscaleSpatialImage: """ def __init__(self, xarray_obj: DataTree): - self._obj = xarray_obj + self._dt = xarray_obj def to_zarr( self, @@ -59,11 +59,11 @@ def to_zarr( """ multiscales = [] - scale0 = self._obj[self._obj.groups[1]] + scale0 = self._dt[self._dt.groups[1]] for name in scale0.ds.data_vars.keys(): ngff_datasets = [] - for child in self._obj.children: - image = self._obj[child].ds + for child in self._dt.children: + image = self._dt[child].ds scale_transform = [] translate_transform = [] for dim in image.dims: @@ -84,7 +84,7 @@ def to_zarr( ngff_datasets.append( { - "path": f"{self._obj[child].name}/{name}", + "path": f"{self._dt[child].name}/{name}", "coordinateTransformations": [ { "type": "scale", @@ -122,6 +122,6 @@ def to_zarr( # NGFF v0.4 metadata ngff_metadata = {"multiscales": multiscales, "multiscaleSpatialImageVersion": 1} - self._obj.ds = self._obj.ds.assign_attrs(**ngff_metadata) + self._dt.ds = self._dt.ds.assign_attrs(**ngff_metadata) - self._obj.to_zarr(store, **kwargs) + self._dt.to_zarr(store, **kwargs)