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

AttributeError: 'Dataset' object has no attribute 'store'; open_ds #9

Open
Mohinta2892 opened this issue May 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Mohinta2892
Copy link
Collaborator

Mohinta2892 commented May 3, 2024

Hello!

When trying to load hdf via open_ds it throws AttributeError: 'Dataset' object has no attribute 'store' in _read_attrs(ds, order) (line 288) under datasets.py.

It's checking for a zarr object, when loading a hdf file.

Full Error traceback:


In [2]: f = open_ds("/Users/sam/Documents/random_codebases/ssTEM_data_Acardona/Seg2Link/data/cremi/hdf/sample_A_20160501.hdf")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 f = open_ds("/Users/sam/Documents/random_codebases/ssTEM_data_Acardona/Seg2Link/data/cremi/hdf/sample_A_20160501.hdf")

TypeError: open_ds() missing 1 required positional argument: 'ds_name'

In [3]: f = open_ds("/Users/sam/Documents/random_codebases/ssTEM_data_Acardona/Seg2Link/data/cremi/hdf/sample_A_20160501.hdf", "volumes/raw")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 f = open_ds("/Users/sam/Documents/random_codebases/ssTEM_data_Acardona/Seg2Link/data/cremi/hdf/sample_A_20160501.hdf", "volumes/raw")

File ~/opt/anaconda3/envs/nglance/lib/python3.10/site-packages/funlib/persistence/arrays/datasets.py:446, in open_ds(filename, ds_name, mode)
    443 logger.debug("opening H5 dataset %s in %s", ds_name, filename)
    444 ds = h5py.File(filename, mode=mode)[ds_name]
--> 446 voxel_size, offset = _read_voxel_size_offset(ds, "C")
    447 shape = Coordinate(ds.shape[-len(voxel_size) :])
    448 roi = Roi(offset, voxel_size * shape)

File ~/opt/anaconda3/envs/nglance/lib/python3.10/site-packages/funlib/persistence/arrays/datasets.py:378, in _read_voxel_size_offset(ds, order)
    376 def _read_voxel_size_offset(ds, order="C"):
--> 378     voxel_size, offset, units = _read_attrs(ds, order)
    380     return regularize_offset(voxel_size, offset)

File ~/opt/anaconda3/envs/nglance/lib/python3.10/site-packages/funlib/persistence/arrays/datasets.py:288, in _read_attrs(ds, order)
    284 multiscales = None
    286 if  not isinstance(ds, zarr.core.Array):
    287     raise TypeError(
--> 288         f"{os.path.join(ds.store.path, ds.path)} is not zarr.core.Array"
    289     )
    290 # check recursively for multiscales attribute in the zarr store tree
    291 multiscales, multiscale_group = check_for_multiscale(group=access_parent(ds))

AttributeError: 'Dataset' object has no attribute 'store'

Best,
Samia

@Mohinta2892 Mohinta2892 added the bug Something isn't working label May 3, 2024
@mzouink
Copy link
Contributor

mzouink commented Nov 21, 2024

(perhaps this is a very late answer)

to read hdf file you need to specify the store:

try:

import h5py
from funlib.persistence import open_ds
source = h5py.File("/Users/sam/Documents/random_codebases/ssTEM_data_Acardona/Seg2Link/data/cremi/hdf/sample_A_20160501.hdf", mode='r')
f = open_ds(source)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants