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

Bug in v0.1.5 visium_hd reader #216

Open
t-a-m-i opened this issue Oct 3, 2024 · 2 comments
Open

Bug in v0.1.5 visium_hd reader #216

t-a-m-i opened this issue Oct 3, 2024 · 2 comments

Comments

@t-a-m-i
Copy link

t-a-m-i commented Oct 3, 2024

Hi, I get an error when trying to read in a Visium HD dataset with the visium_hd reader of v0.1.5. The same code works perfectly fine with v0.1.4.

from spatialdata_io import visium_hd
sdata = visium_hd(
    path_read,
    load_all_images=True,
    fullres_image_file=fullres_image_file,
    dataset_id=dataset_id
)

Throws:

FileNotFoundError: [Errno 2] Unable to synchronously open file (unable to open file: name = '/files/03-SpaceRanger-Results/P31904_402/outs/P31904_402_feature_slice.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

"P31904_402_feature_slice.h5" indeed does not exist, it should simply be "feature_slice.h5" in "outs" of the "P31904_402" folder.

Here is the full traceback:

FileNotFoundError Traceback (most recent call last)
Cell In[4], line 2
1 from spatialdata_io import visium_hd
----> 2 sdata = visium_hd(
3 path_read,
4 load_all_images=True,
5 annotate_table_by_labels=True,
6 fullres_image_file=fullres_image_file,
7 dataset_id=dataset_id
8 )

File ~/anaconda3/envs/sd_pr_test/lib/python3.12/site-packages/spatialdata_io/readers/visium_hd.py:115, in visium_hd(path, dataset_id, filtered_counts_file, bin_size, bins_as_squares, annotate_table_by_labels, fullres_image_file, load_all_images, imread_kwargs, image_models_kwargs, anndata_kwargs)
104 def load_image(path: Path, suffix: str, scale_factors: list[int] | None = None) -> None:
105 _load_image(
106 path=path,
107 images=images,
(...)
112 scale_factors=scale_factors,
113 )
--> 115 metadata, hd_layout = _parse_metadata(path, filename_prefix)
116 transform_matrices = _get_transform_matrices(metadata, hd_layout)
117 file_format = hd_layout[VisiumHDKeys.FILE_FORMAT]

File ~/anaconda3/envs/sd_pr_test/lib/python3.12/site-packages/spatialdata_io/readers/visium_hd.py:471, in _parse_metadata(path, filename_prefix)
470 def _parse_metadata(path: Path, filename_prefix: str) -> tuple[dict[str, Any], dict[str, Any]]:
--> 471 with h5py.File(path / f"{filename_prefix}{VisiumHDKeys.FEATURE_SLICE_FILE.value}", "r") as f5:
472 metadata = json.loads(dict(f5.attrs)[VisiumHDKeys.METADATA_JSON])
473 hd_layout = json.loads(metadata[VisiumHDKeys.HD_LAYOUT_JSON])

File ~/anaconda3/envs/sd_pr_test/lib/python3.12/site-packages/h5py/_hl/files.py:562, in File.init(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, fs_strategy, fs_persist, fs_threshold, fs_page_size, page_buf_size, min_meta_keep, min_raw_keep, locking, alignment_threshold, alignment_interval, meta_block_size, **kwds)
553 fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0,
554 locking, page_buf_size, min_meta_keep, min_raw_keep,
555 alignment_threshold=alignment_threshold,
556 alignment_interval=alignment_interval,
557 meta_block_size=meta_block_size,
558 **kwds)
559 fcpl = make_fcpl(track_order=track_order, fs_strategy=fs_strategy,
560 fs_persist=fs_persist, fs_threshold=fs_threshold,
561 fs_page_size=fs_page_size)
--> 562 fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
564 if isinstance(libver, tuple):
565 self._libver = libver

File ~/anaconda3/envs/sd_pr_test/lib/python3.12/site-packages/h5py/_hl/files.py:235, in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
233 if swmr and swmr_support:
234 flags |= h5f.ACC_SWMR_READ
--> 235 fid = h5f.open(name, flags, fapl=fapl)
236 elif mode == 'r+':
237 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()

File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()

File h5py/h5f.pyx:102, in h5py.h5f.open()
@LucaMarconato
Copy link
Member

Thanks for reporting. Tagging @melonora, the bug seems due to #204 and #206.

@LucaMarconato
Copy link
Member

Partly related to #212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants