Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Enable tiling non-PANDA WSI datasets #621

Merged
merged 16 commits into from
Dec 16, 2021
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
Prev Previous commit
Next Next commit
Use PANDA instead of TCGA-PRAD in test
  • Loading branch information
dccastro committed Dec 16, 2021
commit fa5ec34faee8d3b87b28d80bbfae4876345f409b
2 changes: 2 additions & 0 deletions InnerEye/ML/Histopathology/datasets/default_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
# ------------------------------------------------------------------------------------------

PANDA_DATASET_ID = "PANDA"
PANDA_TILES_DATASET_ID = "PANDA_tiles"
TCGA_CRCK_DATASET_ID = "TCGA-CRCk"
TCGA_PRAD_DATASET_ID = "TCGA-PRAD"

DEFAULT_DATASET_LOCATION = "/tmp/datasets/"
PANDA_DATASET_DIR = DEFAULT_DATASET_LOCATION + PANDA_DATASET_ID
PANDA_TILES_DATASET_DIR = DEFAULT_DATASET_LOCATION + PANDA_TILES_DATASET_ID
TCGA_CRCK_DATASET_DIR = DEFAULT_DATASET_LOCATION + TCGA_CRCK_DATASET_ID
TCGA_PRAD_DATASET_DIR = DEFAULT_DATASET_LOCATION + TCGA_PRAD_DATASET_ID
2 changes: 1 addition & 1 deletion InnerEye/ML/Histopathology/datasets/panda_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self,
dataset_df: Optional[pd.DataFrame] = None) -> None:
super().__init__(root, dataset_csv, dataset_df, validate_columns=False)
# PANDA CSV does not come with paths for image and mask files
slide_ids = self.dataset_df[self.SLIDE_ID_COLUMN]
slide_ids = self.dataset_df.index
self.dataset_df[self.IMAGE_COLUMN] = "train_images/" + slide_ids + ".tiff"
self.dataset_df[self.MASK_COLUMN] = "train_label_masks/" + slide_ids + "_mask.tiff"
self.validate_columns()
Expand Down
14 changes: 6 additions & 8 deletions Tests/ML/histopathology/preprocessing/test_slide_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from monai.data.image_reader import WSIReader

from InnerEye.Common.fixed_paths_for_tests import tests_root_directory
from InnerEye.ML.Histopathology.datasets.default_paths import TCGA_PRAD_DATASET_DIR
from InnerEye.ML.Histopathology.datasets.tcga_prad_dataset import TcgaPradDataset
from InnerEye.ML.Histopathology.datasets.default_paths import PANDA_DATASET_DIR
from InnerEye.ML.Histopathology.datasets.panda_dataset import PandaDataset
from InnerEye.ML.Histopathology.preprocessing.tiling import tile_array_2d
from InnerEye.ML.Histopathology.preprocessing.loading import LoadROId, get_luminance, load_slide_at_level, segment_foreground
from InnerEye.ML.Histopathology.utils.naming import SlideKey
Expand All @@ -17,15 +17,13 @@


def _get_sample() -> Dict[SlideKey, Any]:
dataset = TcgaPradDataset(TCGA_PRAD_DATASET_DIR)
dataset = PandaDataset(PANDA_DATASET_DIR)
return dataset[0]


def test_load_slide() -> None:
level = 2
reader = WSIReader('cuCIM')
# image_path = _get_sample()[SlideKey.IMAGE]
# print(image_path)
slide_obj: CuImage = reader.read(TEST_IMAGE_PATH)
dims = slide_obj.resolutions['level_dimensions'][level][::-1]

Expand Down Expand Up @@ -136,9 +134,9 @@ def test_get_bounding_box(level: int, foreground_threshold: Optional[float]) ->
assert level0_bbox_margin.h == level0_bbox.h + 2 * level0_margin


@pytest.mark.skipif(not os.path.isdir(TCGA_PRAD_DATASET_DIR),
reason="TCGA-PRAD dataset is unavailable")
@pytest.mark.parametrize('level', [2, 3])
@pytest.mark.skipif(not os.path.isdir(PANDA_DATASET_DIR),
reason="PANDA dataset is unavailable")
@pytest.mark.parametrize('level', [1, 2])
@pytest.mark.parametrize('margin', [0, 42])
@pytest.mark.parametrize('foreground_threshold', [None, 215])
def test_load_roi(level: int, margin: int, foreground_threshold: Optional[float]) -> None:
Expand Down