Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added checking for legacy attributes in zarr metadata #3

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions funlib/persistence/arrays/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,28 +251,29 @@ def _read_attrs(ds, order="C"):
# check recursively for multiscales attribute in the zarr store tree
multiscales, multiscale_group = check_for_multiscale(group = access_parent(ds))

# check N5 store
if isinstance(ds.store, (zarr.n5.N5Store, zarr.n5.N5FSStore)):
if multiscales:
voxel_size, offset, units = check_for_attrs_multiscale(ds, multiscale_group, multiscales)
# if multiscale attribute is missing
if voxel_size == None or offset == None:
voxel_size = check_for_voxel_size(ds, order)
offset = check_for_offset(ds, order)
units = check_for_units(ds, order)
else:
return voxel_size, offset, units
# check zarr store
else:
#check for attributes in zarr group multiscale
if multiscales:
voxel_size, offset, units = check_for_attrs_multiscale(ds, multiscale_group, multiscales)
if voxel_size != None and offset != None:
return voxel_size, offset, units
else:
raise ValueError(f"Although multiscale exists within n5 container, no attributes were found.")
else:
raise ValueError(f"No multiscales attribute was found")

#check for attributes in zarr group multiscale
if multiscales:
voxel_size, offset, units = check_for_attrs_multiscale(ds, multiscale_group, multiscales)

# if multiscale attribute is missing
if voxel_size == None:
voxel_size = check_for_voxel_size(ds, order)
if offset == None:
offset = check_for_offset(ds, order)
if units == None:
units = check_for_units(ds, order)

if voxel_size != None and offset != None and units != None:
return voxel_size, offset, units
elif voxel_size == None:
raise ValueError(f"No voxel_size attribute was found")
elif offset == None:
raise ValueError(f"No offset attribute was found")
elif units == None:
raise ValueError(f"No units attribute was found")


return voxel_size, offset, units

def regularize_offset(voxel_size_float, offset_float):
Expand Down