Skip to content
Snippets Groups Projects
Commit 727dfa94 authored by ogueler@idiap.ch's avatar ogueler@idiap.ch
Browse files

added tests for all tbx11k configs

parent 78010d30
No related branches found
No related tags found
2 merge requests!5Tbx11k,!4Moved code to lightning
......@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""Tests for TBX11K simplified dataset."""
"""Tests for TBX11K simplified dataset split 1."""
import pytest
......
# # SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
# #
# # SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
#
# SPDX-License-Identifier: GPL-3.0-or-later
# """Tests for Extended TBX11K simplified dataset."""
"""Tests for Extended TBX11K simplified dataset split 1."""
# import pytest
import pytest
# def test_protocol_consistency():
# from ptbench.data.tbx11k_simplified_RS import dataset
def test_protocol_consistency():
from ptbench.data.tbx11k_simplified_RS import dataset
# # Default protocol
# subset = dataset.subsets("default")
# assert len(subset) == 3
# Default protocol
subset = dataset.subsets("default")
assert len(subset) == 3
# assert "train" in subset
# assert len(subset["train"]) == 2767
assert "train" in subset
assert len(subset["train"]) == 2767
# assert "validation" in subset
# assert len(subset["validation"]) == 706
assert "validation" in subset
assert len(subset["validation"]) == 706
# assert "test" in subset
# assert len(subset["test"]) == 957
# for s in subset["test"]:
# assert s.key.startswith("images/")
assert "test" in subset
assert len(subset["test"]) == 957
for s in subset["test"]:
assert s.key.startswith("images/")
# # Check labels
# for s in subset["train"]:
# assert s.label in [0.0, 1.0]
# Check labels
for s in subset["train"]:
assert s.label in [0.0, 1.0]
# for s in subset["validation"]:
# assert s.label in [0.0, 1.0]
for s in subset["validation"]:
assert s.label in [0.0, 1.0]
# for s in subset["test"]:
# assert s.label in [0.0, 1.0]
for s in subset["test"]:
assert s.label in [0.0, 1.0]
# # Cross-validation fold 0-9
# for f in range(10):
# subset = dataset.subsets("fold_" + str(f))
# assert len(subset) == 3
# Cross-validation fold 0-9
for f in range(10):
subset = dataset.subsets("fold_" + str(f))
assert len(subset) == 3
# assert "train" in subset
# assert len(subset["train"]) == 3177
# for s in subset["train"]:
# assert s.key.startswith("images/")
assert "train" in subset
assert len(subset["train"]) == 3177
for s in subset["train"]:
assert s.key.startswith("images/")
# assert "validation" in subset
# assert len(subset["validation"]) == 810
# for s in subset["validation"]:
# assert s.key.startswith("images/")
assert "validation" in subset
assert len(subset["validation"]) == 810
for s in subset["validation"]:
assert s.key.startswith("images/")
# assert "test" in subset
# assert len(subset["test"]) == 443
# for s in subset["test"]:
# assert s.key.startswith("images/")
assert "test" in subset
assert len(subset["test"]) == 443
for s in subset["test"]:
assert s.key.startswith("images/")
# # Check labels
# for s in subset["train"]:
# assert s.label in [0.0, 1.0]
# Check labels
for s in subset["train"]:
assert s.label in [0.0, 1.0]
# for s in subset["validation"]:
# assert s.label in [0.0, 1.0]
for s in subset["validation"]:
assert s.label in [0.0, 1.0]
# for s in subset["test"]:
# assert s.label in [0.0, 1.0]
for s in subset["test"]:
assert s.label in [0.0, 1.0]
# @pytest.mark.skip_if_rc_var_not_set("datadir.tbx11k_simplified")
# def test_loading():
# from ptbench.data.tbx11k_simplified_RS import dataset
@pytest.mark.skip_if_rc_var_not_set("datadir.tbx11k_simplified")
def test_loading():
from ptbench.data.tbx11k_simplified_RS import dataset
# def _check_sample(s):
# data = s.data
# assert isinstance(data, dict)
# assert len(data) == 2
def _check_sample(s):
data = s.data
assert isinstance(data, dict)
assert len(data) == 2
# assert "data" in data
# assert len(data["data"]) == 14 # Check radiological signs
assert "data" in data
assert len(data["data"]) == 14 # Check radiological signs
# assert "label" in data
# assert data["label"] in [0, 1] # Check labels
assert "label" in data
assert data["label"] in [0, 1] # Check labels
# limit = 30 # use this to limit testing to first images only, else None
limit = 30 # use this to limit testing to first images only, else None
# subset = dataset.subsets("default")
# for s in subset["train"][:limit]:
# _check_sample(s)
subset = dataset.subsets("default")
for s in subset["train"][:limit]:
_check_sample(s)
......@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""Tests for TBX11K simplified dataset."""
"""Tests for TBX11K simplified dataset split 2."""
import pytest
......
# # SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
# #
# # SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
#
# SPDX-License-Identifier: GPL-3.0-or-later
# """Tests for Extended TBX11K simplified dataset."""
"""Tests for Extended TBX11K simplified dataset split 2."""
# import pytest
import pytest
# def test_protocol_consistency():
# from ptbench.data.tbx11k_simplified_v2_RS import dataset
def test_protocol_consistency():
from ptbench.data.tbx11k_simplified_v2_RS import dataset
# # Default protocol
# subset = dataset.subsets("default")
# assert len(subset) == 3
# Default protocol
subset = dataset.subsets("default")
assert len(subset) == 3
# assert "train" in subset
# assert len(subset["train"]) == 5241
assert "train" in subset
assert len(subset["train"]) == 5241
# assert "validation" in subset
# assert len(subset["validation"]) == 1335
assert "validation" in subset
assert len(subset["validation"]) == 1335
# assert "test" in subset
# assert len(subset["test"]) == 1793
# for s in subset["test"]:
# assert s.key.startswith("images/")
assert "test" in subset
assert len(subset["test"]) == 1793
for s in subset["test"]:
assert s.key.startswith("images/")
# # Check labels
# for s in subset["train"]:
# assert s.label in [0.0, 1.0]
# Check labels
for s in subset["train"]:
assert s.label in [0.0, 1.0]
# for s in subset["validation"]:
# assert s.label in [0.0, 1.0]
for s in subset["validation"]:
assert s.label in [0.0, 1.0]
# for s in subset["test"]:
# assert s.label in [0.0, 1.0]
for s in subset["test"]:
assert s.label in [0.0, 1.0]
# # Cross-validation fold 0-8
# for f in range(9):
# subset = dataset.subsets("fold_" + str(f))
# assert len(subset) == 3
# Cross-validation fold 0-8
for f in range(9):
subset = dataset.subsets("fold_" + str(f))
assert len(subset) == 3
# assert "train" in subset
# assert len(subset["train"]) == 6003
# for s in subset["train"]:
# assert s.key.startswith("images/")
assert "train" in subset
assert len(subset["train"]) == 6003
for s in subset["train"]:
assert s.key.startswith("images/")
# assert "validation" in subset
# assert len(subset["validation"]) == 1529
# for s in subset["validation"]:
# assert s.key.startswith("images/")
assert "validation" in subset
assert len(subset["validation"]) == 1529
for s in subset["validation"]:
assert s.key.startswith("images/")
# assert "test" in subset
# assert len(subset["test"]) == 837
# for s in subset["test"]:
# assert s.key.startswith("images/")
assert "test" in subset
assert len(subset["test"]) == 837
for s in subset["test"]:
assert s.key.startswith("images/")
# # Check labels
# for s in subset["train"]:
# assert s.label in [0.0, 1.0]
# Check labels
for s in subset["train"]:
assert s.label in [0.0, 1.0]
# for s in subset["validation"]:
# assert s.label in [0.0, 1.0]
for s in subset["validation"]:
assert s.label in [0.0, 1.0]
# for s in subset["test"]:
# assert s.label in [0.0, 1.0]
for s in subset["test"]:
assert s.label in [0.0, 1.0]
# # Cross-validation fold 9
# subset = dataset.subsets("fold_9")
# assert len(subset) == 3
# Cross-validation fold 9
subset = dataset.subsets("fold_9")
assert len(subset) == 3
# assert "train" in subset
# assert len(subset["train"]) == 6003
# for s in subset["train"]:
# assert s.key.startswith("images/")
assert "train" in subset
assert len(subset["train"]) == 6003
for s in subset["train"]:
assert s.key.startswith("images/")
# assert "validation" in subset
# assert len(subset["validation"]) == 1530
# for s in subset["validation"]:
# assert s.key.startswith("images/")
assert "validation" in subset
assert len(subset["validation"]) == 1530
for s in subset["validation"]:
assert s.key.startswith("images/")
# assert "test" in subset
# assert len(subset["test"]) == 836
# for s in subset["test"]:
# assert s.key.startswith("images/")
assert "test" in subset
assert len(subset["test"]) == 836
for s in subset["test"]:
assert s.key.startswith("images/")
# # Check labels
# for s in subset["train"]:
# assert s.label in [0.0, 1.0]
# Check labels
for s in subset["train"]:
assert s.label in [0.0, 1.0]
# for s in subset["validation"]:
# assert s.label in [0.0, 1.0]
for s in subset["validation"]:
assert s.label in [0.0, 1.0]
# for s in subset["test"]:
# assert s.label in [0.0, 1.0]
for s in subset["test"]:
assert s.label in [0.0, 1.0]
# @pytest.mark.skip_if_rc_var_not_set("datadir.tbx11k_simplified")
# def test_loading():
# from ptbench.data.tbx11k_simplified_v2_RS import dataset
@pytest.mark.skip_if_rc_var_not_set("datadir.tbx11k_simplified")
def test_loading():
from ptbench.data.tbx11k_simplified_v2_RS import dataset
# def _check_sample(s):
# data = s.data
# assert isinstance(data, dict)
# assert len(data) == 2
def _check_sample(s):
data = s.data
assert isinstance(data, dict)
assert len(data) == 2
# assert "data" in data
# assert len(data["data"]) == 14 # Check radiological signs
assert "data" in data
assert len(data["data"]) == 14 # Check radiological signs
# assert "label" in data
# assert data["label"] in [0, 1] # Check labels
assert "label" in data
assert data["label"] in [0, 1] # Check labels
# limit = 30 # use this to limit testing to first images only, else None
limit = 30 # use this to limit testing to first images only, else None
# subset = dataset.subsets("default")
# for s in subset["train"][:limit]:
# _check_sample(s)
subset = dataset.subsets("default")
for s in subset["train"][:limit]:
_check_sample(s)
......@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""Tests for TBX11K simplified dataset."""
"""Tests for TBX11K simplified dataset split 3."""
import pytest
......
# # SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
# #
# # SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
#
# SPDX-License-Identifier: GPL-3.0-or-later
# """Tests for Extended TBX11K simplified dataset."""
"""Tests for Extended TBX11K simplified dataset split 3."""
# import pytest
import pytest
# def test_protocol_consistency():
# from ptbench.data.tbx11k_simplified_v3_RS import dataset
def test_protocol_consistency():
from ptbench.data.tbx11k_simplified_v3_RS import dataset
# # Default protocol
# subset = dataset.subsets("default")
# assert len(subset) == 3
# Default protocol
subset = dataset.subsets("default")
assert len(subset) == 3
# assert "train" in subset
# assert len(subset["train"]) == 5241
assert "train" in subset
assert len(subset["train"]) == 5241
# assert "validation" in subset
# assert len(subset["validation"]) == 1335
assert "validation" in subset
assert len(subset["validation"]) == 1335
# assert "test" in subset
# assert len(subset["test"]) == 1793
# for s in subset["test"]:
# assert s.key.startswith("images/")
assert "test" in subset
assert len(subset["test"]) == 1793
for s in subset["test"]:
assert s.key.startswith("images/")
# # Check labels
# for s in subset["train"]:
# assert s.label in [0.0, 1.0, 2.0, 3.0]
# Check labels
for s in subset["train"]:
assert s.label in [0.0, 1.0, 2.0, 3.0]
# for s in subset["validation"]:
# assert s.label in [0.0, 1.0, 2.0, 3.0]
for s in subset["validation"]:
assert s.label in [0.0, 1.0, 2.0, 3.0]
# for s in subset["test"]:
# assert s.label in [0.0, 1.0, 2.0, 3.0]
for s in subset["test"]:
assert s.label in [0.0, 1.0, 2.0, 3.0]
# # Cross-validation fold 0-8
# for f in range(9):
# subset = dataset.subsets("fold_" + str(f))
# assert len(subset) == 3
# Cross-validation fold 0-8
for f in range(9):
subset = dataset.subsets("fold_" + str(f))
assert len(subset) == 3
# assert "train" in subset
# assert len(subset["train"]) == 6003
# for s in subset["train"]:
# assert s.key.startswith("images/")
assert "train" in subset
assert len(subset["train"]) == 6003
for s in subset["train"]:
assert s.key.startswith("images/")
# assert "validation" in subset
# assert len(subset["validation"]) == 1529
# for s in subset["validation"]:
# assert s.key.startswith("images/")
assert "validation" in subset
assert len(subset["validation"]) == 1529
for s in subset["validation"]:
assert s.key.startswith("images/")
# assert "test" in subset
# assert len(subset["test"]) == 837
# for s in subset["test"]:
# assert s.key.startswith("images/")
assert "test" in subset
assert len(subset["test"]) == 837
for s in subset["test"]:
assert s.key.startswith("images/")
# # Check labels
# for s in subset["train"]:
# assert s.label in [0.0, 1.0, 2.0, 3.0]
# Check labels
for s in subset["train"]:
assert s.label in [0.0, 1.0, 2.0, 3.0]
# for s in subset["validation"]:
# assert s.label in [0.0, 1.0, 2.0, 3.0]
for s in subset["validation"]:
assert s.label in [0.0, 1.0, 2.0, 3.0]
# for s in subset["test"]:
# assert s.label in [0.0, 1.0, 2.0, 3.0]
for s in subset["test"]:
assert s.label in [0.0, 1.0, 2.0, 3.0]
# # Cross-validation fold 9
# subset = dataset.subsets("fold_9")
# assert len(subset) == 3
# Cross-validation fold 9
subset = dataset.subsets("fold_9")
assert len(subset) == 3
# assert "train" in subset
# assert len(subset["train"]) == 6003
# for s in subset["train"]:
# assert s.key.startswith("images/")
assert "train" in subset
assert len(subset["train"]) == 6003
for s in subset["train"]:
assert s.key.startswith("images/")
# assert "validation" in subset
# assert len(subset["validation"]) == 1530
# for s in subset["validation"]:
# assert s.key.startswith("images/")
assert "validation" in subset
assert len(subset["validation"]) == 1530
for s in subset["validation"]:
assert s.key.startswith("images/")
# assert "test" in subset
# assert len(subset["test"]) == 836
# for s in subset["test"]:
# assert s.key.startswith("images/")
assert "test" in subset
assert len(subset["test"]) == 836
for s in subset["test"]:
assert s.key.startswith("images/")
# # Check labels
# for s in subset["train"]:
# assert s.label in [0.0, 1.0, 2.0, 3.0]
# Check labels
for s in subset["train"]:
assert s.label in [0.0, 1.0, 2.0, 3.0]
# for s in subset["validation"]:
# assert s.label in [0.0, 1.0, 2.0, 3.0]
for s in subset["validation"]:
assert s.label in [0.0, 1.0, 2.0, 3.0]
# for s in subset["test"]:
# assert s.label in [0.0, 1.0, 2.0, 3.0]
for s in subset["test"]:
assert s.label in [0.0, 1.0, 2.0, 3.0]
# @pytest.mark.skip_if_rc_var_not_set("datadir.tbx11k_simplified")
# def test_loading():
# from ptbench.data.tbx11k_simplified_v3_RS import dataset
@pytest.mark.skip_if_rc_var_not_set("datadir.tbx11k_simplified")
def test_loading():
from ptbench.data.tbx11k_simplified_v3_RS import dataset
# def _check_sample(s):
# data = s.data
# assert isinstance(data, dict)
# assert len(data) == 2
def _check_sample(s):
data = s.data
assert isinstance(data, dict)
assert len(data) == 2
# assert "data" in data
# assert len(data["data"]) == 14 # Check radiological signs
assert "data" in data
assert len(data["data"]) == 14 # Check radiological signs
# assert "label" in data
# assert data["label"] in [0, 1, 2, 3] # Check labels
assert "label" in data
assert data["label"] in [0, 1, 2, 3] # Check labels
# limit = 30 # use this to limit testing to first images only, else None
limit = 30 # use this to limit testing to first images only, else None
# subset = dataset.subsets("default")
# for s in subset["train"][:limit]:
# _check_sample(s)
subset = dataset.subsets("default")
for s in subset["train"][:limit]:
_check_sample(s)
This diff is collapsed.
This diff is collapsed.
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