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

Add function in datasets to get input paths #367

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions torch_em/data/datasets/light_microscopy/deepbacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get_deepbacs_data(path: Union[os.PathLike, str], bac_type: str, download: bo
return data_folder


def _get_paths(path, bac_type, split):
def _get_deepbacs_paths(path, bac_type, split):
anwai98 marked this conversation as resolved.
Show resolved Hide resolved
# the bacteria types other than mixed are a bit more complicated so we don't have the dataloaders for them yet
# mixed is the combination of all other types
if split == "train":
Expand Down Expand Up @@ -139,7 +139,7 @@ def get_deepbacs_dataset(
"""
assert split in ("train", "val", "test")
get_deepbacs_data(path, bac_type, download)
image_folder, label_folder = _get_paths(path, bac_type, split)
image_folder, label_folder = _get_deepbacs_paths(path, bac_type, split)
dataset = torch_em.default_segmentation_dataset(
image_folder, "*.tif", label_folder, "*.tif", patch_shape=patch_shape, **kwargs
)
Expand Down
7 changes: 6 additions & 1 deletion torch_em/data/datasets/light_microscopy/livecell.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ def _download_livecell_annotations(path, split, download, cell_types, label_path
return _create_segmentations_from_annotations(annotation_file, image_folder, seg_folder, cell_types)


def _get_livecell_paths(path, split, download=False, cell_types=None, label_path=None):
image_paths, seg_paths = _download_livecell_annotations(path, split, download, cell_types, label_path)
return image_paths, seg_paths


def get_livecell_data(
path: Union[os.PathLike, str],
split: str,
Expand All @@ -177,7 +182,7 @@ def get_livecell_data(
The paths to the label data.
"""
_download_livecell_images(path, download)
image_paths, seg_paths = _download_livecell_annotations(path, split, download, cell_types, label_path)
image_paths, seg_paths = _get_livecell_paths(path, split, download, cell_types, label_path)
return image_paths, seg_paths


Expand Down
9 changes: 7 additions & 2 deletions torch_em/data/datasets/light_microscopy/plantseg.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ def get_plantseg_data(path: Union[os.PathLike, str], download: bool, name: str,
return out_path


def _get_plantseg_paths(data_path):
file_paths = glob(os.path.join(data_path, "*.h5"))
file_paths.sort()
return file_paths


def get_plantseg_dataset(
path: Union[os.PathLike, str],
name: str,
Expand Down Expand Up @@ -168,8 +174,7 @@ def get_plantseg_dataset(
assert len(patch_shape) == 3
data_path = get_plantseg_data(path, download, name, split)

file_paths = glob(os.path.join(data_path, "*.h5"))
file_paths.sort()
file_paths = _get_plantseg_paths(data_path)

kwargs, _ = util.add_instance_label_transform(
kwargs, add_binary_target=binary, binary=binary, boundaries=boundaries,
Expand Down