diff --git a/iohub/ngff/nodes.py b/iohub/ngff/nodes.py index 311d02e7..efdbd820 100644 --- a/iohub/ngff/nodes.py +++ b/iohub/ngff/nodes.py @@ -310,20 +310,28 @@ def close(self): class ImageArray(zarr.Array): """Container object for image stored as a zarr array (up to 5D)""" - def __init__(self, zarray: zarr.Array): - super().__init__( - store=zarray._store, - path=zarray._path, - read_only=zarray._read_only, - chunk_store=zarray._chunk_store, - synchronizer=zarray._synchronizer, - cache_metadata=zarray._cache_metadata, - cache_attrs=zarray._attrs.cache, - partial_decompress=zarray._partial_decompress, - write_empty_chunks=zarray._write_empty_chunks, - zarr_version=zarray._version, - meta_array=zarray._meta_array, - ) + def __init__(self, zarray: zarr.Array = None, **kwargs): + """Keyword arguments are passed to the zarr.Array constructor. + If a zarr.Array is provided, the constructor will use its attributes + to initialize the ImageArray. + """ + if zarray is not None: + kwargs.update( + { + "store": zarray._store, + "path": zarray._path, + "read_only": zarray._read_only, + "chunk_store": zarray._chunk_store, + "synchronizer": zarray._synchronizer, + "cache_metadata": zarray._cache_metadata, + "cache_attrs": zarray._attrs.cache, + "partial_decompress": zarray._partial_decompress, + "write_empty_chunks": zarray._write_empty_chunks, + "zarr_version": zarray._version, + "meta_array": zarray._meta_array, + } + ) + super().__init__(**kwargs) self._get_dims() def _get_dims(self):