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

Update ISBI dataset download #210

Merged
merged 1 commit into from
Feb 5, 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
14 changes: 10 additions & 4 deletions torch_em/data/datasets/isbi2012.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import torch_em
from . import util

Expand All @@ -14,10 +16,14 @@ def get_isbi_dataset(
This dataset is from the publication https://doi.org/10.3389/fnana.2015.00142.
Please cite it if you use this dataset for a publication.
"""
if not path.endswith(".h5"):
raise ValueError("Isbi path must be a hdf5 file.")
if path.endswith(".h5"):
volume_path = path
else:
os.makedirs(path, exist_ok=True)
volume_path = os.path.join(path, "isbi.h5")

assert len(patch_shape) == 3
util.download_source(path, ISBI_URL, download, CHECKSUM)
util.download_source(volume_path, ISBI_URL, download, CHECKSUM)
ndim = 2 if patch_shape[0] == 1 else 3
kwargs = util.update_kwargs(kwargs, "ndim", ndim)

Expand All @@ -28,7 +34,7 @@ def get_isbi_dataset(
raw_key = "raw"
label_key = "labels/membranes" if use_original_labels else "labels/gt_segmentation"

return torch_em.default_segmentation_dataset(path, raw_key, path, label_key, patch_shape, **kwargs)
return torch_em.default_segmentation_dataset(volume_path, raw_key, volume_path, label_key, patch_shape, **kwargs)


def get_isbi_loader(
Expand Down