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 resizing to OSIC PulmoFib dataset #306

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 1 addition & 18 deletions scripts/datasets/medical/check_osic_pulmofib.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,11 @@ def check_osic_pulmofib():
patch_shape=(1, 512, 512),
batch_size=2,
resize_inputs=False,
download=False,
download=True,
)

check_loader(loader, 8)


def visualize_data():
import os
from glob import glob

import nrrd
import napari

all_volume_paths = sorted(glob(os.path.join(ROOT, "nrrd_heart", "*", "*")))
for vol_path in all_volume_paths:
vol, header = nrrd.read(vol_path)

v = napari.Viewer()
v.add_image(vol.transpose(2, 0, 1))
napari.run()


if __name__ == "__main__":
# visualize_data()
check_osic_pulmofib()
6 changes: 6 additions & 0 deletions torch_em/data/datasets/medical/osic_pulmofib.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ def get_osic_pulmofib_dataset(
"""
image_paths, gt_paths = _get_osic_pulmofib_paths(path=path, download=download)

if resize_inputs:
resize_kwargs = {"patch_shape": patch_shape, "is_rgb": False}
kwargs, patch_shape = util.update_kwargs_for_resize_trafo(
kwargs=kwargs, patch_shape=patch_shape, resize_inputs=resize_inputs, resize_kwargs=resize_kwargs
)

dataset = torch_em.default_segmentation_dataset(
raw_paths=image_paths,
raw_key="data",
Expand Down