From 451950dd5063e5bb7afd9c767ca7dfbc02df413e Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Mon, 24 Jun 2024 10:50:02 +0200 Subject: [PATCH] Revamp tests; Delete outdated; Make common conftest.py; Improve segmentation tests; Allow segmentation tests to run on CI --- .gitmodules | 0 pyproject.toml | 2 +- tests/classification/data/lfs/.gitattributes | 6 - tests/classification/data/lfs/.gitignore | 1 - tests/classification/data/lfs/README.md | 14 - .../data/lfs/models/logreg.ckpt | Bin 3211 -> 0 bytes .../data/lfs/models/signstotb.ckpt | Bin 6363 -> 0 bytes ...test_cli_classification.py => test_cli.py} | 0 tests/classification/test_hivtb.py | 1 + tests/classification/test_indian.py | 1 + tests/classification/test_montgomery.py | 1 + tests/classification/test_nih_cxr14.py | 1 + tests/classification/test_padchest.py | 1 + tests/classification/test_shenzhen.py | 1 + tests/classification/test_tbpoc.py | 1 + tests/common/__init__.py | 0 tests/common/conftest.py | 26 -- tests/common/data/iris-test.csv | 75 ------ tests/common/data/iris-train.csv | 75 ------ tests/{classification => }/conftest.py | 39 ++- tests/{common => }/data/16bits.png | Bin tests/{common => }/data/iris.json | 0 tests/{classification => }/data/mednet.toml | 14 +- .../data/raw_with_black_border.png | Bin .../data/raw_with_elastic_deformation.png | Bin .../data/raw_without_black_border.png | Bin .../data/raw_without_elastic_deformation.png | Bin tests/segmentation/conftest.py | 253 ------------------ tests/segmentation/test_chasedb1.py | 7 +- .../{test_cli_segmentation.py => test_cli.py} | 0 tests/segmentation/test_cxr8.py | 5 +- tests/segmentation/test_drhagis.py | 7 +- tests/segmentation/test_drionsdb.py | 7 +- tests/segmentation/test_drishtigs1.py | 13 +- tests/segmentation/test_drive.py | 7 +- tests/segmentation/test_hrf.py | 7 +- tests/segmentation/test_iostar.py | 7 +- tests/segmentation/test_jsrt.py | 7 +- tests/segmentation/test_montgomery.py | 6 +- tests/segmentation/test_refuge.py | 7 +- tests/segmentation/test_rimoner3.py | 10 +- tests/segmentation/test_shenzhen.py | 7 +- tests/segmentation/test_stare.py | 7 +- tests/{common => }/test_database_split.py | 0 tests/{common => }/test_image_utils.py | 0 tests/{common => }/test_resource_monitor.py | 0 tests/{common => }/test_transforms.py | 0 47 files changed, 135 insertions(+), 481 deletions(-) delete mode 100644 .gitmodules delete mode 100644 tests/classification/data/lfs/.gitattributes delete mode 100644 tests/classification/data/lfs/.gitignore delete mode 100644 tests/classification/data/lfs/README.md delete mode 100644 tests/classification/data/lfs/models/logreg.ckpt delete mode 100644 tests/classification/data/lfs/models/signstotb.ckpt rename tests/classification/{test_cli_classification.py => test_cli.py} (100%) delete mode 100644 tests/common/__init__.py delete mode 100644 tests/common/conftest.py delete mode 100644 tests/common/data/iris-test.csv delete mode 100644 tests/common/data/iris-train.csv rename tests/{classification => }/conftest.py (86%) rename tests/{common => }/data/16bits.png (100%) rename tests/{common => }/data/iris.json (100%) rename tests/{classification => }/data/mednet.toml (50%) rename tests/{common => }/data/raw_with_black_border.png (100%) rename tests/{common => }/data/raw_with_elastic_deformation.png (100%) rename tests/{common => }/data/raw_without_black_border.png (100%) rename tests/{common => }/data/raw_without_elastic_deformation.png (100%) delete mode 100644 tests/segmentation/conftest.py rename tests/segmentation/{test_cli_segmentation.py => test_cli.py} (100%) rename tests/{common => }/test_database_split.py (100%) rename tests/{common => }/test_image_utils.py (100%) rename tests/{common => }/test_resource_monitor.py (100%) rename tests/{common => }/test_transforms.py (100%) diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29b..00000000 diff --git a/pyproject.toml b/pyproject.toml index 95f54b8d..34b75b6a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -151,7 +151,7 @@ test = "pytest -sv tests/" test-slow = { cmd = "pytest -sv tests/", env = { PYTEST_ADDOPTS = "-m slow" } } test-fast = { cmd = "pytest -sv tests/", env = { PYTEST_ADDOPTS = "-m '(not slow)'" } } test-cov = "pytest -sv --cov-report 'html:html/coverage' tests/" -test-ci = "cp tests/classification/data/mednet.toml $XDG_CONFIG_HOME && pytest -sv --cov-report 'html:html/coverage' --cov-report 'xml:coverage.xml' --junitxml 'junit-coverage.xml' --ignore '.profile' tests/" +test-ci = "cp tests/data/mednet.toml $XDG_CONFIG_HOME && pytest -sv --cov-report 'html:html/coverage' --cov-report 'xml:coverage.xml' --junitxml 'junit-coverage.xml' --ignore '.profile' tests/" [tool.pixi.feature.build.dependencies] hatch = "*" diff --git a/tests/classification/data/lfs/.gitattributes b/tests/classification/data/lfs/.gitattributes deleted file mode 100644 index ebbbf5f9..00000000 --- a/tests/classification/data/lfs/.gitattributes +++ /dev/null @@ -1,6 +0,0 @@ -_test_densenetrs_checkpoint.pth filter=lfs diff=lfs merge=lfs -text -_test_fpasa_checkpoint.pth filter=lfs diff=lfs merge=lfs -text -_test_logreg_checkpoint.pth filter=lfs diff=lfs merge=lfs -text -_test_signstotb_checkpoint.pth filter=lfs diff=lfs merge=lfs -text -_testdb.zip filter=lfs diff=lfs merge=lfs -text -pasa.pth filter=lfs diff=lfs merge=lfs -text diff --git a/tests/classification/data/lfs/.gitignore b/tests/classification/data/lfs/.gitignore deleted file mode 100644 index b25c15b8..00000000 --- a/tests/classification/data/lfs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*~ diff --git a/tests/classification/data/lfs/README.md b/tests/classification/data/lfs/README.md deleted file mode 100644 index bc66bf5e..00000000 --- a/tests/classification/data/lfs/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Assets for Testing biosignal/software/mednet> - -This package contains test unit assets used by the test suit of -biosignal/software/mednet>. - - -## Updating - -To update the contents of this package, use [git-lfs](https://git-lfs.com), -following the workflow described at the [GitLab support -page](https://docs.gitlab.com/ee/topics/git/lfs/). - -Cloning and updating the repository, in particular, works the same as before -and should not impose any workflow changes. diff --git a/tests/classification/data/lfs/models/logreg.ckpt b/tests/classification/data/lfs/models/logreg.ckpt deleted file mode 100644 index b8609b572753ff637cac6edb39d643ec683abebb..0000000000000000000000000000000000000000 GIT binary patch literal 0 H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QGw6HUPG3}!hsYs4NVQNUb9Wqgbh+k)YJ`<s=8W0U?!n2#hFG~ zfG7xMa@<Emw<^hHU_UbjnG}`ECZz0MF{MH}51FxD&lY!GCE^mZvaYczQZ`7mLnrTu zuGu6y!$20Sx;sYK)?L{=&~ppP8(*=1Jwu(8y}}vV>WPGHg%kAZ@Oz_A4__L6`Ot5n z**BkG>EMP!4WHf&)edg#j&^@C`kD9l(7qMT-M7!wcYkr@-B9n&x^C;U*FrdkQ@0k% z%g_q(b*~s~m16Kl!Zj!cG2!?av#$O<%Y~~IU-x1KE3w)lVSn+DF!pEoe|J$DB5Ro_ zgmYE<Z?E2e^NnHRfBmI(%d7U^QN91n&qE{If0)&EWcsd=;1>V+sqgqlVv+br?~5Ot zZ$9{8*Ix(W+?(^C4E}g}(a0~}Z$3IX<J;lwxfhn<oIP=Y-BES^eMbH}wR1u1t<k{s z3%i1oeAk1gI^Pd`J{JPl_Iww#pIs2V-2aMi-eq^!zD+{`>uYayy*+ryx9yL)0qj5b zOz?2k{{4pkGt(w4$E;0*_TyFWe`odkf4eb3{I7eX|Mma&-$(_@^j|mwBVk{41<-EC ztG{wOwH5yc@P&RK_*U%6N>7?5{J}ITcWC8|(vt#rDtAT?>fG*Tw0g=3rRRg0aIrGM zTTUpga5KS)8jT7uw3QP|Yt&3QQJK(QPAIJyGr@_P%L*}cloLudZzf!<Oz@QxN|kOV ztVLaTg&6$hgi@`V2`4HOI?D;AdTYER2K3}aZK64bg2H38&9<a4b&hpu(Fk{Bc#Pdo l67f>hOSs=e1KHueooc}i5E{5akJ00CZ;5Q|6rOL){Rdx2AL9T3 diff --git a/tests/classification/data/lfs/models/signstotb.ckpt b/tests/classification/data/lfs/models/signstotb.ckpt deleted file mode 100644 index 59ea4595166b871e031c9664c1e0581081f3412e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6363 zcmbW63se(V8i2zaBBGRsN_~KV5=0?{kjzX-MnUiql*hsvu^J-@BpOI=G6BT~q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W0BqNeFoM658wIysI4yNo7qJ|T!cdvf`Gk|z{_8P(n zBdj-|wurUFp{PA0Mp$9J&$LB6dkum;+!5=oqAenw_^`HTMf7ll^-j(<npf>3Mi^ne zU$Z5wCC+8+7%{>I>m8RZ;i`QCXSf&EdnQ{#`dGU*#0)1`uVl7_tM&=p;RNfs$d<5y zIG(W+2Vw@Zt*;WRS;dw>BTjAX5TM}%>v_SJu+}~S9!{{Xf7_ILHi9rXo1}<bU1tuK z(Nw2dLj^@1N|Ei=J(S$l5-n}eGD430R{(9@MDj0<MxObnh+N2nG(u)PjT~<o`(Ii! BOdbFL diff --git a/tests/classification/test_cli_classification.py b/tests/classification/test_cli.py similarity index 100% rename from tests/classification/test_cli_classification.py rename to tests/classification/test_cli.py diff --git a/tests/classification/test_hivtb.py b/tests/classification/test_hivtb.py index 91258839..547346fd 100644 --- a/tests/classification/test_hivtb.py +++ b/tests/classification/test_hivtb.py @@ -103,6 +103,7 @@ def test_loading(database_checkers, name: str, dataset: str): prefixes=("HIV-TB_Algorithm_study_X-rays",), possible_labels=(0, 1), expected_num_labels=1, + expected_meta_size=2, ) limit -= 1 diff --git a/tests/classification/test_indian.py b/tests/classification/test_indian.py index 952bc9b7..dcd4236f 100644 --- a/tests/classification/test_indian.py +++ b/tests/classification/test_indian.py @@ -108,6 +108,7 @@ def test_loading(database_checkers, name: str, dataset: str): prefixes=("DatasetA/Training", "DatasetA/Testing"), possible_labels=(0, 1), expected_num_labels=1, + expected_meta_size=2, ) limit -= 1 diff --git a/tests/classification/test_montgomery.py b/tests/classification/test_montgomery.py index ef8715ea..494528dc 100644 --- a/tests/classification/test_montgomery.py +++ b/tests/classification/test_montgomery.py @@ -108,6 +108,7 @@ def test_loading(database_checkers, name: str, dataset: str): prefixes=("CXR_png/MCUCXR_0",), possible_labels=(0, 1), expected_num_labels=1, + expected_meta_size=2, ) limit -= 1 diff --git a/tests/classification/test_nih_cxr14.py b/tests/classification/test_nih_cxr14.py index da5504ba..1d2c2222 100644 --- a/tests/classification/test_nih_cxr14.py +++ b/tests/classification/test_nih_cxr14.py @@ -83,6 +83,7 @@ def test_loading(database_checkers, name: str, dataset: str, num_labels: int): possible_labels=(0, 1), expected_num_labels=num_labels, expected_image_shape=(1, 1024, 1024), + expected_meta_size=2, ) limit -= 1 diff --git a/tests/classification/test_padchest.py b/tests/classification/test_padchest.py index af6007df..78ce812a 100644 --- a/tests/classification/test_padchest.py +++ b/tests/classification/test_padchest.py @@ -88,6 +88,7 @@ def test_loading(database_checkers, name: str, dataset: str, num_labels: int): prefixes=("",), possible_labels=(0, 1), expected_num_labels=num_labels, + expected_meta_size=2, ) limit -= 1 diff --git a/tests/classification/test_shenzhen.py b/tests/classification/test_shenzhen.py index afc55032..2c31ac26 100644 --- a/tests/classification/test_shenzhen.py +++ b/tests/classification/test_shenzhen.py @@ -105,6 +105,7 @@ def test_loading(database_checkers, name: str, dataset: str): prefixes=("CXR_png/CHNCXR_0",), possible_labels=(0, 1), expected_num_labels=1, + expected_meta_size=2, ) limit -= 1 diff --git a/tests/classification/test_tbpoc.py b/tests/classification/test_tbpoc.py index 81288179..66dcd46a 100644 --- a/tests/classification/test_tbpoc.py +++ b/tests/classification/test_tbpoc.py @@ -109,6 +109,7 @@ def test_loading(database_checkers, name: str, dataset: str): ), possible_labels=(0, 1), expected_num_labels=1, + expected_meta_size=2, ) limit -= 1 diff --git a/tests/common/__init__.py b/tests/common/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/common/conftest.py b/tests/common/conftest.py deleted file mode 100644 index e9c23ab2..00000000 --- a/tests/common/conftest.py +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch> -# -# SPDX-License-Identifier: GPL-3.0-or-later - -import pathlib - -import pytest - - -@pytest.fixture -def datadir(request) -> pathlib.Path: - """Return the directory in which the test is sitting. Check the pytest - documentation for more information. - - Parameters - ---------- - request - Information of the requesting test function. - - Returns - ------- - pathlib.Path - The directory in which the test is sitting. - """ - - return pathlib.Path(request.module.__file__).parents[0] / "data" diff --git a/tests/common/data/iris-test.csv b/tests/common/data/iris-test.csv deleted file mode 100644 index 27d1b05a..00000000 --- a/tests/common/data/iris-test.csv +++ /dev/null @@ -1,75 +0,0 @@ -5,3,1.6,0.2,Iris-setosa -5,3.4,1.6,0.4,Iris-setosa -5.2,3.5,1.5,0.2,Iris-setosa -5.2,3.4,1.4,0.2,Iris-setosa -4.7,3.2,1.6,0.2,Iris-setosa -4.8,3.1,1.6,0.2,Iris-setosa -5.4,3.4,1.5,0.4,Iris-setosa -5.2,4.1,1.5,0.1,Iris-setosa -5.5,4.2,1.4,0.2,Iris-setosa -4.9,3.1,1.5,0.1,Iris-setosa -5,3.2,1.2,0.2,Iris-setosa -5.5,3.5,1.3,0.2,Iris-setosa -4.9,3.1,1.5,0.1,Iris-setosa -4.4,3,1.3,0.2,Iris-setosa -5.1,3.4,1.5,0.2,Iris-setosa -5,3.5,1.3,0.3,Iris-setosa -4.5,2.3,1.3,0.3,Iris-setosa -4.4,3.2,1.3,0.2,Iris-setosa -5,3.5,1.6,0.6,Iris-setosa -5.1,3.8,1.9,0.4,Iris-setosa -4.8,3,1.4,0.3,Iris-setosa -5.1,3.8,1.6,0.2,Iris-setosa -4.6,3.2,1.4,0.2,Iris-setosa -5.3,3.7,1.5,0.2,Iris-setosa -5,3.3,1.4,0.2,Iris-setosa -6.6,3,4.4,1.4,Iris-versicolor -6.8,2.8,4.8,1.4,Iris-versicolor -6.7,3,5,1.7,Iris-versicolor -6,2.9,4.5,1.5,Iris-versicolor -5.7,2.6,3.5,1,Iris-versicolor -5.5,2.4,3.8,1.1,Iris-versicolor -5.5,2.4,3.7,1,Iris-versicolor -5.8,2.7,3.9,1.2,Iris-versicolor -6,2.7,5.1,1.6,Iris-versicolor -5.4,3,4.5,1.5,Iris-versicolor -6,3.4,4.5,1.6,Iris-versicolor -6.7,3.1,4.7,1.5,Iris-versicolor -6.3,2.3,4.4,1.3,Iris-versicolor -5.6,3,4.1,1.3,Iris-versicolor -5.5,2.5,4,1.3,Iris-versicolor -5.5,2.6,4.4,1.2,Iris-versicolor -6.1,3,4.6,1.4,Iris-versicolor -5.8,2.6,4,1.2,Iris-versicolor -5,2.3,3.3,1,Iris-versicolor -5.6,2.7,4.2,1.3,Iris-versicolor -5.7,3,4.2,1.2,Iris-versicolor -5.7,2.9,4.2,1.3,Iris-versicolor -6.2,2.9,4.3,1.3,Iris-versicolor -5.1,2.5,3,1.1,Iris-versicolor -5.7,2.8,4.1,1.3,Iris-versicolor -7.2,3.2,6,1.8,Iris-virginica -6.2,2.8,4.8,1.8,Iris-virginica -6.1,3,4.9,1.8,Iris-virginica -6.4,2.8,5.6,2.1,Iris-virginica -7.2,3,5.8,1.6,Iris-virginica -7.4,2.8,6.1,1.9,Iris-virginica -7.9,3.8,6.4,2,Iris-virginica -6.4,2.8,5.6,2.2,Iris-virginica -6.3,2.8,5.1,1.5,Iris-virginica -6.1,2.6,5.6,1.4,Iris-virginica -7.7,3,6.1,2.3,Iris-virginica -6.3,3.4,5.6,2.4,Iris-virginica -6.4,3.1,5.5,1.8,Iris-virginica -6,3,4.8,1.8,Iris-virginica -6.9,3.1,5.4,2.1,Iris-virginica -6.7,3.1,5.6,2.4,Iris-virginica -6.9,3.1,5.1,2.3,Iris-virginica -5.8,2.7,5.1,1.9,Iris-virginica -6.8,3.2,5.9,2.3,Iris-virginica -6.7,3.3,5.7,2.5,Iris-virginica -6.7,3,5.2,2.3,Iris-virginica -6.3,2.5,5,1.9,Iris-virginica -6.5,3,5.2,2,Iris-virginica -6.2,3.4,5.4,2.3,Iris-virginica -5.9,3,5.1,1.8,Iris-virginica diff --git a/tests/common/data/iris-train.csv b/tests/common/data/iris-train.csv deleted file mode 100644 index 82d5b134..00000000 --- a/tests/common/data/iris-train.csv +++ /dev/null @@ -1,75 +0,0 @@ -5.1,3.5,1.4,0.2,Iris-setosa -4.9,3,1.4,0.2,Iris-setosa -4.7,3.2,1.3,0.2,Iris-setosa -4.6,3.1,1.5,0.2,Iris-setosa -5,3.6,1.4,0.2,Iris-setosa -5.4,3.9,1.7,0.4,Iris-setosa -4.6,3.4,1.4,0.3,Iris-setosa -5,3.4,1.5,0.2,Iris-setosa -4.4,2.9,1.4,0.2,Iris-setosa -4.9,3.1,1.5,0.1,Iris-setosa -5.4,3.7,1.5,0.2,Iris-setosa -4.8,3.4,1.6,0.2,Iris-setosa -4.8,3,1.4,0.1,Iris-setosa -4.3,3,1.1,0.1,Iris-setosa -5.8,4,1.2,0.2,Iris-setosa -5.7,4.4,1.5,0.4,Iris-setosa -5.4,3.9,1.3,0.4,Iris-setosa -5.1,3.5,1.4,0.3,Iris-setosa -5.7,3.8,1.7,0.3,Iris-setosa -5.1,3.8,1.5,0.3,Iris-setosa -5.4,3.4,1.7,0.2,Iris-setosa -5.1,3.7,1.5,0.4,Iris-setosa -4.6,3.6,1,0.2,Iris-setosa -5.1,3.3,1.7,0.5,Iris-setosa -4.8,3.4,1.9,0.2,Iris-setosa -7,3.2,4.7,1.4,Iris-versicolor -6.4,3.2,4.5,1.5,Iris-versicolor -6.9,3.1,4.9,1.5,Iris-versicolor -5.5,2.3,4,1.3,Iris-versicolor -6.5,2.8,4.6,1.5,Iris-versicolor -5.7,2.8,4.5,1.3,Iris-versicolor -6.3,3.3,4.7,1.6,Iris-versicolor -4.9,2.4,3.3,1,Iris-versicolor -6.6,2.9,4.6,1.3,Iris-versicolor -5.2,2.7,3.9,1.4,Iris-versicolor -5,2,3.5,1,Iris-versicolor -5.9,3,4.2,1.5,Iris-versicolor -6,2.2,4,1,Iris-versicolor -6.1,2.9,4.7,1.4,Iris-versicolor -5.6,2.9,3.6,1.3,Iris-versicolor -6.7,3.1,4.4,1.4,Iris-versicolor -5.6,3,4.5,1.5,Iris-versicolor -5.8,2.7,4.1,1,Iris-versicolor -6.2,2.2,4.5,1.5,Iris-versicolor -5.6,2.5,3.9,1.1,Iris-versicolor -5.9,3.2,4.8,1.8,Iris-versicolor -6.1,2.8,4,1.3,Iris-versicolor -6.3,2.5,4.9,1.5,Iris-versicolor -6.1,2.8,4.7,1.2,Iris-versicolor -6.4,2.9,4.3,1.3,Iris-versicolor -6.3,3.3,6,2.5,Iris-virginica -5.8,2.7,5.1,1.9,Iris-virginica -7.1,3,5.9,2.1,Iris-virginica -6.3,2.9,5.6,1.8,Iris-virginica -6.5,3,5.8,2.2,Iris-virginica -7.6,3,6.6,2.1,Iris-virginica -4.9,2.5,4.5,1.7,Iris-virginica -7.3,2.9,6.3,1.8,Iris-virginica -6.7,2.5,5.8,1.8,Iris-virginica -7.2,3.6,6.1,2.5,Iris-virginica -6.5,3.2,5.1,2,Iris-virginica -6.4,2.7,5.3,1.9,Iris-virginica -6.8,3,5.5,2.1,Iris-virginica -5.7,2.5,5,2,Iris-virginica -5.8,2.8,5.1,2.4,Iris-virginica -6.4,3.2,5.3,2.3,Iris-virginica -6.5,3,5.5,1.8,Iris-virginica -7.7,3.8,6.7,2.2,Iris-virginica -7.7,2.6,6.9,2.3,Iris-virginica -6,2.2,5,1.5,Iris-virginica -6.9,3.2,5.7,2.3,Iris-virginica -5.6,2.8,4.9,2,Iris-virginica -7.7,2.8,6.7,2,Iris-virginica -6.3,2.7,4.9,1.8,Iris-virginica -6.7,3.3,5.7,2.1,Iris-virginica diff --git a/tests/classification/conftest.py b/tests/conftest.py similarity index 86% rename from tests/classification/conftest.py rename to tests/conftest.py index 97d42378..36e5fa5b 100644 --- a/tests/classification/conftest.py +++ b/tests/conftest.py @@ -44,7 +44,7 @@ def pytest_configure(config): config.addinivalue_line( "markers", "skip_if_rc_var_not_set(name): this mark skips the test if a certain " - "~/.config/mednet.libs.classification.toml variable is not set", + "~/.config/mednet.toml variable is not set", ) config.addinivalue_line("markers", "slow: this mark indicates slow tests") @@ -134,14 +134,19 @@ class DatabaseCheckers: assert len(split[k]) == lengths[k] for s in split[k]: - assert any([s[0].startswith(k) for k in prefixes]), ( - f"Sample with name {s[0]} does not start with any of the " - f"prefixes in {prefixes}" - ) - if isinstance(s[1], list): - assert all([k in possible_labels for k in s[1]]) - else: - assert s[1] in possible_labels + # check filename prefixes match, if prefixes were passed + if prefixes: + assert any([s[0].startswith(k) for k in prefixes]), ( + f"Sample with name {s[0]} does not start with any of the " + f"prefixes in {prefixes}" + ) + + # check if labels match, if labels were passed + if possible_labels: + if isinstance(s[1], list): + assert all([k in possible_labels for k in s[1]]) + else: + assert s[1] in possible_labels @staticmethod def check_loaded_batch( @@ -151,6 +156,7 @@ class DatabaseCheckers: prefixes: typing.Sequence[str], possible_labels: typing.Sequence[int], expected_num_labels: int, + expected_meta_size: int, expected_image_shape: tuple[int, ...] | None = None, ): """Check the consistency of an individual (loaded) batch. @@ -170,6 +176,9 @@ class DatabaseCheckers: These are the list of possible labels contained in any split. expected_num_labels The expected number of labels each sample should have. + expected_meta_size + The expected number of elements on the meta-information dictionary + on every sample. expected_image_shape The expected shape of the image (num_channels, width, height). """ @@ -186,18 +195,20 @@ class DatabaseCheckers: ) assert isinstance(batch[1], dict) # metadata - assert len(batch[1]) == 2 # label and name + assert len(batch[1]) == expected_meta_size assert "target" in batch[1] - assert all([k in possible_labels for k in batch[1]["target"]]) + if possible_labels: + assert all([k in possible_labels for k in batch[1]["target"]]) if expected_num_labels: assert len(batch[1]["target"]) == expected_num_labels assert "name" in batch[1] - assert all( - [any([k.startswith(j) for j in prefixes]) for k in batch[1]["name"]], - ) + if prefixes: + assert all( + [any([k.startswith(j) for j in prefixes]) for k in batch[1]["name"]], + ) # use the code below to view generated images # from torchvision.transforms.functional import to_pil_image diff --git a/tests/common/data/16bits.png b/tests/data/16bits.png similarity index 100% rename from tests/common/data/16bits.png rename to tests/data/16bits.png diff --git a/tests/common/data/iris.json b/tests/data/iris.json similarity index 100% rename from tests/common/data/iris.json rename to tests/data/iris.json diff --git a/tests/classification/data/mednet.toml b/tests/data/mednet.toml similarity index 50% rename from tests/classification/data/mednet.toml rename to tests/data/mednet.toml index 283c0998..6096cb4b 100644 --- a/tests/classification/data/mednet.toml +++ b/tests/data/mednet.toml @@ -1,6 +1,16 @@ [datadir] +# classification +indian = "/idiap/resource/database/TBXpredict" +tbx11k = "/idiap/resource/database/tbx11k" + +# segmentation +chasedb1 = "/idiap/resource/database/CHASE-DB1" +drive = "/idiap/resource/database/DRIVE" +hrf = "/idiap/resource/database/HRF" +jsrt = "/idiap/resource/database/JSRT" +stare = "/idiap/resource/database/STARE" + +# classification and segmentation #montgomery = "/idiap/resource/database/MontgomeryXraySet" montgomery = "/idiap/resource/database/montgomery-preprocessed" shenzhen = "/idiap/resource/database/ShenzhenXraySet" -indian = "/idiap/resource/database/TBXpredict" -tbx11k = "/idiap/resource/database/tbx11k" diff --git a/tests/common/data/raw_with_black_border.png b/tests/data/raw_with_black_border.png similarity index 100% rename from tests/common/data/raw_with_black_border.png rename to tests/data/raw_with_black_border.png diff --git a/tests/common/data/raw_with_elastic_deformation.png b/tests/data/raw_with_elastic_deformation.png similarity index 100% rename from tests/common/data/raw_with_elastic_deformation.png rename to tests/data/raw_with_elastic_deformation.png diff --git a/tests/common/data/raw_without_black_border.png b/tests/data/raw_without_black_border.png similarity index 100% rename from tests/common/data/raw_without_black_border.png rename to tests/data/raw_without_black_border.png diff --git a/tests/common/data/raw_without_elastic_deformation.png b/tests/data/raw_without_elastic_deformation.png similarity index 100% rename from tests/common/data/raw_without_elastic_deformation.png rename to tests/data/raw_without_elastic_deformation.png diff --git a/tests/segmentation/conftest.py b/tests/segmentation/conftest.py deleted file mode 100644 index ce7e932f..00000000 --- a/tests/segmentation/conftest.py +++ /dev/null @@ -1,253 +0,0 @@ -# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch> -# -# SPDX-License-Identifier: GPL-3.0-or-later - -import pathlib -import typing - -import numpy -import pytest -import torch -from mednet.libs.common.data.split import JSONDatabaseSplit -from mednet.libs.common.data.typing import DatabaseSplit - - -@pytest.fixture -def datadir(request) -> pathlib.Path: - """Return the directory in which the test is sitting. Check the pytest - documentation for more information. - - Parameters - ---------- - request - Information of the requesting test function. - - Returns - ------- - pathlib.Path - The directory in which the test is sitting. - """ - - return pathlib.Path(request.module.__file__).parents[0] / "data" - - -def pytest_configure(config): - """This function is run once for pytest setup. - - Parameters - ---------- - config - Configuration values. Check the pytest documentation for more - information. - """ - - config.addinivalue_line( - "markers", - "skip_if_rc_var_not_set(name): this mark skips the test if a certain " - "~/.config/mednet.libs.segmentation.toml variable is not set", - ) - - config.addinivalue_line("markers", "slow: this mark indicates slow tests") - - -def pytest_runtest_setup(item): - """This function is run for every test candidate in this directory. - - The test is run if this function returns ``None``. To skip a test, - call ``pytest.skip()``, specifying a reason. - - Parameters - ---------- - item - A test invocation item. Check the pytest documentation for more - information. - """ - - from mednet.libs.common.utils.rc import load_rc - - rc = load_rc() - - # iterates over all markers for the item being examined, get the first - # argument and accumulate these names - rc_names = [ - mark.args[0] for mark in item.iter_markers(name="skip_if_rc_var_not_set") - ] - - # checks all names mentioned are set in ~/.config/mednet.libs.segmentation.toml, otherwise, - # skip the test - if rc_names: - missing = [k for k in rc_names if rc.get(k) is None] - if any(missing): - pytest.skip( - f"Test skipped because {', '.join(missing)} is **not** " - f"set in ~/.config/mednet.libs.segmentation.toml", - ) - - -def rc_variable_set(name): - from mednet.libs.common.utils.rc import load_rc - - rc = load_rc() - pytest.mark.skipif( - name not in rc, - reason=f"RC variable '{name}' is not set", - ) - - -@pytest.fixture(scope="session") -def temporary_basedir(tmp_path_factory): - return tmp_path_factory.mktemp("test-cli") - - -class DatabaseCheckers: - """Helpers for database tests.""" - - @staticmethod - def check_split( - split: DatabaseSplit, - lengths: dict[str, int], - prefixes: typing.Sequence[str] = None, - ): - """Run a simple consistency check on the data split. - - Parameters - ---------- - split - An instance of DatabaseSplit. - lengths - A dictionary that contains keys matching those of the split (this - will be checked). The values of the dictionary should correspond - to the sizes of each of the datasets in the split. - prefixes - Each file named in a split should start with at least one of these - prefixes. - """ - - assert len(split) == len(lengths) - - for k in lengths.keys(): - # dataset must have been declared - assert k in split - - assert len(split[k]) == lengths[k] - for s in split[k]: - if prefixes is not None: - assert any([s[0].startswith(k) for k in prefixes]), ( - f"Sample with name {s[0]} does not start with any of the " - f"prefixes in {prefixes}" - ) - - @staticmethod - def check_loaded_batch( - batch, - batch_size: int, - color_planes: int, - expected_num_targets: int, - prefixes: typing.Sequence[str] = None, - expected_image_shape: tuple[int, ...] | None = None, - ): - """Check the consistency of an individual (loaded) batch. - - Parameters - ---------- - batch - The loaded batch to be checked. - batch_size - The mini-batch size. - color_planes - The number of color planes in the images. - expected_num_targets - The expected number of labels each sample should have. - prefixes - Each file named in a split should start with at least one of these - prefixes. - expected_image_shape - The expected shape of the image (num_channels, width, height). - """ - - assert len(batch) == 2 # sample, metadata - - assert isinstance(batch[0], torch.Tensor) - assert batch[0].shape[0] == batch_size # mini-batch size - assert batch[0].shape[1] == color_planes - assert all([isinstance(image, torch.Tensor) for image in batch[0]]) - - if expected_image_shape: - assert all( - [data.shape == expected_image_shape for data in batch[0]], - ) - - assert isinstance(batch[1], dict) # metadata - assert len(batch[1]) in [2, 3] # target, Optional(mask), name - - assert "target" in batch[1] - assert all([isinstance(target, torch.Tensor) for target in batch[1]["target"]]) - - if expected_num_targets: - assert len(batch[1]["target"]) == expected_num_targets - - if "mask" in batch[1]: - assert all([isinstance(mask, torch.Tensor) for mask in batch[1]["mask"]]) - - assert "name" in batch[1] - if prefixes is not None: - assert all( - [any([k.startswith(j) for j in prefixes]) for k in batch[1]["name"]], - ) - - @staticmethod - def check_image_quality( - datamodule, - reference_histogram_file, - compare_type="equal", - pearson_coeff_threshold=0.005, - ): - ref_histogram_splits = JSONDatabaseSplit(reference_histogram_file) - - for split_name in ref_histogram_splits: - raw_samples = datamodule.splits[split_name][0][0] - - # It is not possible to get a sample from a Dataset by name/path, - # only by index. This creates a dict of sample name to dataset - # index. - raw_samples_indices = {} - for idx, rs in enumerate(raw_samples): - raw_samples_indices[rs[0]] = idx - - for ref_hist_path, ref_hist_data in ref_histogram_splits[split_name]: - # Get index in the dataset that will return the data - # corresponding to the specified sample name - dataset_sample_index = raw_samples_indices[ref_hist_path] - - image_tensor = datamodule._datasets[split_name][ # noqa: SLF001 - dataset_sample_index - ][0] - - histogram = [] - for color_channel in image_tensor: - color_channel = numpy.multiply( - color_channel.numpy(), - 255, - ).astype(int) - histogram.extend( - numpy.histogram( - color_channel, - bins=256, - range=(0, 256), - )[0].tolist(), - ) - - if compare_type == "statistical": - # Compute pearson coefficients between histogram and - # reference and check the similarity within a certain - # threshold - pearson_coeffs = numpy.corrcoef(histogram, ref_hist_data) - assert 1 - pearson_coeff_threshold <= pearson_coeffs[0][1] <= 1 - - else: - assert histogram == ref_hist_data - - -@pytest.fixture -def database_checkers(): - return DatabaseCheckers diff --git a/tests/segmentation/test_chasedb1.py b/tests/segmentation/test_chasedb1.py index 77c8f2d6..04983002 100644 --- a/tests/segmentation/test_chasedb1.py +++ b/tests/segmentation/test_chasedb1.py @@ -33,6 +33,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.chasedb1", f"{split}.json"), lengths=lengths, + prefixes=["Image_"], + possible_labels=[], ) @@ -81,7 +83,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=["Image_"], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_cli_segmentation.py b/tests/segmentation/test_cli.py similarity index 100% rename from tests/segmentation/test_cli_segmentation.py rename to tests/segmentation/test_cli.py diff --git a/tests/segmentation/test_cxr8.py b/tests/segmentation/test_cxr8.py index 1d18d53c..c097557a 100644 --- a/tests/segmentation/test_cxr8.py +++ b/tests/segmentation/test_cxr8.py @@ -32,6 +32,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.cxr8", f"{split}.json"), lengths=lengths, + prefixes=[], + possible_labels=[], ) @@ -79,7 +81,8 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, ) limit -= 1 diff --git a/tests/segmentation/test_drhagis.py b/tests/segmentation/test_drhagis.py index 48001248..8eaf73e0 100644 --- a/tests/segmentation/test_drhagis.py +++ b/tests/segmentation/test_drhagis.py @@ -32,6 +32,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.drhagis", f"{split}.json"), lengths=lengths, + prefixes=["Fundus_Images/"], + possible_labels=[], ) @@ -79,7 +81,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=["Fundus_Images/"], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_drionsdb.py b/tests/segmentation/test_drionsdb.py index 7d4e14f8..6c04191a 100644 --- a/tests/segmentation/test_drionsdb.py +++ b/tests/segmentation/test_drionsdb.py @@ -33,6 +33,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.drionsdb", f"{split}.json"), lengths=lengths, + prefixes=["images/image_"], + possible_labels=[], ) @@ -81,7 +83,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=["images/image_"], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_drishtigs1.py b/tests/segmentation/test_drishtigs1.py index 0c099b55..8f704979 100644 --- a/tests/segmentation/test_drishtigs1.py +++ b/tests/segmentation/test_drishtigs1.py @@ -33,6 +33,11 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.drishtigs1", f"{split}.json"), lengths=lengths, + prefixes=[ + "Drishti-GS1_files/Training/Images/drishtiGS_", + "Drishti-GS1_files/Test/Images/drishtiGS_", + ], + possible_labels=[], ) @@ -83,7 +88,13 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=[ + "Drishti-GS1_files/Training/Images/drishtiGS_", + "Drishti-GS1_files/Test/Images/drishtiGS_", + ], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_drive.py b/tests/segmentation/test_drive.py index 9d356596..33fdd65a 100644 --- a/tests/segmentation/test_drive.py +++ b/tests/segmentation/test_drive.py @@ -33,6 +33,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.drive", f"{split}.json"), lengths=lengths, + prefixes=["training/", "test/"], + possible_labels=[], ) @@ -80,7 +82,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + possible_labels=[], + prefixes=["training/", "test/"], ) limit -= 1 diff --git a/tests/segmentation/test_hrf.py b/tests/segmentation/test_hrf.py index 416fe434..5f7a29bd 100644 --- a/tests/segmentation/test_hrf.py +++ b/tests/segmentation/test_hrf.py @@ -32,6 +32,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.hrf", f"{split}.json"), lengths=lengths, + prefixes=["images/"], + possible_labels=[], ) @@ -79,7 +81,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=["images/"], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_iostar.py b/tests/segmentation/test_iostar.py index e50967e0..082131f2 100644 --- a/tests/segmentation/test_iostar.py +++ b/tests/segmentation/test_iostar.py @@ -33,6 +33,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.iostar", f"{split}.json"), lengths=lengths, + prefixes=["image/STAR "], + possible_labels=[], ) @@ -78,7 +80,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=["image/STAR "], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_jsrt.py b/tests/segmentation/test_jsrt.py index c096a130..e40b6d18 100644 --- a/tests/segmentation/test_jsrt.py +++ b/tests/segmentation/test_jsrt.py @@ -32,6 +32,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.jsrt", f"{split}.json"), lengths=lengths, + prefixes=["All247images/JPC"], + possible_labels=[], ) @@ -80,7 +82,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=["All247images/JPC"], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_montgomery.py b/tests/segmentation/test_montgomery.py index 97d30147..df72590c 100644 --- a/tests/segmentation/test_montgomery.py +++ b/tests/segmentation/test_montgomery.py @@ -32,6 +32,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.montgomery", f"{split}.json"), lengths=lengths, + prefixes=["CXR_png"], + possible_labels=[], ) @@ -80,8 +82,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, prefixes=["CXR_png"], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_refuge.py b/tests/segmentation/test_refuge.py index 07dedfc2..df854840 100644 --- a/tests/segmentation/test_refuge.py +++ b/tests/segmentation/test_refuge.py @@ -32,6 +32,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.refuge", f"{split}.json"), lengths=lengths, + prefixes=["Training400/", "REFUGE-Validation400/V", "Test400/T0"], + possible_labels=[], ) @@ -81,7 +83,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=["Training400/", "REFUGE-Validation400/V", "Test400/T0"], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_rimoner3.py b/tests/segmentation/test_rimoner3.py index 6a2327f3..895dc3c0 100644 --- a/tests/segmentation/test_rimoner3.py +++ b/tests/segmentation/test_rimoner3.py @@ -35,6 +35,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.rimoner3", f"{split}.json"), lengths=lengths, + prefixes=["Healthy/Stereo Images/N-", "Glaucoma and suspects/Stereo Images/"], + possible_labels=[], ) @@ -85,7 +87,13 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=[ + "Healthy/Stereo Images/N-", + "Glaucoma and suspects/Stereo Images/", + ], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_shenzhen.py b/tests/segmentation/test_shenzhen.py index 9510d3e4..8de3a36e 100644 --- a/tests/segmentation/test_shenzhen.py +++ b/tests/segmentation/test_shenzhen.py @@ -32,6 +32,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.shenzhen", f"{split}.json"), lengths=lengths, + prefixes=["CXR_png/CHNCXR_"], + possible_labels=[], ) @@ -80,7 +82,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=["CXR_png/CHNCXR_"], + possible_labels=[], ) limit -= 1 diff --git a/tests/segmentation/test_stare.py b/tests/segmentation/test_stare.py index 6268ec9f..08697089 100644 --- a/tests/segmentation/test_stare.py +++ b/tests/segmentation/test_stare.py @@ -33,6 +33,8 @@ def test_protocol_consistency( database_checkers.check_split( make_split("mednet.libs.segmentation.config.data.stare", f"{split}.json"), lengths=lengths, + prefixes=["stare-images/im0"], + possible_labels=[], ) @@ -81,7 +83,10 @@ def test_loading(database_checkers, name: str, dataset: str): batch, batch_size=1, color_planes=3, - expected_num_targets=1, + expected_num_labels=1, + expected_meta_size=3, + prefixes=["stare-images/im0"], + possible_labels=[], ) limit -= 1 diff --git a/tests/common/test_database_split.py b/tests/test_database_split.py similarity index 100% rename from tests/common/test_database_split.py rename to tests/test_database_split.py diff --git a/tests/common/test_image_utils.py b/tests/test_image_utils.py similarity index 100% rename from tests/common/test_image_utils.py rename to tests/test_image_utils.py diff --git a/tests/common/test_resource_monitor.py b/tests/test_resource_monitor.py similarity index 100% rename from tests/common/test_resource_monitor.py rename to tests/test_resource_monitor.py diff --git a/tests/common/test_transforms.py b/tests/test_transforms.py similarity index 100% rename from tests/common/test_transforms.py rename to tests/test_transforms.py -- GitLab