Skip to content
Snippets Groups Projects
Commit 1e1e2dac authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[tests] Minimal tests for the combined NIH-CXR14 and PadChest database remix

parent 2ce9f658
No related branches found
No related tags found
1 merge request!6Making use of LightningDataModule and simplification of data loading
Pipeline #76828 passed
# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch> # SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
"""Tests for the aggregated NIH CXR14-PadChest dataset.""" """Tests for the aggregated NIH+CXR14-PadChest dataset."""
import importlib
import pytest import pytest
@pytest.mark.skip(reason="Test need to be updated") @pytest.mark.parametrize(
def test_dataset_consistency(): "name,padchest_name,combined_name",
from ptbench.data.nih_cxr14 import default as nih [
from ptbench.data.nih_cxr14_padchest import idiap as nih_pc ("default", "no_tb_idiap", "idiap"),
from ptbench.data.padchest import no_tb_idiap as pc ],
)
def test_split_consistency(name: str, padchest_name: str, combined_name: str):
nih_cxr14 = importlib.import_module(
f".{name}", "ptbench.data.nih_cxr14"
).datamodule
padchest = importlib.import_module(
f".{padchest_name}", "ptbench.data.padchest"
).datamodule
combined = importlib.import_module(
f".{combined_name}", "ptbench.data.nih_cxr14_padchest"
).datamodule
# Default protocol CXR14Loader = importlib.import_module(
nih_pc_dataset = nih_pc.dataset ".datamodule", "ptbench.data.nih_cxr14"
assert isinstance(nih_pc_dataset, dict) ).RawDataLoader
nih_dataset = nih.dataset PadChestLoader = importlib.import_module(
pc_dataset = pc.dataset ".datamodule", "ptbench.data.padchest"
).RawDataLoader
assert "train" in nih_pc_dataset for split in ("train", "validation", "test"):
assert len(nih_pc_dataset["train"]) == len(nih_dataset["train"]) + len( assert nih_cxr14.splits[split][0][0] == combined.splits[split][0][0]
pc_dataset["train"] assert isinstance(nih_cxr14.splits[split][0][1], CXR14Loader)
) assert isinstance(combined.splits[split][0][1], CXR14Loader)
assert "validation" in nih_pc_dataset if split != "test":
assert len(nih_pc_dataset["validation"]) == len( # padchest has no test
nih_dataset["validation"] assert padchest.splits[split][0][0] == combined.splits[split][1][0]
) + len(pc_dataset["validation"]) assert isinstance(padchest.splits[split][0][1], PadChestLoader)
assert isinstance(combined.splits[split][1][1], PadChestLoader)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment