From b550794f771760e1b1903e2286c1d23b96ff345e Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Sun, 6 Aug 2023 15:55:04 +0200 Subject: [PATCH] Re-shuffle datamodules to the "config" base directory, adjust tests and documentation --- .reuse/dep5 | 4 +- doc/_templates/config.rst | 5 +- doc/api.rst | 38 --- doc/config.rst | 125 ++++---- doc/links.rst | 4 +- doc/results/index.rst | 30 +- doc/usage/evaluation.rst | 2 +- pyproject.toml | 270 +++++++++--------- .../{data/hivtb => config}/__init__.py | 0 .../indian => config/data/hivtb}/__init__.py | 0 .../{ => config}/data/hivtb/datamodule.py | 20 +- .../{ => config}/data/hivtb/fold-0.json | 0 .../{ => config}/data/hivtb/fold-1.json | 0 .../{ => config}/data/hivtb/fold-2.json | 0 .../{ => config}/data/hivtb/fold-3.json | 0 .../{ => config}/data/hivtb/fold-4.json | 0 .../{ => config}/data/hivtb/fold-5.json | 0 .../{ => config}/data/hivtb/fold-6.json | 0 .../{ => config}/data/hivtb/fold-7.json | 0 .../{ => config}/data/hivtb/fold-8.json | 0 .../{ => config}/data/hivtb/fold-9.json | 0 src/ptbench/{ => config}/data/hivtb/fold_0.py | 4 +- src/ptbench/{ => config}/data/hivtb/fold_1.py | 4 +- src/ptbench/{ => config}/data/hivtb/fold_2.py | 4 +- src/ptbench/{ => config}/data/hivtb/fold_3.py | 4 +- src/ptbench/{ => config}/data/hivtb/fold_4.py | 4 +- src/ptbench/{ => config}/data/hivtb/fold_5.py | 4 +- src/ptbench/{ => config}/data/hivtb/fold_6.py | 4 +- src/ptbench/{ => config}/data/hivtb/fold_7.py | 4 +- src/ptbench/{ => config}/data/hivtb/fold_8.py | 4 +- src/ptbench/{ => config}/data/hivtb/fold_9.py | 4 +- .../data/indian}/__init__.py | 0 .../{ => config}/data/indian/datamodule.py | 16 +- .../{ => config}/data/indian/default.json | 0 .../{ => config}/data/indian/default.py | 4 +- .../{ => config}/data/indian/fold-0.json | 0 .../{ => config}/data/indian/fold-1.json | 0 .../{ => config}/data/indian/fold-2.json | 0 .../{ => config}/data/indian/fold-3.json | 0 .../{ => config}/data/indian/fold-4.json | 0 .../{ => config}/data/indian/fold-5.json | 0 .../{ => config}/data/indian/fold-6.json | 0 .../{ => config}/data/indian/fold-7.json | 0 .../{ => config}/data/indian/fold-8.json | 0 .../{ => config}/data/indian/fold-9.json | 0 .../{ => config}/data/indian/fold_0.py | 4 +- .../{ => config}/data/indian/fold_1.py | 4 +- .../{ => config}/data/indian/fold_2.py | 4 +- .../{ => config}/data/indian/fold_3.py | 4 +- .../{ => config}/data/indian/fold_4.py | 4 +- .../{ => config}/data/indian/fold_5.py | 4 +- .../{ => config}/data/indian/fold_6.py | 4 +- .../{ => config}/data/indian/fold_7.py | 4 +- .../{ => config}/data/indian/fold_8.py | 4 +- .../{ => config}/data/indian/fold_9.py | 4 +- .../data/montgomery}/__init__.py | 0 .../data/montgomery/datamodule.py | 20 +- .../{ => config}/data/montgomery/default.json | 0 .../{ => config}/data/montgomery/default.py | 5 +- .../{ => config}/data/montgomery/fold-0.json | 0 .../{ => config}/data/montgomery/fold-1.json | 0 .../{ => config}/data/montgomery/fold-2.json | 0 .../{ => config}/data/montgomery/fold-3.json | 0 .../{ => config}/data/montgomery/fold-4.json | 0 .../{ => config}/data/montgomery/fold-5.json | 0 .../{ => config}/data/montgomery/fold-6.json | 0 .../{ => config}/data/montgomery/fold-7.json | 0 .../{ => config}/data/montgomery/fold-8.json | 0 .../{ => config}/data/montgomery/fold-9.json | 0 .../{ => config}/data/montgomery/fold_0.py | 5 +- .../{ => config}/data/montgomery/fold_1.py | 5 +- .../{ => config}/data/montgomery/fold_2.py | 5 +- .../{ => config}/data/montgomery/fold_3.py | 5 +- .../{ => config}/data/montgomery/fold_4.py | 5 +- .../{ => config}/data/montgomery/fold_5.py | 5 +- .../{ => config}/data/montgomery/fold_6.py | 5 +- .../{ => config}/data/montgomery/fold_7.py | 5 +- .../{ => config}/data/montgomery/fold_8.py | 5 +- .../{ => config}/data/montgomery/fold_9.py | 5 +- .../data/montgomery_shenzhen}/__init__.py | 0 .../data/montgomery_shenzhen/datamodule.py | 3 +- .../data/montgomery_shenzhen/default.py | 0 .../data/montgomery_shenzhen/fold_0.py | 0 .../data/montgomery_shenzhen/fold_1.py | 0 .../data/montgomery_shenzhen/fold_2.py | 0 .../data/montgomery_shenzhen/fold_3.py | 0 .../data/montgomery_shenzhen/fold_4.py | 0 .../data/montgomery_shenzhen/fold_5.py | 0 .../data/montgomery_shenzhen/fold_6.py | 0 .../data/montgomery_shenzhen/fold_7.py | 0 .../data/montgomery_shenzhen/fold_8.py | 0 .../data/montgomery_shenzhen/fold_9.py | 0 .../montgomery_shenzhen_indian}/__init__.py | 0 .../montgomery_shenzhen_indian/datamodule.py | 24 +- .../montgomery_shenzhen_indian/default.py | 0 .../data/montgomery_shenzhen_indian/fold_0.py | 0 .../data/montgomery_shenzhen_indian/fold_1.py | 0 .../data/montgomery_shenzhen_indian/fold_2.py | 0 .../data/montgomery_shenzhen_indian/fold_3.py | 0 .../data/montgomery_shenzhen_indian/fold_4.py | 0 .../data/montgomery_shenzhen_indian/fold_5.py | 0 .../data/montgomery_shenzhen_indian/fold_6.py | 0 .../data/montgomery_shenzhen_indian/fold_7.py | 0 .../data/montgomery_shenzhen_indian/fold_8.py | 0 .../data/montgomery_shenzhen_indian/fold_9.py | 0 .../__init__.py | 0 .../datamodule.py | 32 ++- .../default.py | 0 .../__init__.py | 0 .../datamodule.py | 30 +- .../v1_fold_0.py | 0 .../v1_fold_1.py | 0 .../v1_fold_2.py | 0 .../v1_fold_3.py | 0 .../v1_fold_4.py | 0 .../v1_fold_5.py | 0 .../v1_fold_6.py | 0 .../v1_fold_7.py | 0 .../v1_fold_8.py | 0 .../v1_fold_9.py | 0 .../v1_healthy_vs_atb.py | 0 .../v2_fold_0.py | 0 .../v2_fold_1.py | 0 .../v2_fold_2.py | 0 .../v2_fold_3.py | 0 .../v2_fold_4.py | 0 .../v2_fold_5.py | 0 .../v2_fold_6.py | 0 .../v2_fold_7.py | 0 .../v2_fold_8.py | 0 .../v2_fold_9.py | 0 .../v2_others_vs_atb.py | 0 .../data/nih_cxr14}/__init__.py | 0 .../data/nih_cxr14/cardiomegaly.json | 0 .../data/nih_cxr14/cardiomegaly.py | 5 +- .../{ => config}/data/nih_cxr14/datamodule.py | 33 ++- .../data/nih_cxr14/default.json.bz2 | Bin .../{ => config}/data/nih_cxr14/default.py | 5 +- .../data/nih_cxr14_padchest}/__init__.py | 0 .../data/nih_cxr14_padchest/datamodule.py | 18 +- .../data/nih_cxr14_padchest/idiap.py | 0 .../data/padchest}/__init__.py | 0 .../data/padchest/cardiomegaly-idiap.json | 0 .../data/padchest/cardiomegaly_idiap.py | 6 +- .../{ => config}/data/padchest/datamodule.py | 22 +- .../{ => config}/data/padchest/idiap.json.bz2 | Bin .../{ => config}/data/padchest/idiap.py | 9 +- .../data/padchest/no-tb-idiap.json.bz2 | Bin .../{ => config}/data/padchest/no_tb_idiap.py | 5 +- .../{ => config}/data/padchest/tb-idiap.json | 0 .../{ => config}/data/padchest/tb_idiap.py | 5 +- .../data/shenzhen}/__init__.py | 0 .../{ => config}/data/shenzhen/datamodule.py | 22 +- .../{ => config}/data/shenzhen/default.json | 0 .../{ => config}/data/shenzhen/default.py | 5 +- .../{ => config}/data/shenzhen/fold-0.json | 0 .../{ => config}/data/shenzhen/fold-1.json | 0 .../{ => config}/data/shenzhen/fold-2.json | 0 .../{ => config}/data/shenzhen/fold-3.json | 0 .../{ => config}/data/shenzhen/fold-4.json | 0 .../{ => config}/data/shenzhen/fold-5.json | 0 .../{ => config}/data/shenzhen/fold-6.json | 0 .../{ => config}/data/shenzhen/fold-7.json | 0 .../{ => config}/data/shenzhen/fold-8.json | 0 .../{ => config}/data/shenzhen/fold-9.json | 0 .../{ => config}/data/shenzhen/fold_0.py | 5 +- .../{ => config}/data/shenzhen/fold_1.py | 5 +- .../{ => config}/data/shenzhen/fold_2.py | 5 +- .../{ => config}/data/shenzhen/fold_3.py | 5 +- .../{ => config}/data/shenzhen/fold_4.py | 5 +- .../{ => config}/data/shenzhen/fold_5.py | 5 +- .../{ => config}/data/shenzhen/fold_6.py | 5 +- .../{ => config}/data/shenzhen/fold_7.py | 5 +- .../{ => config}/data/shenzhen/fold_8.py | 5 +- .../{ => config}/data/shenzhen/fold_9.py | 5 +- .../tbx11k => config/data/tbpoc}/__init__.py | 0 .../{ => config}/data/tbpoc/datamodule.py | 22 +- .../{ => config}/data/tbpoc/fold-0.json | 0 .../{ => config}/data/tbpoc/fold-1.json | 0 .../{ => config}/data/tbpoc/fold-2.json | 0 .../{ => config}/data/tbpoc/fold-3.json | 0 .../{ => config}/data/tbpoc/fold-4.json | 0 .../{ => config}/data/tbpoc/fold-5.json | 0 .../{ => config}/data/tbpoc/fold-6.json | 0 .../{ => config}/data/tbpoc/fold-7.json | 0 .../{ => config}/data/tbpoc/fold-8.json | 0 .../{ => config}/data/tbpoc/fold-9.json | 0 src/ptbench/{ => config}/data/tbpoc/fold_0.py | 5 +- src/ptbench/{ => config}/data/tbpoc/fold_1.py | 5 +- src/ptbench/{ => config}/data/tbpoc/fold_2.py | 5 +- src/ptbench/{ => config}/data/tbpoc/fold_3.py | 5 +- src/ptbench/{ => config}/data/tbpoc/fold_4.py | 5 +- src/ptbench/{ => config}/data/tbpoc/fold_5.py | 5 +- src/ptbench/{ => config}/data/tbpoc/fold_6.py | 5 +- src/ptbench/{ => config}/data/tbpoc/fold_7.py | 5 +- src/ptbench/{ => config}/data/tbpoc/fold_8.py | 5 +- src/ptbench/{ => config}/data/tbpoc/fold_9.py | 5 +- .../config => config/data/tbx11k}/__init__.py | 0 .../{ => config}/data/tbx11k/datamodule.py | 19 +- .../data/tbx11k/make_splits_from_database.py | 0 .../{ => config}/data/tbx11k/v1-fold-0.json | 0 .../{ => config}/data/tbx11k/v1-fold-1.json | 0 .../{ => config}/data/tbx11k/v1-fold-2.json | 0 .../{ => config}/data/tbx11k/v1-fold-3.json | 0 .../{ => config}/data/tbx11k/v1-fold-4.json | 0 .../{ => config}/data/tbx11k/v1-fold-5.json | 0 .../{ => config}/data/tbx11k/v1-fold-6.json | 0 .../{ => config}/data/tbx11k/v1-fold-7.json | 0 .../{ => config}/data/tbx11k/v1-fold-8.json | 0 .../{ => config}/data/tbx11k/v1-fold-9.json | 0 .../data/tbx11k/v1-healthy-vs-atb.json | 0 .../{ => config}/data/tbx11k/v1_fold_0.py | 5 +- .../{ => config}/data/tbx11k/v1_fold_1.py | 5 +- .../{ => config}/data/tbx11k/v1_fold_2.py | 5 +- .../{ => config}/data/tbx11k/v1_fold_3.py | 5 +- .../{ => config}/data/tbx11k/v1_fold_4.py | 5 +- .../{ => config}/data/tbx11k/v1_fold_5.py | 5 +- .../{ => config}/data/tbx11k/v1_fold_6.py | 5 +- .../{ => config}/data/tbx11k/v1_fold_7.py | 5 +- .../{ => config}/data/tbx11k/v1_fold_8.py | 5 +- .../{ => config}/data/tbx11k/v1_fold_9.py | 5 +- .../data/tbx11k/v1_healthy_vs_atb.py | 5 +- .../{ => config}/data/tbx11k/v2-fold-0.json | 0 .../{ => config}/data/tbx11k/v2-fold-1.json | 0 .../{ => config}/data/tbx11k/v2-fold-2.json | 0 .../{ => config}/data/tbx11k/v2-fold-3.json | 0 .../{ => config}/data/tbx11k/v2-fold-4.json | 0 .../{ => config}/data/tbx11k/v2-fold-5.json | 0 .../{ => config}/data/tbx11k/v2-fold-6.json | 0 .../{ => config}/data/tbx11k/v2-fold-7.json | 0 .../{ => config}/data/tbx11k/v2-fold-8.json | 0 .../{ => config}/data/tbx11k/v2-fold-9.json | 0 .../data/tbx11k/v2-others-vs-atb.json | 0 .../{ => config}/data/tbx11k/v2_fold_0.py | 5 +- .../{ => config}/data/tbx11k/v2_fold_1.py | 5 +- .../{ => config}/data/tbx11k/v2_fold_2.py | 5 +- .../{ => config}/data/tbx11k/v2_fold_3.py | 5 +- .../{ => config}/data/tbx11k/v2_fold_4.py | 5 +- .../{ => config}/data/tbx11k/v2_fold_5.py | 5 +- .../{ => config}/data/tbx11k/v2_fold_6.py | 5 +- .../{ => config}/data/tbx11k/v2_fold_7.py | 5 +- .../{ => config}/data/tbx11k/v2_fold_8.py | 5 +- .../{ => config}/data/tbx11k/v2_fold_9.py | 5 +- .../data/tbx11k/v2_others_vs_atb.py | 5 +- src/ptbench/config/models/__init__.py | 0 .../config => config/models}/alexnet.py | 2 +- .../models}/alexnet_pretrained.py | 0 .../config => config/models}/densenet.py | 0 .../models}/densenet_pretrained.py | 0 .../config => config/models}/densenet_rs.py | 0 .../models}/logistic_regression.py | 0 .../{models/config => config/models}/mlp.py | 0 .../{models/config => config/models}/pasa.py | 0 tests/test_cli.py | 8 +- tests/test_hivtb.py | 4 +- tests/test_indian.py | 4 +- tests/test_montgomery.py | 4 +- tests/test_montgomery_shenzhen.py | 10 +- tests/test_montgomery_shenzhen_indian.py | 14 +- ...est_montgomery_shenzhen_indian_padchest.py | 18 +- .../test_montgomery_shenzhen_indian_tbx11k.py | 19 +- tests/test_nih_cxr14.py | 4 +- tests/test_nih_cxr14_padchest.py | 10 +- tests/test_padchest.py | 4 +- tests/test_shenzhen.py | 4 +- tests/test_summary.py | 2 +- tests/test_tbpoc.py | 4 +- tests/test_tbx11k.py | 4 +- 268 files changed, 703 insertions(+), 560 deletions(-) rename src/ptbench/{data/hivtb => config}/__init__.py (100%) rename src/ptbench/{data/indian => config/data/hivtb}/__init__.py (100%) rename src/ptbench/{ => config}/data/hivtb/datamodule.py (85%) rename src/ptbench/{ => config}/data/hivtb/fold-0.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold-1.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold-2.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold-3.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold-4.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold-5.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold-6.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold-7.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold-8.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold-9.json (100%) rename src/ptbench/{ => config}/data/hivtb/fold_0.py (65%) rename src/ptbench/{ => config}/data/hivtb/fold_1.py (65%) rename src/ptbench/{ => config}/data/hivtb/fold_2.py (65%) rename src/ptbench/{ => config}/data/hivtb/fold_3.py (65%) rename src/ptbench/{ => config}/data/hivtb/fold_4.py (65%) rename src/ptbench/{ => config}/data/hivtb/fold_5.py (65%) rename src/ptbench/{ => config}/data/hivtb/fold_6.py (65%) rename src/ptbench/{ => config}/data/hivtb/fold_7.py (65%) rename src/ptbench/{ => config}/data/hivtb/fold_8.py (65%) rename src/ptbench/{ => config}/data/hivtb/fold_9.py (65%) rename src/ptbench/{data/montgomery => config/data/indian}/__init__.py (100%) rename src/ptbench/{ => config}/data/indian/datamodule.py (78%) rename src/ptbench/{ => config}/data/indian/default.json (100%) rename src/ptbench/{ => config}/data/indian/default.py (65%) rename src/ptbench/{ => config}/data/indian/fold-0.json (100%) rename src/ptbench/{ => config}/data/indian/fold-1.json (100%) rename src/ptbench/{ => config}/data/indian/fold-2.json (100%) rename src/ptbench/{ => config}/data/indian/fold-3.json (100%) rename src/ptbench/{ => config}/data/indian/fold-4.json (100%) rename src/ptbench/{ => config}/data/indian/fold-5.json (100%) rename src/ptbench/{ => config}/data/indian/fold-6.json (100%) rename src/ptbench/{ => config}/data/indian/fold-7.json (100%) rename src/ptbench/{ => config}/data/indian/fold-8.json (100%) rename src/ptbench/{ => config}/data/indian/fold-9.json (100%) rename src/ptbench/{ => config}/data/indian/fold_0.py (66%) rename src/ptbench/{ => config}/data/indian/fold_1.py (66%) rename src/ptbench/{ => config}/data/indian/fold_2.py (66%) rename src/ptbench/{ => config}/data/indian/fold_3.py (66%) rename src/ptbench/{ => config}/data/indian/fold_4.py (66%) rename src/ptbench/{ => config}/data/indian/fold_5.py (66%) rename src/ptbench/{ => config}/data/indian/fold_6.py (66%) rename src/ptbench/{ => config}/data/indian/fold_7.py (66%) rename src/ptbench/{ => config}/data/indian/fold_8.py (66%) rename src/ptbench/{ => config}/data/indian/fold_9.py (66%) rename src/ptbench/{data/montgomery_shenzhen => config/data/montgomery}/__init__.py (100%) rename src/ptbench/{ => config}/data/montgomery/datamodule.py (86%) rename src/ptbench/{ => config}/data/montgomery/default.json (100%) rename src/ptbench/{ => config}/data/montgomery/default.py (63%) rename src/ptbench/{ => config}/data/montgomery/fold-0.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold-1.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold-2.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold-3.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold-4.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold-5.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold-6.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold-7.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold-8.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold-9.json (100%) rename src/ptbench/{ => config}/data/montgomery/fold_0.py (65%) rename src/ptbench/{ => config}/data/montgomery/fold_1.py (65%) rename src/ptbench/{ => config}/data/montgomery/fold_2.py (65%) rename src/ptbench/{ => config}/data/montgomery/fold_3.py (65%) rename src/ptbench/{ => config}/data/montgomery/fold_4.py (65%) rename src/ptbench/{ => config}/data/montgomery/fold_5.py (65%) rename src/ptbench/{ => config}/data/montgomery/fold_6.py (65%) rename src/ptbench/{ => config}/data/montgomery/fold_7.py (65%) rename src/ptbench/{ => config}/data/montgomery/fold_8.py (65%) rename src/ptbench/{ => config}/data/montgomery/fold_9.py (65%) rename src/ptbench/{data/montgomery_shenzhen_indian => config/data/montgomery_shenzhen}/__init__.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/datamodule.py (96%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/default.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_0.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_1.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_2.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_3.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_4.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_5.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_6.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_7.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_8.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen/fold_9.py (100%) rename src/ptbench/{data/montgomery_shenzhen_indian_padchest => config/data/montgomery_shenzhen_indian}/__init__.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/datamodule.py (70%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/default.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_0.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_1.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_2.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_3.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_4.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_5.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_6.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_7.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_8.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian/fold_9.py (100%) rename src/ptbench/{data/montgomery_shenzhen_indian_tbx11k => config/data/montgomery_shenzhen_indian_padchest}/__init__.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_padchest/datamodule.py (70%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_padchest/default.py (100%) rename src/ptbench/{data/nih_cxr14 => config/data/montgomery_shenzhen_indian_tbx11k}/__init__.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/datamodule.py (69%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_0.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_1.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_2.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_3.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_4.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_5.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_6.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_7.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_8.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_fold_9.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v1_healthy_vs_atb.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_0.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_1.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_2.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_3.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_4.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_5.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_6.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_7.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_8.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_fold_9.py (100%) rename src/ptbench/{ => config}/data/montgomery_shenzhen_indian_tbx11k/v2_others_vs_atb.py (100%) rename src/ptbench/{data/nih_cxr14_padchest => config/data/nih_cxr14}/__init__.py (100%) rename src/ptbench/{ => config}/data/nih_cxr14/cardiomegaly.json (100%) rename src/ptbench/{ => config}/data/nih_cxr14/cardiomegaly.py (71%) rename src/ptbench/{ => config}/data/nih_cxr14/datamodule.py (82%) rename src/ptbench/{ => config}/data/nih_cxr14/default.json.bz2 (100%) rename src/ptbench/{ => config}/data/nih_cxr14/default.py (67%) rename src/ptbench/{data/padchest => config/data/nih_cxr14_padchest}/__init__.py (100%) rename src/ptbench/{ => config}/data/nih_cxr14_padchest/datamodule.py (73%) rename src/ptbench/{ => config}/data/nih_cxr14_padchest/idiap.py (100%) rename src/ptbench/{data/shenzhen => config/data/padchest}/__init__.py (100%) rename src/ptbench/{ => config}/data/padchest/cardiomegaly-idiap.json (100%) rename src/ptbench/{ => config}/data/padchest/cardiomegaly_idiap.py (72%) rename src/ptbench/{ => config}/data/padchest/datamodule.py (94%) rename src/ptbench/{ => config}/data/padchest/idiap.json.bz2 (100%) rename src/ptbench/{ => config}/data/padchest/idiap.py (67%) rename src/ptbench/{ => config}/data/padchest/no-tb-idiap.json.bz2 (100%) rename src/ptbench/{ => config}/data/padchest/no_tb_idiap.py (81%) rename src/ptbench/{ => config}/data/padchest/tb-idiap.json (100%) rename src/ptbench/{ => config}/data/padchest/tb_idiap.py (77%) rename src/ptbench/{data/tbpoc => config/data/shenzhen}/__init__.py (100%) rename src/ptbench/{ => config}/data/shenzhen/datamodule.py (84%) rename src/ptbench/{ => config}/data/shenzhen/default.json (100%) rename src/ptbench/{ => config}/data/shenzhen/default.py (75%) rename src/ptbench/{ => config}/data/shenzhen/fold-0.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold-1.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold-2.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold-3.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold-4.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold-5.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold-6.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold-7.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold-8.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold-9.json (100%) rename src/ptbench/{ => config}/data/shenzhen/fold_0.py (66%) rename src/ptbench/{ => config}/data/shenzhen/fold_1.py (66%) rename src/ptbench/{ => config}/data/shenzhen/fold_2.py (66%) rename src/ptbench/{ => config}/data/shenzhen/fold_3.py (66%) rename src/ptbench/{ => config}/data/shenzhen/fold_4.py (66%) rename src/ptbench/{ => config}/data/shenzhen/fold_5.py (66%) rename src/ptbench/{ => config}/data/shenzhen/fold_6.py (66%) rename src/ptbench/{ => config}/data/shenzhen/fold_7.py (66%) rename src/ptbench/{ => config}/data/shenzhen/fold_8.py (66%) rename src/ptbench/{ => config}/data/shenzhen/fold_9.py (66%) rename src/ptbench/{data/tbx11k => config/data/tbpoc}/__init__.py (100%) rename src/ptbench/{ => config}/data/tbpoc/datamodule.py (84%) rename src/ptbench/{ => config}/data/tbpoc/fold-0.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold-1.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold-2.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold-3.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold-4.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold-5.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold-6.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold-7.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold-8.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold-9.json (100%) rename src/ptbench/{ => config}/data/tbpoc/fold_0.py (65%) rename src/ptbench/{ => config}/data/tbpoc/fold_1.py (65%) rename src/ptbench/{ => config}/data/tbpoc/fold_2.py (65%) rename src/ptbench/{ => config}/data/tbpoc/fold_3.py (65%) rename src/ptbench/{ => config}/data/tbpoc/fold_4.py (65%) rename src/ptbench/{ => config}/data/tbpoc/fold_5.py (65%) rename src/ptbench/{ => config}/data/tbpoc/fold_6.py (65%) rename src/ptbench/{ => config}/data/tbpoc/fold_7.py (65%) rename src/ptbench/{ => config}/data/tbpoc/fold_8.py (65%) rename src/ptbench/{ => config}/data/tbpoc/fold_9.py (65%) rename src/ptbench/{models/config => config/data/tbx11k}/__init__.py (100%) rename src/ptbench/{ => config}/data/tbx11k/datamodule.py (93%) rename src/ptbench/{ => config}/data/tbx11k/make_splits_from_database.py (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-0.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-1.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-2.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-3.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-4.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-5.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-6.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-7.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-8.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-fold-9.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1-healthy-vs-atb.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_0.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_1.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_2.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_3.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_4.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_5.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_6.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_7.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_8.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_fold_9.py (67%) rename src/ptbench/{ => config}/data/tbx11k/v1_healthy_vs_atb.py (81%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-0.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-1.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-2.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-3.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-4.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-5.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-6.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-7.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-8.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-fold-9.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2-others-vs-atb.json (100%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_0.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_1.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_2.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_3.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_4.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_5.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_6.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_7.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_8.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_fold_9.py (68%) rename src/ptbench/{ => config}/data/tbx11k/v2_others_vs_atb.py (83%) create mode 100644 src/ptbench/config/models/__init__.py rename src/ptbench/{models/config => config/models}/alexnet.py (90%) rename src/ptbench/{models/config => config/models}/alexnet_pretrained.py (100%) rename src/ptbench/{models/config => config/models}/densenet.py (100%) rename src/ptbench/{models/config => config/models}/densenet_pretrained.py (100%) rename src/ptbench/{models/config => config/models}/densenet_rs.py (100%) rename src/ptbench/{models/config => config/models}/logistic_regression.py (100%) rename src/ptbench/{models/config => config/models}/mlp.py (100%) rename src/ptbench/{models/config => config/models}/pasa.py (100%) diff --git a/.reuse/dep5 b/.reuse/dep5 index f21f6e2e..4e2a69c2 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -15,8 +15,8 @@ Files: doc/results/img/*.jpg doc/results/img/*.png doc/results/img/*/*.jpg - src/ptbench/data/*/*.json - src/ptbench/data/*/*.json.bz2 + src/ptbench/config/data/*/*.json + src/ptbench/config/data/*/*.json.bz2 tests/data/*.csv tests/data/*.json tests/data/*.png diff --git a/doc/_templates/config.rst b/doc/_templates/config.rst index 3a1f3d38..dc8a8877 100644 --- a/doc/_templates/config.rst +++ b/doc/_templates/config.rst @@ -1,3 +1,6 @@ {% include "autosummary/module.rst" %} -.. literalinclude:: ../../../../src/{{ fullname.replace(".", "/") }}.py +.. literalinclude:: ../../../src/{{ fullname.replace(".", "/") }}.py :start-at: import + + +.. include:: ../../links.rst diff --git a/doc/api.rst b/doc/api.rst index 5bfd2b2f..4b223ca5 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -28,44 +28,6 @@ Auxiliary classes and methods to define raw dataset iterators. ptbench.data.split ptbench.data.typing -.. _ptbench.api.rawdata: - -Basic Datamodules ------------------ - -Pytorch_ :py:class:`torch.utils.data.DataLoader` access through lightning_ -:py:class:`lightning.pytorch.core.LightningDataModule`. - -.. autosummary:: - :toctree: api/data/raw - - ptbench.data.hivtb.datamodule - ptbench.data.indian.datamodule - ptbench.data.montgomery.datamodule - ptbench.data.nih_cxr14.datamodule - ptbench.data.padchest.datamodule - ptbench.data.shenzhen.datamodule - ptbench.data.tbpoc.datamodule - ptbench.data.tbx11k.datamodule - - -.. _ptbench.api.remixdata: - -Remixed Datamodules -------------------- - -Pytorch_ :py:class:`torch.utils.data.DataLoader` access through lightning_ -:py:class:`lightning.pytorch.core.LightningDataModule`. - -.. autosummary:: - :toctree: api/data/raw - - ptbench.data.montgomery_shenzhen.datamodule - ptbench.data.montgomery_shenzhen_indian.datamodule - ptbench.data.montgomery_shenzhen_indian_tbx11k.datamodule - ptbench.data.montgomery_shenzhen_indian_padchest.datamodule - ptbench.data.nih_cxr14_padchest.datamodule - .. _ptbench.api.models: diff --git a/doc/config.rst b/doc/config.rst index cedc8c07..93c4559a 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -13,68 +13,86 @@ datamodules. .. _ptbench.config.models: -Models -====== +Pre-configured Models +===================== + +Pre-configured models you can readily use. .. autosummary:: - :toctree: api/models/config + :toctree: api/config.models :template: config.rst - ptbench.models.config.alexnet - ptbench.models.config.alexnet_pretrained - ptbench.models.config.densenet - ptbench.models.config.densenet_pretrained - ptbench.models.config.densenet_rs - ptbench.models.config.logistic_regression - ptbench.models.config.mlp - ptbench.models.config.pasa + ptbench.config.models.alexnet + ptbench.config.models.alexnet_pretrained + ptbench.config.models.densenet + ptbench.config.models.densenet_pretrained + ptbench.config.models.densenet_rs + ptbench.config.models.logistic_regression + ptbench.config.models.mlp + ptbench.config.models.pasa .. _ptbench.config.datamodules: -Preset Datamodules +DataModule support ================== -Datamodules include iterative accessors to raw data -(:ref:`ptbench.setup.databases`) including data pre-processing to a minimum -input standard, if applicable. Use these datamodules for training and evaluating -your models. +Base DataModules and raw data loaders for the various databases currently +supported in this package, for your reference. Each pre-configured data module +can receive the name of one or more splits as argument to build a fully +functional data module that can be used in training, prediction or testing. .. autosummary:: - :toctree: api/data/config - :template: config.rst + :toctree: api/config.datamodules - ptbench.data.indian.default - ptbench.data.montgomery.default - ptbench.data.nih_cxr14.default - ptbench.data.padchest.idiap - ptbench.data.shenzhen.default - ptbench.data.tbx11k.v1_healthy_vs_atb - ptbench.data.tbx11k.v2_others_vs_atb + ptbench.config.data.hivtb.datamodule + ptbench.config.data.indian.datamodule + ptbench.config.data.montgomery.datamodule + ptbench.config.data.montgomery_shenzhen.datamodule + ptbench.config.data.montgomery_shenzhen_indian.datamodule + ptbench.config.data.montgomery_shenzhen_indian_padchest.datamodule + ptbench.config.data.montgomery_shenzhen_indian_tbx11k.datamodule + ptbench.config.data.nih_cxr14.datamodule + ptbench.config.data.nih_cxr14_padchest.datamodule + ptbench.config.data.padchest.datamodule + ptbench.config.data.shenzhen.datamodule + ptbench.config.data.tbpoc.datamodule + ptbench.config.data.tbx11k.datamodule -.. _ptbench.config.datamodules.remix: +.. _ptbench.config.datamodule-instances: -Remix Datamodules -================= +Pre-configured DataModules +========================== -We provide some aggregated datamodules to facilitate cross-database development. +DataModules provide access to preset pytorch dataloaders for training, +validating, testing and running prediction tasks. Each of the pre-configured +DataModule is based on one (or more) of the :ref:`supported base data modules +<ptbench.config.datamodules>`. .. autosummary:: - :toctree: api/data/config + :toctree: api/config.datamodule-instances :template: config.rst - ptbench.data.montgomery_shenzhen.default - ptbench.data.montgomery_shenzhen_indian.default - ptbench.data.montgomery_shenzhen_indian_padchest.default - ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_healthy_vs_atb - ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_others_vs_atb - ptbench.data.nih_cxr14_padchest.idiap - - -.. _ptbench.config.datamodules.folds: - -Cross-validation Datamodules + ptbench.config.data.indian.default + ptbench.config.data.montgomery.default + ptbench.config.data.montgomery_shenzhen.default + ptbench.config.data.montgomery_shenzhen_indian.default + ptbench.config.data.montgomery_shenzhen_indian_padchest.default + ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_healthy_vs_atb + ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_others_vs_atb + ptbench.config.data.nih_cxr14.default + ptbench.config.data.nih_cxr14_padchest.idiap + ptbench.config.data.padchest.idiap + ptbench.config.data.shenzhen.default + ptbench.config.data.tbx11k.v1_healthy_vs_atb + ptbench.config.data.tbx11k.v2_others_vs_atb + ptbench.config.data.tbx11k.v2_others_vs_atb + + +.. _ptbench.config.datamodule-instances.folds: + +Cross-validation DataModules ============================ We support cross-validation with precise preset folds. In this section, you @@ -84,19 +102,20 @@ datamodules. Nine other folds are available for every configuration (from 1 to .. autosummary:: - :toctree: api/data/config + :toctree: api/config.datamodule-folds :template: config.rst - ptbench.data.hivtb.fold_0 - ptbench.data.indian.fold_0 - ptbench.data.montgomery.fold_0 - ptbench.data.montgomery_shenzhen.fold_0 - ptbench.data.montgomery_shenzhen_indian.fold_0 - ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_0 - ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_0 - ptbench.data.shenzhen.fold_0 - ptbench.data.tbpoc.fold_0 - ptbench.data.tbx11k.v1_fold_0 - ptbench.data.tbx11k.v2_fold_0 + ptbench.config.data.hivtb.fold_0 + ptbench.config.data.indian.fold_0 + ptbench.config.data.montgomery.fold_0 + ptbench.config.data.montgomery_shenzhen.fold_0 + ptbench.config.data.montgomery_shenzhen_indian.fold_0 + ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_0 + ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_0 + ptbench.config.data.shenzhen.fold_0 + ptbench.config.data.tbpoc.fold_0 + ptbench.config.data.tbx11k.v1_fold_0 + ptbench.config.data.tbx11k.v2_fold_0 + .. include:: links.rst diff --git a/doc/links.rst b/doc/links.rst index 2e454082..f4ba3310 100644 --- a/doc/links.rst +++ b/doc/links.rst @@ -25,6 +25,6 @@ .. models .. _imagenet: https://www.image-net.org .. _alexnet: https://en.wikipedia.org/wiki/AlexNet -.. _alexnet_pytorch: https://pytorch.org/hub/pytorch_vision_alexnet/ +.. _alexnet-pytorch: https://pytorch.org/hub/pytorch_vision_alexnet/ .. _densenet: https://arxiv.org/abs/1608.06993 -.. _densenet_pytorch: https://pytorch.org/hub/pytorch_vision_densenet/ +.. _densenet-pytorch: https://pytorch.org/hub/pytorch_vision_densenet/ diff --git a/doc/results/index.rst b/doc/results/index.rst index 0217fe6c..0585e912 100644 --- a/doc/results/index.rst +++ b/doc/results/index.rst @@ -113,37 +113,37 @@ Thresholds used: :scale: 50% :alt: Testing sets ROC curves for Pasa model trained on normalized-kfold MC - :py:mod:`Pasa <ptbench.models.config.pasa>`: Pasa trained on normalized-kfold MC + :py:mod:`Pasa <ptbench.config.models.pasa>`: Pasa trained on normalized-kfold MC - .. figure:: img/compare_pasa_mc_ch_kfold_500.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for Pasa model trained on normalized-kfold MC-CH - :py:mod:`Pasa <ptbench.models.config.pasa>`: Pasa trained on normalized-kfold MC-CH + :py:mod:`Pasa <ptbench.config.models.pasa>`: Pasa trained on normalized-kfold MC-CH - .. figure:: img/compare_pasa_mc_ch_in_kfold_500.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for Pasa model trained on normalized-kfold MC-CH-IN - :py:mod:`Pasa <ptbench.models.config.pasa>`: Pasa trained on normalized-kfold MC-CH-IN + :py:mod:`Pasa <ptbench.config.models.pasa>`: Pasa trained on normalized-kfold MC-CH-IN * - .. figure:: img/compare_densenet_mc_kfold_2000.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for DenseNet model trained on normalized-kfold MC - :py:mod:`DenseNet <ptbench.models.config.densenet>`: DenseNet trained on normalized-kfold MC + :py:mod:`DenseNet <ptbench.config.models.densenet>`: DenseNet trained on normalized-kfold MC - .. figure:: img/compare_densenet_mc_ch_kfold_2000.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for DenseNet model trained on normalized-kfold MC-CH - :py:mod:`DenseNet <ptbench.models.config.densenet>`: DenseNet trained on normalized-kfold MC-CH + :py:mod:`DenseNet <ptbench.config.models.densenet>`: DenseNet trained on normalized-kfold MC-CH - .. figure:: img/compare_densenet_mc_ch_in_kfold_2000.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for DenseNet model trained on normalized-kfold MC-CH-IN - :py:mod:`DenseNet <ptbench.models.config.densenet>`: DenseNet trained on normalized-kfold MC-CH-IN + :py:mod:`DenseNet <ptbench.config.models.densenet>`: DenseNet trained on normalized-kfold MC-CH-IN DenseNet-121 (pretrained on ImageNet) """"""""""""""""""""""""""""""""""""" @@ -180,19 +180,19 @@ Thresholds used: :scale: 50% :alt: Testing sets ROC curves for DenseNet model trained on normalized-kfold MC - :py:mod:`DenseNet <ptbench.models.config.densenet>` DenseNet trained on normalized-kfold MC + :py:mod:`DenseNet <ptbench.config.models.densenet>` DenseNet trained on normalized-kfold MC - .. figure:: img/compare_densenetpreIN_mc_ch_kfold_600.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for DenseNet model trained on normalized-kfold MC-CH - :py:mod:`DenseNet <ptbench.models.config.densenet>` DenseNet trained on normalized-kfold MC-CH + :py:mod:`DenseNet <ptbench.config.models.densenet>` DenseNet trained on normalized-kfold MC-CH - .. figure:: img/compare_densenetpreIN_mc_ch_ch_kfold_600.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for DenseNet model trained on normalized-kfold MC-CH-IN - :py:mod:`DenseNet <ptbench.models.config.densenet>` DenseNet trained on normalized-kfold MC-CH-IN + :py:mod:`DenseNet <ptbench.config.models.densenet>` DenseNet trained on normalized-kfold MC-CH-IN Logistic Regression Classifier """""""""""""""""""""""""""""" @@ -229,19 +229,19 @@ Thresholds used: :scale: 50% :alt: Testing sets ROC curves for LogReg model trained on normalized-kfold MC - :py:mod:`LogReg <ptbench.models.config.logistic_regression>`: LogReg trained on normalized-kfold MC + :py:mod:`LogReg <ptbench.config.models.logistic_regression>`: LogReg trained on normalized-kfold MC - .. figure:: img/compare_logreg_mc_ch_kfold_100.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for LogReg model trained on normalized-kfold MC-CH - :py:mod:`LogReg <ptbench.models.config.logistic_regression>`: LogReg trained on normalized-kfold MC-CH + :py:mod:`LogReg <ptbench.config.models.logistic_regression>`: LogReg trained on normalized-kfold MC-CH - .. figure:: img/compare_logreg_mc_ch_in_kfold_100.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for LogReg model trained on normalized-kfold MC-CH-IN - :py:mod:`LogReg <ptbench.models.config.logistic_regression>`: LogReg trained on normalized-kfold MC-CH-IN + :py:mod:`LogReg <ptbench.config.models.logistic_regression>`: LogReg trained on normalized-kfold MC-CH-IN DenseNet-121 (pretrained on ImageNet and NIH CXR14) """"""""""""""""""""""""""""""""""""""""""""""""""" @@ -278,19 +278,19 @@ Thresholds used: :scale: 50% :alt: Testing sets ROC curves for DenseNet model trained on normalized-kfold MC (pretrained on NIH) - :py:mod:`DenseNet <ptbench.models.config.densenet>`: DenseNet trained on normalized-kfold MC (pretrained on NIH) + :py:mod:`DenseNet <ptbench.config.models.densenet>`: DenseNet trained on normalized-kfold MC (pretrained on NIH) - .. figure:: img/compare_densenetpre_mc_ch_kfold_300.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for DenseNet model trained on normalized-kfold MC-CH (pretrained on NIH) - :py:mod:`DenseNet <ptbench.models.config.densenet>`: DenseNet trained on normalized-kfold MC-CH (pretrained on NIH) + :py:mod:`DenseNet <ptbench.config.models.densenet>`: DenseNet trained on normalized-kfold MC-CH (pretrained on NIH) - .. figure:: img/compare_densenetpre_mc_ch_in_kfold_300.jpg :align: center :scale: 50% :alt: Testing sets ROC curves for DenseNet model trained on normalized-kfold MC-CH-IN (pretrained on NIH) - :py:mod:`DenseNet <ptbench.models.config.densenet>`: DenseNet trained on normalized-kfold MC-CH-IN (pretrained on NIH) + :py:mod:`DenseNet <ptbench.config.models.densenet>`: DenseNet trained on normalized-kfold MC-CH-IN (pretrained on NIH) Global sensitivity analysis (relevance) diff --git a/doc/usage/evaluation.rst b/doc/usage/evaluation.rst index 8d98ca92..1778e126 100644 --- a/doc/usage/evaluation.rst +++ b/doc/usage/evaluation.rst @@ -35,7 +35,7 @@ the pre-trained model. .. tip:: An option to generate grad-CAMs is available for the :py:mod:`DensenetRS - <ptbench.models.config.densenet_rs>` model. To activate it, use the + <ptbench.config.models.densenet_rs>` model. To activate it, use the ``--grad-cams`` argument. .. tip:: diff --git a/pyproject.toml b/pyproject.toml index f2de6fd4..8ebe16e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ dependencies = [ "torch>=1.8", "torchvision>=0.10", "lightning>=2.0.3", - "pydantic <2.0,>=1.7.4", # temporary, until issue #31 is fixed + "pydantic <2.0,>=1.7.4", # temporary, until issue #31 is fixed "tensorboard", ] @@ -70,168 +70,168 @@ ptbench = "ptbench.scripts.cli:cli" [project.entry-points."ptbench.config"] # models -pasa = "ptbench.models.config.pasa" -mlp = "ptbench.models.config.mlp" -logistic-regression = "ptbench.models.config.logistic_regression" -alexnet = "ptbench.models.config.alexnet" -alexnet-pretrained = "ptbench.models.config.alexnet_pretrained" -densenet = "ptbench.models.config.densenet" -densenet-pretrained = "ptbench.models.config.densenet_pretrained" +pasa = "ptbench.config.models.pasa" +mlp = "ptbench.config.models.mlp" +logistic-regression = "ptbench.config.models.logistic_regression" +alexnet = "ptbench.config.models.alexnet" +alexnet-pretrained = "ptbench.config.models.alexnet_pretrained" +densenet = "ptbench.config.models.densenet" +densenet-pretrained = "ptbench.config.models.densenet_pretrained" # montgomery dataset (and cross-validation folds) -montgomery = "ptbench.data.montgomery.default" -montgomery-f0 = "ptbench.data.montgomery.fold_0" -montgomery-f1 = "ptbench.data.montgomery.fold_1" -montgomery-f2 = "ptbench.data.montgomery.fold_2" -montgomery-f3 = "ptbench.data.montgomery.fold_3" -montgomery-f4 = "ptbench.data.montgomery.fold_4" -montgomery-f5 = "ptbench.data.montgomery.fold_5" -montgomery-f6 = "ptbench.data.montgomery.fold_6" -montgomery-f7 = "ptbench.data.montgomery.fold_7" -montgomery-f8 = "ptbench.data.montgomery.fold_8" -montgomery-f9 = "ptbench.data.montgomery.fold_9" +montgomery = "ptbench.config.data.montgomery.default" +montgomery-f0 = "ptbench.config.data.montgomery.fold_0" +montgomery-f1 = "ptbench.config.data.montgomery.fold_1" +montgomery-f2 = "ptbench.config.data.montgomery.fold_2" +montgomery-f3 = "ptbench.config.data.montgomery.fold_3" +montgomery-f4 = "ptbench.config.data.montgomery.fold_4" +montgomery-f5 = "ptbench.config.data.montgomery.fold_5" +montgomery-f6 = "ptbench.config.data.montgomery.fold_6" +montgomery-f7 = "ptbench.config.data.montgomery.fold_7" +montgomery-f8 = "ptbench.config.data.montgomery.fold_8" +montgomery-f9 = "ptbench.config.data.montgomery.fold_9" # shenzhen dataset (and cross-validation folds) -shenzhen = "ptbench.data.shenzhen.default" -shenzhen-f0 = "ptbench.data.shenzhen.fold_0" -shenzhen-f1 = "ptbench.data.shenzhen.fold_1" -shenzhen-f2 = "ptbench.data.shenzhen.fold_2" -shenzhen-f3 = "ptbench.data.shenzhen.fold_3" -shenzhen-f4 = "ptbench.data.shenzhen.fold_4" -shenzhen-f5 = "ptbench.data.shenzhen.fold_5" -shenzhen-f6 = "ptbench.data.shenzhen.fold_6" -shenzhen-f7 = "ptbench.data.shenzhen.fold_7" -shenzhen-f8 = "ptbench.data.shenzhen.fold_8" -shenzhen-f9 = "ptbench.data.shenzhen.fold_9" +shenzhen = "ptbench.config.data.shenzhen.default" +shenzhen-f0 = "ptbench.config.data.shenzhen.fold_0" +shenzhen-f1 = "ptbench.config.data.shenzhen.fold_1" +shenzhen-f2 = "ptbench.config.data.shenzhen.fold_2" +shenzhen-f3 = "ptbench.config.data.shenzhen.fold_3" +shenzhen-f4 = "ptbench.config.data.shenzhen.fold_4" +shenzhen-f5 = "ptbench.config.data.shenzhen.fold_5" +shenzhen-f6 = "ptbench.config.data.shenzhen.fold_6" +shenzhen-f7 = "ptbench.config.data.shenzhen.fold_7" +shenzhen-f8 = "ptbench.config.data.shenzhen.fold_8" +shenzhen-f9 = "ptbench.config.data.shenzhen.fold_9" # indian dataset (and cross-validation folds) -indian = "ptbench.data.indian.default" -indian-f0 = "ptbench.data.indian.fold_0" -indian-f1 = "ptbench.data.indian.fold_1" -indian-f2 = "ptbench.data.indian.fold_2" -indian-f3 = "ptbench.data.indian.fold_3" -indian-f4 = "ptbench.data.indian.fold_4" -indian-f5 = "ptbench.data.indian.fold_5" -indian-f6 = "ptbench.data.indian.fold_6" -indian-f7 = "ptbench.data.indian.fold_7" -indian-f8 = "ptbench.data.indian.fold_8" -indian-f9 = "ptbench.data.indian.fold_9" +indian = "ptbench.config.data.indian.default" +indian-f0 = "ptbench.config.data.indian.fold_0" +indian-f1 = "ptbench.config.data.indian.fold_1" +indian-f2 = "ptbench.config.data.indian.fold_2" +indian-f3 = "ptbench.config.data.indian.fold_3" +indian-f4 = "ptbench.config.data.indian.fold_4" +indian-f5 = "ptbench.config.data.indian.fold_5" +indian-f6 = "ptbench.config.data.indian.fold_6" +indian-f7 = "ptbench.config.data.indian.fold_7" +indian-f8 = "ptbench.config.data.indian.fold_8" +indian-f9 = "ptbench.config.data.indian.fold_9" # TBX11K dataset split 1: healthy vs active tb, and cross-validation folds -tbx11k-v1-healthy-vs-atb = "ptbench.data.tbx11k.v1_healthy_vs_atb" -tbx11k-v1-f0 = "ptbench.data.tbx11k.v1_fold_0" -tbx11k-v1-f1 = "ptbench.data.tbx11k.v1_fold_1" -tbx11k-v1-f2 = "ptbench.data.tbx11k.v1_fold_2" -tbx11k-v1-f3 = "ptbench.data.tbx11k.v1_fold_3" -tbx11k-v1-f4 = "ptbench.data.tbx11k.v1_fold_4" -tbx11k-v1-f5 = "ptbench.data.tbx11k.v1_fold_5" -tbx11k-v1-f6 = "ptbench.data.tbx11k.v1_fold_6" -tbx11k-v1-f7 = "ptbench.data.tbx11k.v1_fold_7" -tbx11k-v1-f8 = "ptbench.data.tbx11k.v1_fold_8" -tbx11k-v1-f9 = "ptbench.data.tbx11k.v1_fold_9" +tbx11k-v1-healthy-vs-atb = "ptbench.config.data.tbx11k.v1_healthy_vs_atb" +tbx11k-v1-f0 = "ptbench.config.data.tbx11k.v1_fold_0" +tbx11k-v1-f1 = "ptbench.config.data.tbx11k.v1_fold_1" +tbx11k-v1-f2 = "ptbench.config.data.tbx11k.v1_fold_2" +tbx11k-v1-f3 = "ptbench.config.data.tbx11k.v1_fold_3" +tbx11k-v1-f4 = "ptbench.config.data.tbx11k.v1_fold_4" +tbx11k-v1-f5 = "ptbench.config.data.tbx11k.v1_fold_5" +tbx11k-v1-f6 = "ptbench.config.data.tbx11k.v1_fold_6" +tbx11k-v1-f7 = "ptbench.config.data.tbx11k.v1_fold_7" +tbx11k-v1-f8 = "ptbench.config.data.tbx11k.v1_fold_8" +tbx11k-v1-f9 = "ptbench.config.data.tbx11k.v1_fold_9" # TBX11K dataset split 2: others vs active tb, and cross-validation folds -tbx11k-v2-others-vs-atb = "ptbench.data.tbx11k.v2_others_vs_atb" -tbx11k-v2-f0 = "ptbench.data.tbx11k.v2_fold_0" -tbx11k-v2-f1 = "ptbench.data.tbx11k.v2_fold_1" -tbx11k-v2-f2 = "ptbench.data.tbx11k.v2_fold_2" -tbx11k-v2-f3 = "ptbench.data.tbx11k.v2_fold_3" -tbx11k-v2-f4 = "ptbench.data.tbx11k.v2_fold_4" -tbx11k-v2-f5 = "ptbench.data.tbx11k.v2_fold_5" -tbx11k-v2-f6 = "ptbench.data.tbx11k.v2_fold_6" -tbx11k-v2-f7 = "ptbench.data.tbx11k.v2_fold_7" -tbx11k-v2-f8 = "ptbench.data.tbx11k.v2_fold_8" -tbx11k-v2-f9 = "ptbench.data.tbx11k.v2_fold_9" +tbx11k-v2-others-vs-atb = "ptbench.config.data.tbx11k.v2_others_vs_atb" +tbx11k-v2-f0 = "ptbench.config.data.tbx11k.v2_fold_0" +tbx11k-v2-f1 = "ptbench.config.data.tbx11k.v2_fold_1" +tbx11k-v2-f2 = "ptbench.config.data.tbx11k.v2_fold_2" +tbx11k-v2-f3 = "ptbench.config.data.tbx11k.v2_fold_3" +tbx11k-v2-f4 = "ptbench.config.data.tbx11k.v2_fold_4" +tbx11k-v2-f5 = "ptbench.config.data.tbx11k.v2_fold_5" +tbx11k-v2-f6 = "ptbench.config.data.tbx11k.v2_fold_6" +tbx11k-v2-f7 = "ptbench.config.data.tbx11k.v2_fold_7" +tbx11k-v2-f8 = "ptbench.config.data.tbx11k.v2_fold_8" +tbx11k-v2-f9 = "ptbench.config.data.tbx11k.v2_fold_9" # montgomery-shenzhen aggregated dataset -montgomery-shenzhen = "ptbench.data.montgomery_shenzhen.default" -montgomery-shenzhen-f0 = "ptbench.data.montgomery_shenzhen.fold_0" -montgomery-shenzhen-f1 = "ptbench.data.montgomery_shenzhen.fold_1" -montgomery-shenzhen-f2 = "ptbench.data.montgomery_shenzhen.fold_2" -montgomery-shenzhen-f3 = "ptbench.data.montgomery_shenzhen.fold_3" -montgomery-shenzhen-f4 = "ptbench.data.montgomery_shenzhen.fold_4" -montgomery-shenzhen-f5 = "ptbench.data.montgomery_shenzhen.fold_5" -montgomery-shenzhen-f6 = "ptbench.data.montgomery_shenzhen.fold_6" -montgomery-shenzhen-f7 = "ptbench.data.montgomery_shenzhen.fold_7" -montgomery-shenzhen-f8 = "ptbench.data.montgomery_shenzhen.fold_8" -montgomery-shenzhen-f9 = "ptbench.data.montgomery_shenzhen.fold_9" +montgomery-shenzhen = "ptbench.config.data.montgomery_shenzhen.default" +montgomery-shenzhen-f0 = "ptbench.config.data.montgomery_shenzhen.fold_0" +montgomery-shenzhen-f1 = "ptbench.config.data.montgomery_shenzhen.fold_1" +montgomery-shenzhen-f2 = "ptbench.config.data.montgomery_shenzhen.fold_2" +montgomery-shenzhen-f3 = "ptbench.config.data.montgomery_shenzhen.fold_3" +montgomery-shenzhen-f4 = "ptbench.config.data.montgomery_shenzhen.fold_4" +montgomery-shenzhen-f5 = "ptbench.config.data.montgomery_shenzhen.fold_5" +montgomery-shenzhen-f6 = "ptbench.config.data.montgomery_shenzhen.fold_6" +montgomery-shenzhen-f7 = "ptbench.config.data.montgomery_shenzhen.fold_7" +montgomery-shenzhen-f8 = "ptbench.config.data.montgomery_shenzhen.fold_8" +montgomery-shenzhen-f9 = "ptbench.config.data.montgomery_shenzhen.fold_9" # montgomery-shenzhen-indian aggregated dataset -montgomery-shenzhen-indian = "ptbench.data.montgomery_shenzhen_indian.default" -montgomery-shenzhen-indian-f0 = "ptbench.data.montgomery_shenzhen_indian.fold_0" -montgomery-shenzhen-indian-f1 = "ptbench.data.montgomery_shenzhen_indian.fold_1" -montgomery-shenzhen-indian-f2 = "ptbench.data.montgomery_shenzhen_indian.fold_2" -montgomery-shenzhen-indian-f3 = "ptbench.data.montgomery_shenzhen_indian.fold_3" -montgomery-shenzhen-indian-f4 = "ptbench.data.montgomery_shenzhen_indian.fold_4" -montgomery-shenzhen-indian-f5 = "ptbench.data.montgomery_shenzhen_indian.fold_5" -montgomery-shenzhen-indian-f6 = "ptbench.data.montgomery_shenzhen_indian.fold_6" -montgomery-shenzhen-indian-f7 = "ptbench.data.montgomery_shenzhen_indian.fold_7" -montgomery-shenzhen-indian-f8 = "ptbench.data.montgomery_shenzhen_indian.fold_8" -montgomery-shenzhen-indian-f9 = "ptbench.data.montgomery_shenzhen_indian.fold_9" +montgomery-shenzhen-indian = "ptbench.config.data.montgomery_shenzhen_indian.default" +montgomery-shenzhen-indian-f0 = "ptbench.config.data.montgomery_shenzhen_indian.fold_0" +montgomery-shenzhen-indian-f1 = "ptbench.config.data.montgomery_shenzhen_indian.fold_1" +montgomery-shenzhen-indian-f2 = "ptbench.config.data.montgomery_shenzhen_indian.fold_2" +montgomery-shenzhen-indian-f3 = "ptbench.config.data.montgomery_shenzhen_indian.fold_3" +montgomery-shenzhen-indian-f4 = "ptbench.config.data.montgomery_shenzhen_indian.fold_4" +montgomery-shenzhen-indian-f5 = "ptbench.config.data.montgomery_shenzhen_indian.fold_5" +montgomery-shenzhen-indian-f6 = "ptbench.config.data.montgomery_shenzhen_indian.fold_6" +montgomery-shenzhen-indian-f7 = "ptbench.config.data.montgomery_shenzhen_indian.fold_7" +montgomery-shenzhen-indian-f8 = "ptbench.config.data.montgomery_shenzhen_indian.fold_8" +montgomery-shenzhen-indian-f9 = "ptbench.config.data.montgomery_shenzhen_indian.fold_9" # montgomery-shenzhen-indian-tbx11k aggregated dataset -montgomery-shenzhen-indian-tbx11k-v1 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_healthy_vs_atb" -montgomery-shenzhen-indian-tbx11k-v1-f0 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_0" -montgomery-shenzhen-indian-tbx11k-v1-f1 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_1" -montgomery-shenzhen-indian-tbx11k-v1-f2 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_2" -montgomery-shenzhen-indian-tbx11k-v1-f3 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_3" -montgomery-shenzhen-indian-tbx11k-v1-f4 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_4" -montgomery-shenzhen-indian-tbx11k-v1-f5 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_5" -montgomery-shenzhen-indian-tbx11k-v1-f6 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_6" -montgomery-shenzhen-indian-tbx11k-v1-f7 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_7" -montgomery-shenzhen-indian-tbx11k-v1-f8 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_8" -montgomery-shenzhen-indian-tbx11k-v1-f9 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_9" -montgomery-shenzhen-indian-tbx11k-v2 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_others_vs_atb" -montgomery-shenzhen-indian-tbx11k-v2-f0 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_0" -montgomery-shenzhen-indian-tbx11k-v2-f1 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_1" -montgomery-shenzhen-indian-tbx11k-v2-f2 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_2" -montgomery-shenzhen-indian-tbx11k-v2-f3 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_3" -montgomery-shenzhen-indian-tbx11k-v2-f4 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_4" -montgomery-shenzhen-indian-tbx11k-v2-f5 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_5" -montgomery-shenzhen-indian-tbx11k-v2-f6 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_6" -montgomery-shenzhen-indian-tbx11k-v2-f7 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_7" -montgomery-shenzhen-indian-tbx11k-v2-f8 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_8" -montgomery-shenzhen-indian-tbx11k-v2-f9 = "ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_9" +montgomery-shenzhen-indian-tbx11k-v1 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_healthy_vs_atb" +montgomery-shenzhen-indian-tbx11k-v1-f0 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_0" +montgomery-shenzhen-indian-tbx11k-v1-f1 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_1" +montgomery-shenzhen-indian-tbx11k-v1-f2 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_2" +montgomery-shenzhen-indian-tbx11k-v1-f3 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_3" +montgomery-shenzhen-indian-tbx11k-v1-f4 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_4" +montgomery-shenzhen-indian-tbx11k-v1-f5 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_5" +montgomery-shenzhen-indian-tbx11k-v1-f6 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_6" +montgomery-shenzhen-indian-tbx11k-v1-f7 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_7" +montgomery-shenzhen-indian-tbx11k-v1-f8 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_8" +montgomery-shenzhen-indian-tbx11k-v1-f9 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v1_fold_9" +montgomery-shenzhen-indian-tbx11k-v2 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_others_vs_atb" +montgomery-shenzhen-indian-tbx11k-v2-f0 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_0" +montgomery-shenzhen-indian-tbx11k-v2-f1 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_1" +montgomery-shenzhen-indian-tbx11k-v2-f2 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_2" +montgomery-shenzhen-indian-tbx11k-v2-f3 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_3" +montgomery-shenzhen-indian-tbx11k-v2-f4 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_4" +montgomery-shenzhen-indian-tbx11k-v2-f5 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_5" +montgomery-shenzhen-indian-tbx11k-v2-f6 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_6" +montgomery-shenzhen-indian-tbx11k-v2-f7 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_7" +montgomery-shenzhen-indian-tbx11k-v2-f8 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_8" +montgomery-shenzhen-indian-tbx11k-v2-f9 = "ptbench.config.data.montgomery_shenzhen_indian_tbx11k.v2_fold_9" # tbpoc dataset (only cross-validation folds) -tbpoc-f0 = "ptbench.data.tbpoc.fold_0" -tbpoc-f1 = "ptbench.data.tbpoc.fold_1" -tbpoc-f2 = "ptbench.data.tbpoc.fold_2" -tbpoc-f3 = "ptbench.data.tbpoc.fold_3" -tbpoc-f4 = "ptbench.data.tbpoc.fold_4" -tbpoc-f5 = "ptbench.data.tbpoc.fold_5" -tbpoc-f6 = "ptbench.data.tbpoc.fold_6" -tbpoc-f7 = "ptbench.data.tbpoc.fold_7" -tbpoc-f8 = "ptbench.data.tbpoc.fold_8" -tbpoc-f9 = "ptbench.data.tbpoc.fold_9" +tbpoc-f0 = "ptbench.config.data.tbpoc.fold_0" +tbpoc-f1 = "ptbench.config.data.tbpoc.fold_1" +tbpoc-f2 = "ptbench.config.data.tbpoc.fold_2" +tbpoc-f3 = "ptbench.config.data.tbpoc.fold_3" +tbpoc-f4 = "ptbench.config.data.tbpoc.fold_4" +tbpoc-f5 = "ptbench.config.data.tbpoc.fold_5" +tbpoc-f6 = "ptbench.config.data.tbpoc.fold_6" +tbpoc-f7 = "ptbench.config.data.tbpoc.fold_7" +tbpoc-f8 = "ptbench.config.data.tbpoc.fold_8" +tbpoc-f9 = "ptbench.config.data.tbpoc.fold_9" # hivtb dataset (only cross-validation folds) -hivtb-f0 = "ptbench.data.hivtb.fold_0" -hivtb-f1 = "ptbench.data.hivtb.fold_1" -hivtb-f2 = "ptbench.data.hivtb.fold_2" -hivtb-f3 = "ptbench.data.hivtb.fold_3" -hivtb-f4 = "ptbench.data.hivtb.fold_4" -hivtb-f5 = "ptbench.data.hivtb.fold_5" -hivtb-f6 = "ptbench.data.hivtb.fold_6" -hivtb-f7 = "ptbench.data.hivtb.fold_7" -hivtb-f8 = "ptbench.data.hivtb.fold_8" -hivtb-f9 = "ptbench.data.hivtb.fold_9" +hivtb-f0 = "ptbench.config.data.hivtb.fold_0" +hivtb-f1 = "ptbench.config.data.hivtb.fold_1" +hivtb-f2 = "ptbench.config.data.hivtb.fold_2" +hivtb-f3 = "ptbench.config.data.hivtb.fold_3" +hivtb-f4 = "ptbench.config.data.hivtb.fold_4" +hivtb-f5 = "ptbench.config.data.hivtb.fold_5" +hivtb-f6 = "ptbench.config.data.hivtb.fold_6" +hivtb-f7 = "ptbench.config.data.hivtb.fold_7" +hivtb-f8 = "ptbench.config.data.hivtb.fold_8" +hivtb-f9 = "ptbench.config.data.hivtb.fold_9" # NIH CXR14 (relabeled), multi-class (14 labels) -nih-cxr14 = "ptbench.data.nih_cxr14.default" -nih-cxr14-cardiomegaly = "ptbench.data.nih_cxr14.cardiomegaly" +nih-cxr14 = "ptbench.config.data.nih_cxr14.default" +nih-cxr14-cardiomegaly = "ptbench.config.data.nih_cxr14.cardiomegaly" # PadChest, multi-class (varied number of labels) -padchest-idiap = "ptbench.data.padchest.idiap" -padchest-tb-idiap = "ptbench.data.padchest.tb_idiap" -padchest-no-tb-idiap = "ptbench.data.padchest.no_tb_idiap" -padchest-cardiomegaly-idiap = "ptbench.data.padchest.cardiomegaly_idiap" +padchest-idiap = "ptbench.config.data.padchest.idiap" +padchest-tb-idiap = "ptbench.config.data.padchest.tb_idiap" +padchest-no-tb-idiap = "ptbench.config.data.padchest.no_tb_idiap" +padchest-cardiomegaly-idiap = "ptbench.config.data.padchest.cardiomegaly_idiap" # NIH CXR14 / PadChest aggregated dataset -nih-cxr14-padchest = "ptbench.data.nih_cxr14_padchest.idiap" +nih-cxr14-padchest = "ptbench.config.data.nih_cxr14_padchest.idiap" # montgomery-shenzhen-indian-padchest aggregated dataset -montgomery-shenzhen-indian-padchest = "ptbench.data.montgomery_shenzhen_indian_padchest.default" +montgomery-shenzhen-indian-padchest = "ptbench.config.data.montgomery_shenzhen_indian_padchest.default" [tool.setuptools] zip-safe = true diff --git a/src/ptbench/data/hivtb/__init__.py b/src/ptbench/config/__init__.py similarity index 100% rename from src/ptbench/data/hivtb/__init__.py rename to src/ptbench/config/__init__.py diff --git a/src/ptbench/data/indian/__init__.py b/src/ptbench/config/data/hivtb/__init__.py similarity index 100% rename from src/ptbench/data/indian/__init__.py rename to src/ptbench/config/data/hivtb/__init__.py diff --git a/src/ptbench/data/hivtb/datamodule.py b/src/ptbench/config/data/hivtb/datamodule.py similarity index 85% rename from src/ptbench/data/hivtb/datamodule.py rename to src/ptbench/config/data/hivtb/datamodule.py index 2c68c85d..653743a5 100644 --- a/src/ptbench/data/hivtb/datamodule.py +++ b/src/ptbench/config/data/hivtb/datamodule.py @@ -14,13 +14,17 @@ import PIL.Image from torchvision.transforms.functional import center_crop, to_tensor -from ...utils.rc import load_rc -from ..datamodule import CachingDataModule -from ..image_utils import remove_black_borders -from ..split import JSONDatabaseSplit -from ..typing import DatabaseSplit -from ..typing import RawDataLoader as _BaseRawDataLoader -from ..typing import Sample +from ptbench.data.datamodule import CachingDataModule +from ptbench.data.image_utils import remove_black_borders +from ptbench.data.split import JSONDatabaseSplit +from ptbench.data.typing import DatabaseSplit +from ptbench.data.typing import RawDataLoader as _BaseRawDataLoader +from ptbench.data.typing import Sample +from ptbench.utils.rc import load_rc + +CONFIGURATION_KEY_DATADIR = "datadir." + (__name__.rsplit(".", 2)[-2]) +"""Key to search for in the configuration file for the root directory of this +database.""" class RawDataLoader(_BaseRawDataLoader): @@ -32,7 +36,7 @@ class RawDataLoader(_BaseRawDataLoader): def __init__(self): self.datadir = load_rc().get( - "datadir.hivtb", os.path.realpath(os.curdir) + CONFIGURATION_KEY_DATADIR, os.path.realpath(os.curdir) ) def sample(self, sample: tuple[str, int]) -> Sample: diff --git a/src/ptbench/data/hivtb/fold-0.json b/src/ptbench/config/data/hivtb/fold-0.json similarity index 100% rename from src/ptbench/data/hivtb/fold-0.json rename to src/ptbench/config/data/hivtb/fold-0.json diff --git a/src/ptbench/data/hivtb/fold-1.json b/src/ptbench/config/data/hivtb/fold-1.json similarity index 100% rename from src/ptbench/data/hivtb/fold-1.json rename to src/ptbench/config/data/hivtb/fold-1.json diff --git a/src/ptbench/data/hivtb/fold-2.json b/src/ptbench/config/data/hivtb/fold-2.json similarity index 100% rename from src/ptbench/data/hivtb/fold-2.json rename to src/ptbench/config/data/hivtb/fold-2.json diff --git a/src/ptbench/data/hivtb/fold-3.json b/src/ptbench/config/data/hivtb/fold-3.json similarity index 100% rename from src/ptbench/data/hivtb/fold-3.json rename to src/ptbench/config/data/hivtb/fold-3.json diff --git a/src/ptbench/data/hivtb/fold-4.json b/src/ptbench/config/data/hivtb/fold-4.json similarity index 100% rename from src/ptbench/data/hivtb/fold-4.json rename to src/ptbench/config/data/hivtb/fold-4.json diff --git a/src/ptbench/data/hivtb/fold-5.json b/src/ptbench/config/data/hivtb/fold-5.json similarity index 100% rename from src/ptbench/data/hivtb/fold-5.json rename to src/ptbench/config/data/hivtb/fold-5.json diff --git a/src/ptbench/data/hivtb/fold-6.json b/src/ptbench/config/data/hivtb/fold-6.json similarity index 100% rename from src/ptbench/data/hivtb/fold-6.json rename to src/ptbench/config/data/hivtb/fold-6.json diff --git a/src/ptbench/data/hivtb/fold-7.json b/src/ptbench/config/data/hivtb/fold-7.json similarity index 100% rename from src/ptbench/data/hivtb/fold-7.json rename to src/ptbench/config/data/hivtb/fold-7.json diff --git a/src/ptbench/data/hivtb/fold-8.json b/src/ptbench/config/data/hivtb/fold-8.json similarity index 100% rename from src/ptbench/data/hivtb/fold-8.json rename to src/ptbench/config/data/hivtb/fold-8.json diff --git a/src/ptbench/data/hivtb/fold-9.json b/src/ptbench/config/data/hivtb/fold-9.json similarity index 100% rename from src/ptbench/data/hivtb/fold-9.json rename to src/ptbench/config/data/hivtb/fold-9.json diff --git a/src/ptbench/data/hivtb/fold_0.py b/src/ptbench/config/data/hivtb/fold_0.py similarity index 65% rename from src/ptbench/data/hivtb/fold_0.py rename to src/ptbench/config/data/hivtb/fold_0.py index c8a11de1..4e00590f 100644 --- a/src/ptbench/data/hivtb/fold_0.py +++ b/src/ptbench/config/data/hivtb/fold_0.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-0.json") diff --git a/src/ptbench/data/hivtb/fold_1.py b/src/ptbench/config/data/hivtb/fold_1.py similarity index 65% rename from src/ptbench/data/hivtb/fold_1.py rename to src/ptbench/config/data/hivtb/fold_1.py index 3b2434e0..55333dd0 100644 --- a/src/ptbench/data/hivtb/fold_1.py +++ b/src/ptbench/config/data/hivtb/fold_1.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-1.json") diff --git a/src/ptbench/data/hivtb/fold_2.py b/src/ptbench/config/data/hivtb/fold_2.py similarity index 65% rename from src/ptbench/data/hivtb/fold_2.py rename to src/ptbench/config/data/hivtb/fold_2.py index ac95eca1..5c8fd9b7 100644 --- a/src/ptbench/data/hivtb/fold_2.py +++ b/src/ptbench/config/data/hivtb/fold_2.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-2.json") diff --git a/src/ptbench/data/hivtb/fold_3.py b/src/ptbench/config/data/hivtb/fold_3.py similarity index 65% rename from src/ptbench/data/hivtb/fold_3.py rename to src/ptbench/config/data/hivtb/fold_3.py index 1d662e27..5d1b308c 100644 --- a/src/ptbench/data/hivtb/fold_3.py +++ b/src/ptbench/config/data/hivtb/fold_3.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-3.json") diff --git a/src/ptbench/data/hivtb/fold_4.py b/src/ptbench/config/data/hivtb/fold_4.py similarity index 65% rename from src/ptbench/data/hivtb/fold_4.py rename to src/ptbench/config/data/hivtb/fold_4.py index 1f59dcf5..77c2073a 100644 --- a/src/ptbench/data/hivtb/fold_4.py +++ b/src/ptbench/config/data/hivtb/fold_4.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-4.json") diff --git a/src/ptbench/data/hivtb/fold_5.py b/src/ptbench/config/data/hivtb/fold_5.py similarity index 65% rename from src/ptbench/data/hivtb/fold_5.py rename to src/ptbench/config/data/hivtb/fold_5.py index 03170e28..e06f9dd1 100644 --- a/src/ptbench/data/hivtb/fold_5.py +++ b/src/ptbench/config/data/hivtb/fold_5.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-5.json") diff --git a/src/ptbench/data/hivtb/fold_6.py b/src/ptbench/config/data/hivtb/fold_6.py similarity index 65% rename from src/ptbench/data/hivtb/fold_6.py rename to src/ptbench/config/data/hivtb/fold_6.py index 9950b0df..4b7db6de 100644 --- a/src/ptbench/data/hivtb/fold_6.py +++ b/src/ptbench/config/data/hivtb/fold_6.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-6.json") diff --git a/src/ptbench/data/hivtb/fold_7.py b/src/ptbench/config/data/hivtb/fold_7.py similarity index 65% rename from src/ptbench/data/hivtb/fold_7.py rename to src/ptbench/config/data/hivtb/fold_7.py index 043ef9de..3670047c 100644 --- a/src/ptbench/data/hivtb/fold_7.py +++ b/src/ptbench/config/data/hivtb/fold_7.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-7.json") diff --git a/src/ptbench/data/hivtb/fold_8.py b/src/ptbench/config/data/hivtb/fold_8.py similarity index 65% rename from src/ptbench/data/hivtb/fold_8.py rename to src/ptbench/config/data/hivtb/fold_8.py index 9aa80c51..c0900d15 100644 --- a/src/ptbench/data/hivtb/fold_8.py +++ b/src/ptbench/config/data/hivtb/fold_8.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-8.json") diff --git a/src/ptbench/data/hivtb/fold_9.py b/src/ptbench/config/data/hivtb/fold_9.py similarity index 65% rename from src/ptbench/data/hivtb/fold_9.py rename to src/ptbench/config/data/hivtb/fold_9.py index 94a38a15..96ceb596 100644 --- a/src/ptbench/data/hivtb/fold_9.py +++ b/src/ptbench/config/data/hivtb/fold_9.py @@ -5,9 +5,9 @@ Database reference: [HIV-TB-2019]_ -See :py:class:`.hivtb.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.hivtb.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.hivtb.datamodule import DataModule datamodule = DataModule("fold-9.json") diff --git a/src/ptbench/data/montgomery/__init__.py b/src/ptbench/config/data/indian/__init__.py similarity index 100% rename from src/ptbench/data/montgomery/__init__.py rename to src/ptbench/config/data/indian/__init__.py diff --git a/src/ptbench/data/indian/datamodule.py b/src/ptbench/config/data/indian/datamodule.py similarity index 78% rename from src/ptbench/data/indian/datamodule.py rename to src/ptbench/config/data/indian/datamodule.py index a17a0bef..1c514f47 100644 --- a/src/ptbench/data/indian/datamodule.py +++ b/src/ptbench/config/data/indian/datamodule.py @@ -8,10 +8,14 @@ Database reference: [INDIAN-2013]_ import importlib.resources -from ..datamodule import CachingDataModule -from ..shenzhen.datamodule import RawDataLoader -from ..split import JSONDatabaseSplit -from ..typing import DatabaseSplit +from ptbench.config.data.shenzhen.datamodule import RawDataLoader +from ptbench.data.datamodule import CachingDataModule +from ptbench.data.split import JSONDatabaseSplit +from ptbench.data.typing import DatabaseSplit + +CONFIGURATION_KEY_DATADIR = "datadir." + (__name__.rsplit(".", 2)[-2]) +"""Key to search for in the configuration file for the root directory of this +database.""" def make_split(basename: str) -> DatabaseSplit: @@ -60,5 +64,7 @@ class DataModule(CachingDataModule): def __init__(self, split_filename: str): super().__init__( database_split=make_split(split_filename), - raw_data_loader=RawDataLoader(config_variable="datadir.indian"), + raw_data_loader=RawDataLoader( + config_variable=CONFIGURATION_KEY_DATADIR + ), ) diff --git a/src/ptbench/data/indian/default.json b/src/ptbench/config/data/indian/default.json similarity index 100% rename from src/ptbench/data/indian/default.json rename to src/ptbench/config/data/indian/default.json diff --git a/src/ptbench/data/indian/default.py b/src/ptbench/config/data/indian/default.py similarity index 65% rename from src/ptbench/data/indian/default.py rename to src/ptbench/config/data/indian/default.py index cd5c98bf..33bcb48d 100644 --- a/src/ptbench/data/indian/default.py +++ b/src/ptbench/config/data/indian/default.py @@ -5,9 +5,9 @@ Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("default.json") diff --git a/src/ptbench/data/indian/fold-0.json b/src/ptbench/config/data/indian/fold-0.json similarity index 100% rename from src/ptbench/data/indian/fold-0.json rename to src/ptbench/config/data/indian/fold-0.json diff --git a/src/ptbench/data/indian/fold-1.json b/src/ptbench/config/data/indian/fold-1.json similarity index 100% rename from src/ptbench/data/indian/fold-1.json rename to src/ptbench/config/data/indian/fold-1.json diff --git a/src/ptbench/data/indian/fold-2.json b/src/ptbench/config/data/indian/fold-2.json similarity index 100% rename from src/ptbench/data/indian/fold-2.json rename to src/ptbench/config/data/indian/fold-2.json diff --git a/src/ptbench/data/indian/fold-3.json b/src/ptbench/config/data/indian/fold-3.json similarity index 100% rename from src/ptbench/data/indian/fold-3.json rename to src/ptbench/config/data/indian/fold-3.json diff --git a/src/ptbench/data/indian/fold-4.json b/src/ptbench/config/data/indian/fold-4.json similarity index 100% rename from src/ptbench/data/indian/fold-4.json rename to src/ptbench/config/data/indian/fold-4.json diff --git a/src/ptbench/data/indian/fold-5.json b/src/ptbench/config/data/indian/fold-5.json similarity index 100% rename from src/ptbench/data/indian/fold-5.json rename to src/ptbench/config/data/indian/fold-5.json diff --git a/src/ptbench/data/indian/fold-6.json b/src/ptbench/config/data/indian/fold-6.json similarity index 100% rename from src/ptbench/data/indian/fold-6.json rename to src/ptbench/config/data/indian/fold-6.json diff --git a/src/ptbench/data/indian/fold-7.json b/src/ptbench/config/data/indian/fold-7.json similarity index 100% rename from src/ptbench/data/indian/fold-7.json rename to src/ptbench/config/data/indian/fold-7.json diff --git a/src/ptbench/data/indian/fold-8.json b/src/ptbench/config/data/indian/fold-8.json similarity index 100% rename from src/ptbench/data/indian/fold-8.json rename to src/ptbench/config/data/indian/fold-8.json diff --git a/src/ptbench/data/indian/fold-9.json b/src/ptbench/config/data/indian/fold-9.json similarity index 100% rename from src/ptbench/data/indian/fold-9.json rename to src/ptbench/config/data/indian/fold-9.json diff --git a/src/ptbench/data/indian/fold_0.py b/src/ptbench/config/data/indian/fold_0.py similarity index 66% rename from src/ptbench/data/indian/fold_0.py rename to src/ptbench/config/data/indian/fold_0.py index e316888d..6a8e6c5b 100644 --- a/src/ptbench/data/indian/fold_0.py +++ b/src/ptbench/config/data/indian/fold_0.py @@ -6,9 +6,9 @@ fold 0). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-0.json") diff --git a/src/ptbench/data/indian/fold_1.py b/src/ptbench/config/data/indian/fold_1.py similarity index 66% rename from src/ptbench/data/indian/fold_1.py rename to src/ptbench/config/data/indian/fold_1.py index 000a8410..029b6df6 100644 --- a/src/ptbench/data/indian/fold_1.py +++ b/src/ptbench/config/data/indian/fold_1.py @@ -6,9 +6,9 @@ fold 1). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-1.json") diff --git a/src/ptbench/data/indian/fold_2.py b/src/ptbench/config/data/indian/fold_2.py similarity index 66% rename from src/ptbench/data/indian/fold_2.py rename to src/ptbench/config/data/indian/fold_2.py index 9f9152b3..f54f35e5 100644 --- a/src/ptbench/data/indian/fold_2.py +++ b/src/ptbench/config/data/indian/fold_2.py @@ -6,9 +6,9 @@ fold 2). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-2.json") diff --git a/src/ptbench/data/indian/fold_3.py b/src/ptbench/config/data/indian/fold_3.py similarity index 66% rename from src/ptbench/data/indian/fold_3.py rename to src/ptbench/config/data/indian/fold_3.py index 16475b98..0c493592 100644 --- a/src/ptbench/data/indian/fold_3.py +++ b/src/ptbench/config/data/indian/fold_3.py @@ -6,9 +6,9 @@ fold 3). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-3.json") diff --git a/src/ptbench/data/indian/fold_4.py b/src/ptbench/config/data/indian/fold_4.py similarity index 66% rename from src/ptbench/data/indian/fold_4.py rename to src/ptbench/config/data/indian/fold_4.py index e2844b97..52a7b792 100644 --- a/src/ptbench/data/indian/fold_4.py +++ b/src/ptbench/config/data/indian/fold_4.py @@ -6,9 +6,9 @@ fold 4). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-4.json") diff --git a/src/ptbench/data/indian/fold_5.py b/src/ptbench/config/data/indian/fold_5.py similarity index 66% rename from src/ptbench/data/indian/fold_5.py rename to src/ptbench/config/data/indian/fold_5.py index ef583528..843a1e8c 100644 --- a/src/ptbench/data/indian/fold_5.py +++ b/src/ptbench/config/data/indian/fold_5.py @@ -6,9 +6,9 @@ fold 5). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-5.json") diff --git a/src/ptbench/data/indian/fold_6.py b/src/ptbench/config/data/indian/fold_6.py similarity index 66% rename from src/ptbench/data/indian/fold_6.py rename to src/ptbench/config/data/indian/fold_6.py index 59c168c5..9970d6f6 100644 --- a/src/ptbench/data/indian/fold_6.py +++ b/src/ptbench/config/data/indian/fold_6.py @@ -6,9 +6,9 @@ fold 6). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-6.json") diff --git a/src/ptbench/data/indian/fold_7.py b/src/ptbench/config/data/indian/fold_7.py similarity index 66% rename from src/ptbench/data/indian/fold_7.py rename to src/ptbench/config/data/indian/fold_7.py index 9eda09ad..5bbef8db 100644 --- a/src/ptbench/data/indian/fold_7.py +++ b/src/ptbench/config/data/indian/fold_7.py @@ -6,9 +6,9 @@ fold 7). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-7.json") diff --git a/src/ptbench/data/indian/fold_8.py b/src/ptbench/config/data/indian/fold_8.py similarity index 66% rename from src/ptbench/data/indian/fold_8.py rename to src/ptbench/config/data/indian/fold_8.py index abc54bac..0416153f 100644 --- a/src/ptbench/data/indian/fold_8.py +++ b/src/ptbench/config/data/indian/fold_8.py @@ -6,9 +6,9 @@ fold 8). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-8.json") diff --git a/src/ptbench/data/indian/fold_9.py b/src/ptbench/config/data/indian/fold_9.py similarity index 66% rename from src/ptbench/data/indian/fold_9.py rename to src/ptbench/config/data/indian/fold_9.py index cb4aa6be..3d4df2a5 100644 --- a/src/ptbench/data/indian/fold_9.py +++ b/src/ptbench/config/data/indian/fold_9.py @@ -6,9 +6,9 @@ fold 9). Database reference: [INDIAN-2013]_ -See :py:class:`.indian.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.indian.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.indian.datamodule import DataModule datamodule = DataModule("fold-9.json") diff --git a/src/ptbench/data/montgomery_shenzhen/__init__.py b/src/ptbench/config/data/montgomery/__init__.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/__init__.py rename to src/ptbench/config/data/montgomery/__init__.py diff --git a/src/ptbench/data/montgomery/datamodule.py b/src/ptbench/config/data/montgomery/datamodule.py similarity index 86% rename from src/ptbench/data/montgomery/datamodule.py rename to src/ptbench/config/data/montgomery/datamodule.py index b5ed48dd..84cdbc77 100644 --- a/src/ptbench/data/montgomery/datamodule.py +++ b/src/ptbench/config/data/montgomery/datamodule.py @@ -13,13 +13,17 @@ import PIL.Image from torchvision.transforms.functional import center_crop, to_tensor -from ...utils.rc import load_rc -from ..datamodule import CachingDataModule -from ..image_utils import remove_black_borders -from ..split import JSONDatabaseSplit -from ..typing import DatabaseSplit -from ..typing import RawDataLoader as _BaseRawDataLoader -from ..typing import Sample +from ptbench.data.datamodule import CachingDataModule +from ptbench.data.image_utils import remove_black_borders +from ptbench.data.split import JSONDatabaseSplit +from ptbench.data.typing import DatabaseSplit +from ptbench.data.typing import RawDataLoader as _BaseRawDataLoader +from ptbench.data.typing import Sample +from ptbench.utils.rc import load_rc + +CONFIGURATION_KEY_DATADIR = "datadir." + (__name__.rsplit(".", 2)[-2]) +"""Key to search for in the configuration file for the root directory of this +database.""" class RawDataLoader(_BaseRawDataLoader): @@ -31,7 +35,7 @@ class RawDataLoader(_BaseRawDataLoader): def __init__(self): self.datadir = load_rc().get( - "datadir.montgomery", os.path.realpath(os.curdir) + CONFIGURATION_KEY_DATADIR, os.path.realpath(os.curdir) ) def sample(self, sample: tuple[str, int]) -> Sample: diff --git a/src/ptbench/data/montgomery/default.json b/src/ptbench/config/data/montgomery/default.json similarity index 100% rename from src/ptbench/data/montgomery/default.json rename to src/ptbench/config/data/montgomery/default.json diff --git a/src/ptbench/data/montgomery/default.py b/src/ptbench/config/data/montgomery/default.py similarity index 63% rename from src/ptbench/data/montgomery/default.py rename to src/ptbench/config/data/montgomery/default.py index ad32e45b..fa890210 100644 --- a/src/ptbench/data/montgomery/default.py +++ b/src/ptbench/config/data/montgomery/default.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("default.json") diff --git a/src/ptbench/data/montgomery/fold-0.json b/src/ptbench/config/data/montgomery/fold-0.json similarity index 100% rename from src/ptbench/data/montgomery/fold-0.json rename to src/ptbench/config/data/montgomery/fold-0.json diff --git a/src/ptbench/data/montgomery/fold-1.json b/src/ptbench/config/data/montgomery/fold-1.json similarity index 100% rename from src/ptbench/data/montgomery/fold-1.json rename to src/ptbench/config/data/montgomery/fold-1.json diff --git a/src/ptbench/data/montgomery/fold-2.json b/src/ptbench/config/data/montgomery/fold-2.json similarity index 100% rename from src/ptbench/data/montgomery/fold-2.json rename to src/ptbench/config/data/montgomery/fold-2.json diff --git a/src/ptbench/data/montgomery/fold-3.json b/src/ptbench/config/data/montgomery/fold-3.json similarity index 100% rename from src/ptbench/data/montgomery/fold-3.json rename to src/ptbench/config/data/montgomery/fold-3.json diff --git a/src/ptbench/data/montgomery/fold-4.json b/src/ptbench/config/data/montgomery/fold-4.json similarity index 100% rename from src/ptbench/data/montgomery/fold-4.json rename to src/ptbench/config/data/montgomery/fold-4.json diff --git a/src/ptbench/data/montgomery/fold-5.json b/src/ptbench/config/data/montgomery/fold-5.json similarity index 100% rename from src/ptbench/data/montgomery/fold-5.json rename to src/ptbench/config/data/montgomery/fold-5.json diff --git a/src/ptbench/data/montgomery/fold-6.json b/src/ptbench/config/data/montgomery/fold-6.json similarity index 100% rename from src/ptbench/data/montgomery/fold-6.json rename to src/ptbench/config/data/montgomery/fold-6.json diff --git a/src/ptbench/data/montgomery/fold-7.json b/src/ptbench/config/data/montgomery/fold-7.json similarity index 100% rename from src/ptbench/data/montgomery/fold-7.json rename to src/ptbench/config/data/montgomery/fold-7.json diff --git a/src/ptbench/data/montgomery/fold-8.json b/src/ptbench/config/data/montgomery/fold-8.json similarity index 100% rename from src/ptbench/data/montgomery/fold-8.json rename to src/ptbench/config/data/montgomery/fold-8.json diff --git a/src/ptbench/data/montgomery/fold-9.json b/src/ptbench/config/data/montgomery/fold-9.json similarity index 100% rename from src/ptbench/data/montgomery/fold-9.json rename to src/ptbench/config/data/montgomery/fold-9.json diff --git a/src/ptbench/data/montgomery/fold_0.py b/src/ptbench/config/data/montgomery/fold_0.py similarity index 65% rename from src/ptbench/data/montgomery/fold_0.py rename to src/ptbench/config/data/montgomery/fold_0.py index 7f842d59..2f72873e 100644 --- a/src/ptbench/data/montgomery/fold_0.py +++ b/src/ptbench/config/data/montgomery/fold_0.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-0.json") diff --git a/src/ptbench/data/montgomery/fold_1.py b/src/ptbench/config/data/montgomery/fold_1.py similarity index 65% rename from src/ptbench/data/montgomery/fold_1.py rename to src/ptbench/config/data/montgomery/fold_1.py index abdfbcf1..e4fd9fe8 100644 --- a/src/ptbench/data/montgomery/fold_1.py +++ b/src/ptbench/config/data/montgomery/fold_1.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-1.json") diff --git a/src/ptbench/data/montgomery/fold_2.py b/src/ptbench/config/data/montgomery/fold_2.py similarity index 65% rename from src/ptbench/data/montgomery/fold_2.py rename to src/ptbench/config/data/montgomery/fold_2.py index 8614cc00..903154be 100644 --- a/src/ptbench/data/montgomery/fold_2.py +++ b/src/ptbench/config/data/montgomery/fold_2.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-2.json") diff --git a/src/ptbench/data/montgomery/fold_3.py b/src/ptbench/config/data/montgomery/fold_3.py similarity index 65% rename from src/ptbench/data/montgomery/fold_3.py rename to src/ptbench/config/data/montgomery/fold_3.py index 50ac23f5..27d9ebdd 100644 --- a/src/ptbench/data/montgomery/fold_3.py +++ b/src/ptbench/config/data/montgomery/fold_3.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-3.json") diff --git a/src/ptbench/data/montgomery/fold_4.py b/src/ptbench/config/data/montgomery/fold_4.py similarity index 65% rename from src/ptbench/data/montgomery/fold_4.py rename to src/ptbench/config/data/montgomery/fold_4.py index c83e1060..e5379102 100644 --- a/src/ptbench/data/montgomery/fold_4.py +++ b/src/ptbench/config/data/montgomery/fold_4.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-4.json") diff --git a/src/ptbench/data/montgomery/fold_5.py b/src/ptbench/config/data/montgomery/fold_5.py similarity index 65% rename from src/ptbench/data/montgomery/fold_5.py rename to src/ptbench/config/data/montgomery/fold_5.py index 30b97b03..feb8ac45 100644 --- a/src/ptbench/data/montgomery/fold_5.py +++ b/src/ptbench/config/data/montgomery/fold_5.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-5.json") diff --git a/src/ptbench/data/montgomery/fold_6.py b/src/ptbench/config/data/montgomery/fold_6.py similarity index 65% rename from src/ptbench/data/montgomery/fold_6.py rename to src/ptbench/config/data/montgomery/fold_6.py index 86e35ca5..e868c726 100644 --- a/src/ptbench/data/montgomery/fold_6.py +++ b/src/ptbench/config/data/montgomery/fold_6.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-6.json") diff --git a/src/ptbench/data/montgomery/fold_7.py b/src/ptbench/config/data/montgomery/fold_7.py similarity index 65% rename from src/ptbench/data/montgomery/fold_7.py rename to src/ptbench/config/data/montgomery/fold_7.py index 9f0bd3da..0415dfba 100644 --- a/src/ptbench/data/montgomery/fold_7.py +++ b/src/ptbench/config/data/montgomery/fold_7.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-7.json") diff --git a/src/ptbench/data/montgomery/fold_8.py b/src/ptbench/config/data/montgomery/fold_8.py similarity index 65% rename from src/ptbench/data/montgomery/fold_8.py rename to src/ptbench/config/data/montgomery/fold_8.py index 5ea2dfc9..d00595b0 100644 --- a/src/ptbench/data/montgomery/fold_8.py +++ b/src/ptbench/config/data/montgomery/fold_8.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-8.json") diff --git a/src/ptbench/data/montgomery/fold_9.py b/src/ptbench/config/data/montgomery/fold_9.py similarity index 65% rename from src/ptbench/data/montgomery/fold_9.py rename to src/ptbench/config/data/montgomery/fold_9.py index 41025b73..c9158fd1 100644 --- a/src/ptbench/data/montgomery/fold_9.py +++ b/src/ptbench/config/data/montgomery/fold_9.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.montgomery.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.montgomery.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.montgomery.datamodule import DataModule datamodule = DataModule("fold-9.json") diff --git a/src/ptbench/data/montgomery_shenzhen_indian/__init__.py b/src/ptbench/config/data/montgomery_shenzhen/__init__.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/__init__.py rename to src/ptbench/config/data/montgomery_shenzhen/__init__.py diff --git a/src/ptbench/data/montgomery_shenzhen/datamodule.py b/src/ptbench/config/data/montgomery_shenzhen/datamodule.py similarity index 96% rename from src/ptbench/data/montgomery_shenzhen/datamodule.py rename to src/ptbench/config/data/montgomery_shenzhen/datamodule.py index e1173824..0509dd5f 100644 --- a/src/ptbench/data/montgomery_shenzhen/datamodule.py +++ b/src/ptbench/config/data/montgomery_shenzhen/datamodule.py @@ -2,7 +2,8 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -from ..datamodule import ConcatDataModule +from ptbench.data.datamodule import ConcatDataModule + from ..montgomery.datamodule import RawDataLoader as MontgomeryLoader from ..montgomery.datamodule import make_split as make_montgomery_split from ..shenzhen.datamodule import RawDataLoader as ShenzhenLoader diff --git a/src/ptbench/data/montgomery_shenzhen/default.py b/src/ptbench/config/data/montgomery_shenzhen/default.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/default.py rename to src/ptbench/config/data/montgomery_shenzhen/default.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_0.py b/src/ptbench/config/data/montgomery_shenzhen/fold_0.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_0.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_0.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_1.py b/src/ptbench/config/data/montgomery_shenzhen/fold_1.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_1.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_1.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_2.py b/src/ptbench/config/data/montgomery_shenzhen/fold_2.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_2.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_2.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_3.py b/src/ptbench/config/data/montgomery_shenzhen/fold_3.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_3.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_3.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_4.py b/src/ptbench/config/data/montgomery_shenzhen/fold_4.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_4.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_4.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_5.py b/src/ptbench/config/data/montgomery_shenzhen/fold_5.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_5.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_5.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_6.py b/src/ptbench/config/data/montgomery_shenzhen/fold_6.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_6.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_6.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_7.py b/src/ptbench/config/data/montgomery_shenzhen/fold_7.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_7.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_7.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_8.py b/src/ptbench/config/data/montgomery_shenzhen/fold_8.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_8.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_8.py diff --git a/src/ptbench/data/montgomery_shenzhen/fold_9.py b/src/ptbench/config/data/montgomery_shenzhen/fold_9.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen/fold_9.py rename to src/ptbench/config/data/montgomery_shenzhen/fold_9.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_padchest/__init__.py b/src/ptbench/config/data/montgomery_shenzhen_indian/__init__.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_padchest/__init__.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/__init__.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/datamodule.py b/src/ptbench/config/data/montgomery_shenzhen_indian/datamodule.py similarity index 70% rename from src/ptbench/data/montgomery_shenzhen_indian/datamodule.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/datamodule.py index 6df9a850..0bbb2c3d 100644 --- a/src/ptbench/data/montgomery_shenzhen_indian/datamodule.py +++ b/src/ptbench/config/data/montgomery_shenzhen_indian/datamodule.py @@ -4,13 +4,23 @@ """Aggregated datamodule composed of Montgomery, Shenzhen and Indian datasets.""" -from ..datamodule import ConcatDataModule -from ..indian.datamodule import RawDataLoader as IndianLoader -from ..indian.datamodule import make_split as make_indian_split -from ..montgomery.datamodule import RawDataLoader as MontgomeryLoader -from ..montgomery.datamodule import make_split as make_montgomery_split -from ..shenzhen.datamodule import RawDataLoader as ShenzhenLoader -from ..shenzhen.datamodule import make_split as make_shenzhen_split +from ptbench.config.data.indian.datamodule import RawDataLoader as IndianLoader +from ptbench.config.data.indian.datamodule import ( + make_split as make_indian_split, +) +from ptbench.config.data.montgomery.datamodule import ( + RawDataLoader as MontgomeryLoader, +) +from ptbench.config.data.montgomery.datamodule import ( + make_split as make_montgomery_split, +) +from ptbench.config.data.shenzhen.datamodule import ( + RawDataLoader as ShenzhenLoader, +) +from ptbench.config.data.shenzhen.datamodule import ( + make_split as make_shenzhen_split, +) +from ptbench.data.datamodule import ConcatDataModule class DataModule(ConcatDataModule): diff --git a/src/ptbench/data/montgomery_shenzhen_indian/default.py b/src/ptbench/config/data/montgomery_shenzhen_indian/default.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/default.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/default.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_0.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_0.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_0.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_0.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_1.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_1.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_1.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_1.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_2.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_2.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_2.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_2.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_3.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_3.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_3.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_3.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_4.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_4.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_4.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_4.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_5.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_5.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_5.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_5.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_6.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_6.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_6.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_6.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_7.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_7.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_7.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_7.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_8.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_8.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_8.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_8.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian/fold_9.py b/src/ptbench/config/data/montgomery_shenzhen_indian/fold_9.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian/fold_9.py rename to src/ptbench/config/data/montgomery_shenzhen_indian/fold_9.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/__init__.py b/src/ptbench/config/data/montgomery_shenzhen_indian_padchest/__init__.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/__init__.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_padchest/__init__.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_padchest/datamodule.py b/src/ptbench/config/data/montgomery_shenzhen_indian_padchest/datamodule.py similarity index 70% rename from src/ptbench/data/montgomery_shenzhen_indian_padchest/datamodule.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_padchest/datamodule.py index b4317ac4..93d0193f 100644 --- a/src/ptbench/data/montgomery_shenzhen_indian_padchest/datamodule.py +++ b/src/ptbench/config/data/montgomery_shenzhen_indian_padchest/datamodule.py @@ -4,15 +4,29 @@ """Aggregated datamodule composed of Montgomery, Shenzhen, Indian, and PadChest datasets.""" -from ..datamodule import ConcatDataModule -from ..indian.datamodule import RawDataLoader as IndianLoader -from ..indian.datamodule import make_split as make_indian_split -from ..montgomery.datamodule import RawDataLoader as MontgomeryLoader -from ..montgomery.datamodule import make_split as make_montgomery_split -from ..padchest.datamodule import RawDataLoader as PadchestLoader -from ..padchest.datamodule import make_split as make_padchest_split -from ..shenzhen.datamodule import RawDataLoader as ShenzhenLoader -from ..shenzhen.datamodule import make_split as make_shenzhen_split +from ptbench.config.data.indian.datamodule import RawDataLoader as IndianLoader +from ptbench.config.data.indian.datamodule import ( + make_split as make_indian_split, +) +from ptbench.config.data.montgomery.datamodule import ( + RawDataLoader as MontgomeryLoader, +) +from ptbench.config.data.montgomery.datamodule import ( + make_split as make_montgomery_split, +) +from ptbench.config.data.padchest.datamodule import ( + RawDataLoader as PadchestLoader, +) +from ptbench.config.data.padchest.datamodule import ( + make_split as make_padchest_split, +) +from ptbench.config.data.shenzhen.datamodule import ( + RawDataLoader as ShenzhenLoader, +) +from ptbench.config.data.shenzhen.datamodule import ( + make_split as make_shenzhen_split, +) +from ptbench.data.datamodule import ConcatDataModule class DataModule(ConcatDataModule): diff --git a/src/ptbench/data/montgomery_shenzhen_indian_padchest/default.py b/src/ptbench/config/data/montgomery_shenzhen_indian_padchest/default.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_padchest/default.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_padchest/default.py diff --git a/src/ptbench/data/nih_cxr14/__init__.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/__init__.py similarity index 100% rename from src/ptbench/data/nih_cxr14/__init__.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/__init__.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/datamodule.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/datamodule.py similarity index 69% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/datamodule.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/datamodule.py index 6f7ee8bc..97615574 100644 --- a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/datamodule.py +++ b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/datamodule.py @@ -4,15 +4,27 @@ """Aggregated datamodule composed of Montgomery, Shenzhen, Indian, and TBX11k datasets.""" -from ..datamodule import ConcatDataModule -from ..indian.datamodule import RawDataLoader as IndianLoader -from ..indian.datamodule import make_split as make_indian_split -from ..montgomery.datamodule import RawDataLoader as MontgomeryLoader -from ..montgomery.datamodule import make_split as make_montgomery_split -from ..shenzhen.datamodule import RawDataLoader as ShenzhenLoader -from ..shenzhen.datamodule import make_split as make_shenzhen_split -from ..tbx11k.datamodule import RawDataLoader as TBX11kLoader -from ..tbx11k.datamodule import make_split as make_tbx11k_split +from ptbench.config.data.indian.datamodule import RawDataLoader as IndianLoader +from ptbench.config.data.indian.datamodule import ( + make_split as make_indian_split, +) +from ptbench.config.data.montgomery.datamodule import ( + RawDataLoader as MontgomeryLoader, +) +from ptbench.config.data.montgomery.datamodule import ( + make_split as make_montgomery_split, +) +from ptbench.config.data.shenzhen.datamodule import ( + RawDataLoader as ShenzhenLoader, +) +from ptbench.config.data.shenzhen.datamodule import ( + make_split as make_shenzhen_split, +) +from ptbench.config.data.tbx11k.datamodule import RawDataLoader as TBX11kLoader +from ptbench.config.data.tbx11k.datamodule import ( + make_split as make_tbx11k_split, +) +from ptbench.data.datamodule import ConcatDataModule class DataModule(ConcatDataModule): diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_0.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_0.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_0.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_0.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_1.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_1.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_1.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_1.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_2.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_2.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_2.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_2.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_3.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_3.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_3.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_3.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_4.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_4.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_4.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_4.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_5.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_5.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_5.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_5.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_6.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_6.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_6.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_6.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_7.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_7.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_7.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_7.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_8.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_8.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_8.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_8.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_9.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_9.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_fold_9.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_fold_9.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_healthy_vs_atb.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_healthy_vs_atb.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v1_healthy_vs_atb.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v1_healthy_vs_atb.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_0.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_0.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_0.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_0.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_1.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_1.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_1.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_1.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_2.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_2.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_2.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_2.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_3.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_3.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_3.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_3.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_4.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_4.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_4.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_4.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_5.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_5.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_5.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_5.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_6.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_6.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_6.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_6.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_7.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_7.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_7.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_7.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_8.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_8.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_8.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_8.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_9.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_9.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_fold_9.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_fold_9.py diff --git a/src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_others_vs_atb.py b/src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_others_vs_atb.py similarity index 100% rename from src/ptbench/data/montgomery_shenzhen_indian_tbx11k/v2_others_vs_atb.py rename to src/ptbench/config/data/montgomery_shenzhen_indian_tbx11k/v2_others_vs_atb.py diff --git a/src/ptbench/data/nih_cxr14_padchest/__init__.py b/src/ptbench/config/data/nih_cxr14/__init__.py similarity index 100% rename from src/ptbench/data/nih_cxr14_padchest/__init__.py rename to src/ptbench/config/data/nih_cxr14/__init__.py diff --git a/src/ptbench/data/nih_cxr14/cardiomegaly.json b/src/ptbench/config/data/nih_cxr14/cardiomegaly.json similarity index 100% rename from src/ptbench/data/nih_cxr14/cardiomegaly.json rename to src/ptbench/config/data/nih_cxr14/cardiomegaly.json diff --git a/src/ptbench/data/nih_cxr14/cardiomegaly.py b/src/ptbench/config/data/nih_cxr14/cardiomegaly.py similarity index 71% rename from src/ptbench/data/nih_cxr14/cardiomegaly.py rename to src/ptbench/config/data/nih_cxr14/cardiomegaly.py index 7b104faa..77248a47 100644 --- a/src/ptbench/data/nih_cxr14/cardiomegaly.py +++ b/src/ptbench/config/data/nih_cxr14/cardiomegaly.py @@ -8,9 +8,10 @@ Database reference: [NIH-CXR14-2017]_ This split contains cardiomegaly cases from the NIH CXR14 database. -See :py:class:`.nih_cxr14.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.nih_cxr14.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.nih_cxr14.datamodule import DataModule datamodule = DataModule("cardiomegaly.json") diff --git a/src/ptbench/data/nih_cxr14/datamodule.py b/src/ptbench/config/data/nih_cxr14/datamodule.py similarity index 82% rename from src/ptbench/data/nih_cxr14/datamodule.py rename to src/ptbench/config/data/nih_cxr14/datamodule.py index 996c9feb..9875985f 100644 --- a/src/ptbench/data/nih_cxr14/datamodule.py +++ b/src/ptbench/config/data/nih_cxr14/datamodule.py @@ -13,12 +13,27 @@ import PIL.Image from torchvision.transforms.functional import to_tensor -from ...utils.rc import load_rc -from ..datamodule import CachingDataModule -from ..split import JSONDatabaseSplit -from ..typing import DatabaseSplit -from ..typing import RawDataLoader as _BaseRawDataLoader -from ..typing import Sample +from ptbench.data.datamodule import CachingDataModule +from ptbench.data.split import JSONDatabaseSplit +from ptbench.data.typing import DatabaseSplit +from ptbench.data.typing import RawDataLoader as _BaseRawDataLoader +from ptbench.data.typing import Sample +from ptbench.utils.rc import load_rc + +CONFIGURATION_KEY_DATADIR = "datadir." + (__name__.rsplit(".", 2)[-2]) +"""Key to search for in the configuration file for the root directory of this +database.""" + +CONFIGURATION_KEY_IDIAP_FILESTRUCTURE = ( + __name__.rsplit(".", 2)[-2] +) + ".idiap_folder_structure" +"""Key to search for in the configuration file indicating if the loader should +use standard or idiap-based file organisation structure. + +It causes the internal loader to search for files in a slightly +different folder structure, that was adapted to Idiap's requirements +(number of files per folder to be less than 10k). +""" class RawDataLoader(_BaseRawDataLoader): @@ -40,9 +55,11 @@ class RawDataLoader(_BaseRawDataLoader): def __init__(self): rc = load_rc() - self.datadir = rc.get("datadir.nih_cxr14", os.path.realpath(os.curdir)) + self.datadir = rc.get( + CONFIGURATION_KEY_DATADIR, os.path.realpath(os.curdir) + ) self.idiap_file_organisation = rc.get( - "nih_cxr14.idiap_folder_structure", False + CONFIGURATION_KEY_IDIAP_FILESTRUCTURE, False ) def sample(self, sample: tuple[str, list[int]]) -> Sample: diff --git a/src/ptbench/data/nih_cxr14/default.json.bz2 b/src/ptbench/config/data/nih_cxr14/default.json.bz2 similarity index 100% rename from src/ptbench/data/nih_cxr14/default.json.bz2 rename to src/ptbench/config/data/nih_cxr14/default.json.bz2 diff --git a/src/ptbench/data/nih_cxr14/default.py b/src/ptbench/config/data/nih_cxr14/default.py similarity index 67% rename from src/ptbench/data/nih_cxr14/default.py rename to src/ptbench/config/data/nih_cxr14/default.py index c7bc3e2e..00ac5afd 100644 --- a/src/ptbench/data/nih_cxr14/default.py +++ b/src/ptbench/config/data/nih_cxr14/default.py @@ -7,9 +7,10 @@ * Validation samples: 6350 * Test samples: 4054 -See :py:class:`.nih_cxr14.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.nih_cxr14.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.nih_cxr14.datamodule import DataModule datamodule = DataModule("default.json.bz2") diff --git a/src/ptbench/data/padchest/__init__.py b/src/ptbench/config/data/nih_cxr14_padchest/__init__.py similarity index 100% rename from src/ptbench/data/padchest/__init__.py rename to src/ptbench/config/data/nih_cxr14_padchest/__init__.py diff --git a/src/ptbench/data/nih_cxr14_padchest/datamodule.py b/src/ptbench/config/data/nih_cxr14_padchest/datamodule.py similarity index 73% rename from src/ptbench/data/nih_cxr14_padchest/datamodule.py rename to src/ptbench/config/data/nih_cxr14_padchest/datamodule.py index f1ce1f91..cd2d8fb2 100644 --- a/src/ptbench/data/nih_cxr14_padchest/datamodule.py +++ b/src/ptbench/config/data/nih_cxr14_padchest/datamodule.py @@ -2,11 +2,19 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -from ..datamodule import ConcatDataModule -from ..nih_cxr14.datamodule import RawDataLoader as CXR14Loader -from ..nih_cxr14.datamodule import make_split as make_cxr14_split -from ..padchest.datamodule import RawDataLoader as PadchestLoader -from ..padchest.datamodule import make_split as make_padchest_split +from ptbench.config.data.nih_cxr14.datamodule import ( + RawDataLoader as CXR14Loader, +) +from ptbench.config.data.nih_cxr14.datamodule import ( + make_split as make_cxr14_split, +) +from ptbench.config.data.padchest.datamodule import ( + RawDataLoader as PadchestLoader, +) +from ptbench.config.data.padchest.datamodule import ( + make_split as make_padchest_split, +) +from ptbench.data.datamodule import ConcatDataModule class DataModule(ConcatDataModule): diff --git a/src/ptbench/data/nih_cxr14_padchest/idiap.py b/src/ptbench/config/data/nih_cxr14_padchest/idiap.py similarity index 100% rename from src/ptbench/data/nih_cxr14_padchest/idiap.py rename to src/ptbench/config/data/nih_cxr14_padchest/idiap.py diff --git a/src/ptbench/data/shenzhen/__init__.py b/src/ptbench/config/data/padchest/__init__.py similarity index 100% rename from src/ptbench/data/shenzhen/__init__.py rename to src/ptbench/config/data/padchest/__init__.py diff --git a/src/ptbench/data/padchest/cardiomegaly-idiap.json b/src/ptbench/config/data/padchest/cardiomegaly-idiap.json similarity index 100% rename from src/ptbench/data/padchest/cardiomegaly-idiap.json rename to src/ptbench/config/data/padchest/cardiomegaly-idiap.json diff --git a/src/ptbench/data/padchest/cardiomegaly_idiap.py b/src/ptbench/config/data/padchest/cardiomegaly_idiap.py similarity index 72% rename from src/ptbench/data/padchest/cardiomegaly_idiap.py rename to src/ptbench/config/data/padchest/cardiomegaly_idiap.py index bd832fdd..a22cdc08 100644 --- a/src/ptbench/data/padchest/cardiomegaly_idiap.py +++ b/src/ptbench/config/data/padchest/cardiomegaly_idiap.py @@ -8,9 +8,11 @@ Database reference: [PADCHEST-2019]_ This split contains the first 40 images with cardiomegaly, with parameters: Label = "Normal", MethodLabel = "Physician", Projection = "PA" -Read documentation of :py:class:`DataModule` for technical details. +Read documentation of +:py:class:`ptbench.config.data.padchest.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.padchest.datamodule import DataModule datamodule = DataModule("cardiomegaly-idiap.json") diff --git a/src/ptbench/data/padchest/datamodule.py b/src/ptbench/config/data/padchest/datamodule.py similarity index 94% rename from src/ptbench/data/padchest/datamodule.py rename to src/ptbench/config/data/padchest/datamodule.py index 1fc49485..0122a429 100644 --- a/src/ptbench/data/padchest/datamodule.py +++ b/src/ptbench/config/data/padchest/datamodule.py @@ -14,13 +14,17 @@ import PIL.Image from torchvision.transforms.functional import center_crop, to_tensor -from ...utils.rc import load_rc -from ..datamodule import CachingDataModule -from ..image_utils import remove_black_borders -from ..split import JSONDatabaseSplit -from ..typing import DatabaseSplit -from ..typing import RawDataLoader as _BaseRawDataLoader -from ..typing import Sample +from ptbench.data.datamodule import CachingDataModule +from ptbench.data.image_utils import remove_black_borders +from ptbench.data.split import JSONDatabaseSplit +from ptbench.data.typing import DatabaseSplit +from ptbench.data.typing import RawDataLoader as _BaseRawDataLoader +from ptbench.data.typing import Sample +from ptbench.utils.rc import load_rc + +CONFIGURATION_KEY_DATADIR = "datadir." + (__name__.rsplit(".", 2)[-2]) +"""Key to search for in the configuration file for the root directory of this +database.""" class RawDataLoader(_BaseRawDataLoader): @@ -32,7 +36,9 @@ class RawDataLoader(_BaseRawDataLoader): def __init__(self): rc = load_rc() - self.datadir = rc.get("datadir.padchest", os.path.realpath(os.curdir)) + self.datadir = rc.get( + CONFIGURATION_KEY_DATADIR, os.path.realpath(os.curdir) + ) def sample(self, sample: tuple[str, int | list[int]]) -> Sample: """Loads a single image sample from the disk. diff --git a/src/ptbench/data/padchest/idiap.json.bz2 b/src/ptbench/config/data/padchest/idiap.json.bz2 similarity index 100% rename from src/ptbench/data/padchest/idiap.json.bz2 rename to src/ptbench/config/data/padchest/idiap.json.bz2 diff --git a/src/ptbench/data/padchest/idiap.py b/src/ptbench/config/data/padchest/idiap.py similarity index 67% rename from src/ptbench/data/padchest/idiap.py rename to src/ptbench/config/data/padchest/idiap.py index bf1f9356..be0f9b2f 100644 --- a/src/ptbench/data/padchest/idiap.py +++ b/src/ptbench/config/data/padchest/idiap.py @@ -6,14 +6,15 @@ Database reference: [PADCHEST-2019]_ This split contains all images in the database. Read documentation of -:py:class:`.padchest.datamodule.DataModule` for technical details. +:py:class:`ptbench.config.data.padchest.datamodule.DataModule` for technical +details. * Split reference: ours * Training samples: 96'269 - * Validation samples: ? - * Test samples: ? + * Validation samples: 0 + * Test samples: 0 """ -from .datamodule import DataModule +from ptbench.config.data.padchest.datamodule import DataModule datamodule = DataModule("idiap.json.bz2") diff --git a/src/ptbench/data/padchest/no-tb-idiap.json.bz2 b/src/ptbench/config/data/padchest/no-tb-idiap.json.bz2 similarity index 100% rename from src/ptbench/data/padchest/no-tb-idiap.json.bz2 rename to src/ptbench/config/data/padchest/no-tb-idiap.json.bz2 diff --git a/src/ptbench/data/padchest/no_tb_idiap.py b/src/ptbench/config/data/padchest/no_tb_idiap.py similarity index 81% rename from src/ptbench/data/padchest/no_tb_idiap.py rename to src/ptbench/config/data/padchest/no_tb_idiap.py index ca787520..8c2c5fc7 100644 --- a/src/ptbench/data/padchest/no_tb_idiap.py +++ b/src/ptbench/config/data/padchest/no_tb_idiap.py @@ -28,10 +28,11 @@ Database reference: [PADCHEST-2019]_ * fibrosis * edema and consolidation -Read documentation of :py:class:`.padchest.datamodule.DataModule` for technical +Read documentation of +:py:class:`ptbench.config.data.padchest.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.padchest.datamodule import DataModule datamodule = DataModule("no-tb-idiap.json.bz2") diff --git a/src/ptbench/data/padchest/tb-idiap.json b/src/ptbench/config/data/padchest/tb-idiap.json similarity index 100% rename from src/ptbench/data/padchest/tb-idiap.json rename to src/ptbench/config/data/padchest/tb-idiap.json diff --git a/src/ptbench/data/padchest/tb_idiap.py b/src/ptbench/config/data/padchest/tb_idiap.py similarity index 77% rename from src/ptbench/data/padchest/tb_idiap.py rename to src/ptbench/config/data/padchest/tb_idiap.py index d77e5afd..c6c4da93 100644 --- a/src/ptbench/data/padchest/tb_idiap.py +++ b/src/ptbench/config/data/padchest/tb_idiap.py @@ -10,10 +10,11 @@ the following parameters: Label = "Normal", MethodLabel = "Physician", Projection = "PA" and TB cases. Labelling matches those for active TB (binary) classification datasets. -Read documentation of :py:class:`.padchest.datamodule.DataModule` for technical +Read documentation of +:py:class:`ptbench.config.data.padchest.datamodule.DataModule` for technical details. """ -from .datamodule import DataModule +from ptbench.config.data.padchest.datamodule import DataModule datamodule = DataModule("tb-idiap.json") diff --git a/src/ptbench/data/tbpoc/__init__.py b/src/ptbench/config/data/shenzhen/__init__.py similarity index 100% rename from src/ptbench/data/tbpoc/__init__.py rename to src/ptbench/config/data/shenzhen/__init__.py diff --git a/src/ptbench/data/shenzhen/datamodule.py b/src/ptbench/config/data/shenzhen/datamodule.py similarity index 84% rename from src/ptbench/data/shenzhen/datamodule.py rename to src/ptbench/config/data/shenzhen/datamodule.py index af5a4074..70c63893 100644 --- a/src/ptbench/data/shenzhen/datamodule.py +++ b/src/ptbench/config/data/shenzhen/datamodule.py @@ -13,13 +13,17 @@ import PIL.Image from torchvision.transforms.functional import center_crop, to_tensor -from ...utils.rc import load_rc -from ..datamodule import CachingDataModule -from ..image_utils import remove_black_borders -from ..split import JSONDatabaseSplit -from ..typing import DatabaseSplit -from ..typing import RawDataLoader as _BaseRawDataLoader -from ..typing import Sample +from ptbench.data.datamodule import CachingDataModule +from ptbench.data.image_utils import remove_black_borders +from ptbench.data.split import JSONDatabaseSplit +from ptbench.data.typing import DatabaseSplit +from ptbench.data.typing import RawDataLoader as _BaseRawDataLoader +from ptbench.data.typing import Sample +from ptbench.utils.rc import load_rc + +CONFIGURATION_KEY_DATADIR = "datadir." + (__name__.rsplit(".", 2)[-2]) +"""Key to search for in the configuration file for the root directory of this +database.""" class RawDataLoader(_BaseRawDataLoader): @@ -29,7 +33,9 @@ class RawDataLoader(_BaseRawDataLoader): """This variable contains the base directory where the database raw data is stored.""" - def __init__(self, config_variable: str = "datadir.shenzhen"): + # config_variable: required so this loader can be used for the Indian + # database as well. + def __init__(self, config_variable: str = CONFIGURATION_KEY_DATADIR): self.datadir = load_rc().get( config_variable, os.path.realpath(os.curdir) ) diff --git a/src/ptbench/data/shenzhen/default.json b/src/ptbench/config/data/shenzhen/default.json similarity index 100% rename from src/ptbench/data/shenzhen/default.json rename to src/ptbench/config/data/shenzhen/default.json diff --git a/src/ptbench/data/shenzhen/default.py b/src/ptbench/config/data/shenzhen/default.py similarity index 75% rename from src/ptbench/data/shenzhen/default.py rename to src/ptbench/config/data/shenzhen/default.py index b8cf7172..fd0dbaf1 100644 --- a/src/ptbench/data/shenzhen/default.py +++ b/src/ptbench/config/data/shenzhen/default.py @@ -9,9 +9,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ * Validation samples: 16% of TB and healthy CXR (including labels) * Test samples: 20% of TB and healthy CXR (including labels) -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("default.json") diff --git a/src/ptbench/data/shenzhen/fold-0.json b/src/ptbench/config/data/shenzhen/fold-0.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-0.json rename to src/ptbench/config/data/shenzhen/fold-0.json diff --git a/src/ptbench/data/shenzhen/fold-1.json b/src/ptbench/config/data/shenzhen/fold-1.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-1.json rename to src/ptbench/config/data/shenzhen/fold-1.json diff --git a/src/ptbench/data/shenzhen/fold-2.json b/src/ptbench/config/data/shenzhen/fold-2.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-2.json rename to src/ptbench/config/data/shenzhen/fold-2.json diff --git a/src/ptbench/data/shenzhen/fold-3.json b/src/ptbench/config/data/shenzhen/fold-3.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-3.json rename to src/ptbench/config/data/shenzhen/fold-3.json diff --git a/src/ptbench/data/shenzhen/fold-4.json b/src/ptbench/config/data/shenzhen/fold-4.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-4.json rename to src/ptbench/config/data/shenzhen/fold-4.json diff --git a/src/ptbench/data/shenzhen/fold-5.json b/src/ptbench/config/data/shenzhen/fold-5.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-5.json rename to src/ptbench/config/data/shenzhen/fold-5.json diff --git a/src/ptbench/data/shenzhen/fold-6.json b/src/ptbench/config/data/shenzhen/fold-6.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-6.json rename to src/ptbench/config/data/shenzhen/fold-6.json diff --git a/src/ptbench/data/shenzhen/fold-7.json b/src/ptbench/config/data/shenzhen/fold-7.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-7.json rename to src/ptbench/config/data/shenzhen/fold-7.json diff --git a/src/ptbench/data/shenzhen/fold-8.json b/src/ptbench/config/data/shenzhen/fold-8.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-8.json rename to src/ptbench/config/data/shenzhen/fold-8.json diff --git a/src/ptbench/data/shenzhen/fold-9.json b/src/ptbench/config/data/shenzhen/fold-9.json similarity index 100% rename from src/ptbench/data/shenzhen/fold-9.json rename to src/ptbench/config/data/shenzhen/fold-9.json diff --git a/src/ptbench/data/shenzhen/fold_0.py b/src/ptbench/config/data/shenzhen/fold_0.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_0.py rename to src/ptbench/config/data/shenzhen/fold_0.py index df1359ae..890250db 100644 --- a/src/ptbench/data/shenzhen/fold_0.py +++ b/src/ptbench/config/data/shenzhen/fold_0.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-0.json") diff --git a/src/ptbench/data/shenzhen/fold_1.py b/src/ptbench/config/data/shenzhen/fold_1.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_1.py rename to src/ptbench/config/data/shenzhen/fold_1.py index 03be3fa6..ff95e0d0 100644 --- a/src/ptbench/data/shenzhen/fold_1.py +++ b/src/ptbench/config/data/shenzhen/fold_1.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-1.json") diff --git a/src/ptbench/data/shenzhen/fold_2.py b/src/ptbench/config/data/shenzhen/fold_2.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_2.py rename to src/ptbench/config/data/shenzhen/fold_2.py index f4bd72d8..db16495c 100644 --- a/src/ptbench/data/shenzhen/fold_2.py +++ b/src/ptbench/config/data/shenzhen/fold_2.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-2.json") diff --git a/src/ptbench/data/shenzhen/fold_3.py b/src/ptbench/config/data/shenzhen/fold_3.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_3.py rename to src/ptbench/config/data/shenzhen/fold_3.py index b41c7886..d0321c86 100644 --- a/src/ptbench/data/shenzhen/fold_3.py +++ b/src/ptbench/config/data/shenzhen/fold_3.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-3.json") diff --git a/src/ptbench/data/shenzhen/fold_4.py b/src/ptbench/config/data/shenzhen/fold_4.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_4.py rename to src/ptbench/config/data/shenzhen/fold_4.py index f9105989..f6760358 100644 --- a/src/ptbench/data/shenzhen/fold_4.py +++ b/src/ptbench/config/data/shenzhen/fold_4.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-4.json") diff --git a/src/ptbench/data/shenzhen/fold_5.py b/src/ptbench/config/data/shenzhen/fold_5.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_5.py rename to src/ptbench/config/data/shenzhen/fold_5.py index 7882e899..6d77a840 100644 --- a/src/ptbench/data/shenzhen/fold_5.py +++ b/src/ptbench/config/data/shenzhen/fold_5.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-5.json") diff --git a/src/ptbench/data/shenzhen/fold_6.py b/src/ptbench/config/data/shenzhen/fold_6.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_6.py rename to src/ptbench/config/data/shenzhen/fold_6.py index 4d11aca0..3ecd646e 100644 --- a/src/ptbench/data/shenzhen/fold_6.py +++ b/src/ptbench/config/data/shenzhen/fold_6.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-6.json") diff --git a/src/ptbench/data/shenzhen/fold_7.py b/src/ptbench/config/data/shenzhen/fold_7.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_7.py rename to src/ptbench/config/data/shenzhen/fold_7.py index 8a794345..61ba5d27 100644 --- a/src/ptbench/data/shenzhen/fold_7.py +++ b/src/ptbench/config/data/shenzhen/fold_7.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-7.json") diff --git a/src/ptbench/data/shenzhen/fold_8.py b/src/ptbench/config/data/shenzhen/fold_8.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_8.py rename to src/ptbench/config/data/shenzhen/fold_8.py index 9abe5fa4..a03121d5 100644 --- a/src/ptbench/data/shenzhen/fold_8.py +++ b/src/ptbench/config/data/shenzhen/fold_8.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-8.json") diff --git a/src/ptbench/data/shenzhen/fold_9.py b/src/ptbench/config/data/shenzhen/fold_9.py similarity index 66% rename from src/ptbench/data/shenzhen/fold_9.py rename to src/ptbench/config/data/shenzhen/fold_9.py index 06fab974..168031c8 100644 --- a/src/ptbench/data/shenzhen/fold_9.py +++ b/src/ptbench/config/data/shenzhen/fold_9.py @@ -5,9 +5,10 @@ Database reference: [MONTGOMERY-SHENZHEN-2014]_ -See :py:class:`.shenzhen.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.shenzhen.datamodule.DataModule` for +technical details. """ -from .datamodule import DataModule +from ptbench.config.data.shenzhen.datamodule import DataModule datamodule = DataModule("fold-9.json") diff --git a/src/ptbench/data/tbx11k/__init__.py b/src/ptbench/config/data/tbpoc/__init__.py similarity index 100% rename from src/ptbench/data/tbx11k/__init__.py rename to src/ptbench/config/data/tbpoc/__init__.py diff --git a/src/ptbench/data/tbpoc/datamodule.py b/src/ptbench/config/data/tbpoc/datamodule.py similarity index 84% rename from src/ptbench/data/tbpoc/datamodule.py rename to src/ptbench/config/data/tbpoc/datamodule.py index f564e232..42a3a10f 100644 --- a/src/ptbench/data/tbpoc/datamodule.py +++ b/src/ptbench/config/data/tbpoc/datamodule.py @@ -9,13 +9,17 @@ import PIL.Image from torchvision.transforms.functional import center_crop, to_tensor -from ...utils.rc import load_rc -from ..datamodule import CachingDataModule -from ..image_utils import remove_black_borders -from ..split import JSONDatabaseSplit -from ..typing import DatabaseSplit -from ..typing import RawDataLoader as _BaseRawDataLoader -from ..typing import Sample +from ptbench.data.datamodule import CachingDataModule +from ptbench.data.image_utils import remove_black_borders +from ptbench.data.split import JSONDatabaseSplit +from ptbench.data.typing import DatabaseSplit +from ptbench.data.typing import RawDataLoader as _BaseRawDataLoader +from ptbench.data.typing import Sample +from ptbench.utils.rc import load_rc + +CONFIGURATION_KEY_DATADIR = "datadir." + (__name__.rsplit(".", 2)[-2]) +"""Key to search for in the configuration file for the root directory of this +database.""" class RawDataLoader(_BaseRawDataLoader): @@ -25,9 +29,9 @@ class RawDataLoader(_BaseRawDataLoader): """This variable contains the base directory where the database raw data is stored.""" - def __init__(self, config_variable: str = "datadir.tbpoc"): + def __init__(self): self.datadir = load_rc().get( - config_variable, os.path.realpath(os.curdir) + CONFIGURATION_KEY_DATADIR, os.path.realpath(os.curdir) ) def sample(self, sample: tuple[str, int]) -> Sample: diff --git a/src/ptbench/data/tbpoc/fold-0.json b/src/ptbench/config/data/tbpoc/fold-0.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-0.json rename to src/ptbench/config/data/tbpoc/fold-0.json diff --git a/src/ptbench/data/tbpoc/fold-1.json b/src/ptbench/config/data/tbpoc/fold-1.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-1.json rename to src/ptbench/config/data/tbpoc/fold-1.json diff --git a/src/ptbench/data/tbpoc/fold-2.json b/src/ptbench/config/data/tbpoc/fold-2.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-2.json rename to src/ptbench/config/data/tbpoc/fold-2.json diff --git a/src/ptbench/data/tbpoc/fold-3.json b/src/ptbench/config/data/tbpoc/fold-3.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-3.json rename to src/ptbench/config/data/tbpoc/fold-3.json diff --git a/src/ptbench/data/tbpoc/fold-4.json b/src/ptbench/config/data/tbpoc/fold-4.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-4.json rename to src/ptbench/config/data/tbpoc/fold-4.json diff --git a/src/ptbench/data/tbpoc/fold-5.json b/src/ptbench/config/data/tbpoc/fold-5.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-5.json rename to src/ptbench/config/data/tbpoc/fold-5.json diff --git a/src/ptbench/data/tbpoc/fold-6.json b/src/ptbench/config/data/tbpoc/fold-6.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-6.json rename to src/ptbench/config/data/tbpoc/fold-6.json diff --git a/src/ptbench/data/tbpoc/fold-7.json b/src/ptbench/config/data/tbpoc/fold-7.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-7.json rename to src/ptbench/config/data/tbpoc/fold-7.json diff --git a/src/ptbench/data/tbpoc/fold-8.json b/src/ptbench/config/data/tbpoc/fold-8.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-8.json rename to src/ptbench/config/data/tbpoc/fold-8.json diff --git a/src/ptbench/data/tbpoc/fold-9.json b/src/ptbench/config/data/tbpoc/fold-9.json similarity index 100% rename from src/ptbench/data/tbpoc/fold-9.json rename to src/ptbench/config/data/tbpoc/fold-9.json diff --git a/src/ptbench/data/tbpoc/fold_0.py b/src/ptbench/config/data/tbpoc/fold_0.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_0.py rename to src/ptbench/config/data/tbpoc/fold_0.py index 5c452504..e3a0d242 100644 --- a/src/ptbench/data/tbpoc/fold_0.py +++ b/src/ptbench/config/data/tbpoc/fold_0.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-0.json") diff --git a/src/ptbench/data/tbpoc/fold_1.py b/src/ptbench/config/data/tbpoc/fold_1.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_1.py rename to src/ptbench/config/data/tbpoc/fold_1.py index a2fe6083..b6a04095 100644 --- a/src/ptbench/data/tbpoc/fold_1.py +++ b/src/ptbench/config/data/tbpoc/fold_1.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-1.json") diff --git a/src/ptbench/data/tbpoc/fold_2.py b/src/ptbench/config/data/tbpoc/fold_2.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_2.py rename to src/ptbench/config/data/tbpoc/fold_2.py index f0aa508c..c821f0cc 100644 --- a/src/ptbench/data/tbpoc/fold_2.py +++ b/src/ptbench/config/data/tbpoc/fold_2.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-2.json") diff --git a/src/ptbench/data/tbpoc/fold_3.py b/src/ptbench/config/data/tbpoc/fold_3.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_3.py rename to src/ptbench/config/data/tbpoc/fold_3.py index b13213c7..c5c9fa7d 100644 --- a/src/ptbench/data/tbpoc/fold_3.py +++ b/src/ptbench/config/data/tbpoc/fold_3.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-3.json") diff --git a/src/ptbench/data/tbpoc/fold_4.py b/src/ptbench/config/data/tbpoc/fold_4.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_4.py rename to src/ptbench/config/data/tbpoc/fold_4.py index fe153fc6..9b3b74d9 100644 --- a/src/ptbench/data/tbpoc/fold_4.py +++ b/src/ptbench/config/data/tbpoc/fold_4.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-4.json") diff --git a/src/ptbench/data/tbpoc/fold_5.py b/src/ptbench/config/data/tbpoc/fold_5.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_5.py rename to src/ptbench/config/data/tbpoc/fold_5.py index 7759ccc7..7a9947dc 100644 --- a/src/ptbench/data/tbpoc/fold_5.py +++ b/src/ptbench/config/data/tbpoc/fold_5.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-5.json") diff --git a/src/ptbench/data/tbpoc/fold_6.py b/src/ptbench/config/data/tbpoc/fold_6.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_6.py rename to src/ptbench/config/data/tbpoc/fold_6.py index 35be05a4..0e6a7349 100644 --- a/src/ptbench/data/tbpoc/fold_6.py +++ b/src/ptbench/config/data/tbpoc/fold_6.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-6.json") diff --git a/src/ptbench/data/tbpoc/fold_7.py b/src/ptbench/config/data/tbpoc/fold_7.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_7.py rename to src/ptbench/config/data/tbpoc/fold_7.py index da5bec1e..bb257c8e 100644 --- a/src/ptbench/data/tbpoc/fold_7.py +++ b/src/ptbench/config/data/tbpoc/fold_7.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-7.json") diff --git a/src/ptbench/data/tbpoc/fold_8.py b/src/ptbench/config/data/tbpoc/fold_8.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_8.py rename to src/ptbench/config/data/tbpoc/fold_8.py index 65339cc0..790f13c9 100644 --- a/src/ptbench/data/tbpoc/fold_8.py +++ b/src/ptbench/config/data/tbpoc/fold_8.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-8.json") diff --git a/src/ptbench/data/tbpoc/fold_9.py b/src/ptbench/config/data/tbpoc/fold_9.py similarity index 65% rename from src/ptbench/data/tbpoc/fold_9.py rename to src/ptbench/config/data/tbpoc/fold_9.py index dd42e068..a53852a6 100644 --- a/src/ptbench/data/tbpoc/fold_9.py +++ b/src/ptbench/config/data/tbpoc/fold_9.py @@ -5,9 +5,10 @@ Database reference: [TB-POC-2018]_ -See :py:class:`.tbpoc.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbpoc.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbpoc.datamodule import DataModule datamodule = DataModule("fold-9.json") diff --git a/src/ptbench/models/config/__init__.py b/src/ptbench/config/data/tbx11k/__init__.py similarity index 100% rename from src/ptbench/models/config/__init__.py rename to src/ptbench/config/data/tbx11k/__init__.py diff --git a/src/ptbench/data/tbx11k/datamodule.py b/src/ptbench/config/data/tbx11k/datamodule.py similarity index 93% rename from src/ptbench/data/tbx11k/datamodule.py rename to src/ptbench/config/data/tbx11k/datamodule.py index 45cab752..a5959e82 100644 --- a/src/ptbench/data/tbx11k/datamodule.py +++ b/src/ptbench/config/data/tbx11k/datamodule.py @@ -10,12 +10,17 @@ import PIL.Image from torchvision.transforms.functional import to_tensor -from ...utils.rc import load_rc -from ..datamodule import CachingDataModule -from ..split import JSONDatabaseSplit -from ..typing import DatabaseSplit -from ..typing import RawDataLoader as _BaseRawDataLoader -from ..typing import Sample +from ptbench.data.datamodule import CachingDataModule +from ptbench.data.split import JSONDatabaseSplit +from ptbench.data.typing import DatabaseSplit +from ptbench.data.typing import RawDataLoader as _BaseRawDataLoader +from ptbench.data.typing import Sample +from ptbench.utils.rc import load_rc + +CONFIGURATION_KEY_DATADIR = "datadir." + (__name__.rsplit(".", 2)[-2]) +"""Key to search for in the configuration file for the root directory of this +database.""" + BoundingBoxAnnotation: typing.TypeAlias = tuple[int, int, int, int, int] """Location of TB radiological findings (latent or active) @@ -55,7 +60,7 @@ class RawDataLoader(_BaseRawDataLoader): def __init__(self): self.datadir = load_rc().get( - "datadir.tbx11k", os.path.realpath(os.curdir) + CONFIGURATION_KEY_DATADIR, os.path.realpath(os.curdir) ) def sample(self, sample: DatabaseSample) -> Sample: diff --git a/src/ptbench/data/tbx11k/make_splits_from_database.py b/src/ptbench/config/data/tbx11k/make_splits_from_database.py similarity index 100% rename from src/ptbench/data/tbx11k/make_splits_from_database.py rename to src/ptbench/config/data/tbx11k/make_splits_from_database.py diff --git a/src/ptbench/data/tbx11k/v1-fold-0.json b/src/ptbench/config/data/tbx11k/v1-fold-0.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-0.json rename to src/ptbench/config/data/tbx11k/v1-fold-0.json diff --git a/src/ptbench/data/tbx11k/v1-fold-1.json b/src/ptbench/config/data/tbx11k/v1-fold-1.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-1.json rename to src/ptbench/config/data/tbx11k/v1-fold-1.json diff --git a/src/ptbench/data/tbx11k/v1-fold-2.json b/src/ptbench/config/data/tbx11k/v1-fold-2.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-2.json rename to src/ptbench/config/data/tbx11k/v1-fold-2.json diff --git a/src/ptbench/data/tbx11k/v1-fold-3.json b/src/ptbench/config/data/tbx11k/v1-fold-3.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-3.json rename to src/ptbench/config/data/tbx11k/v1-fold-3.json diff --git a/src/ptbench/data/tbx11k/v1-fold-4.json b/src/ptbench/config/data/tbx11k/v1-fold-4.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-4.json rename to src/ptbench/config/data/tbx11k/v1-fold-4.json diff --git a/src/ptbench/data/tbx11k/v1-fold-5.json b/src/ptbench/config/data/tbx11k/v1-fold-5.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-5.json rename to src/ptbench/config/data/tbx11k/v1-fold-5.json diff --git a/src/ptbench/data/tbx11k/v1-fold-6.json b/src/ptbench/config/data/tbx11k/v1-fold-6.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-6.json rename to src/ptbench/config/data/tbx11k/v1-fold-6.json diff --git a/src/ptbench/data/tbx11k/v1-fold-7.json b/src/ptbench/config/data/tbx11k/v1-fold-7.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-7.json rename to src/ptbench/config/data/tbx11k/v1-fold-7.json diff --git a/src/ptbench/data/tbx11k/v1-fold-8.json b/src/ptbench/config/data/tbx11k/v1-fold-8.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-8.json rename to src/ptbench/config/data/tbx11k/v1-fold-8.json diff --git a/src/ptbench/data/tbx11k/v1-fold-9.json b/src/ptbench/config/data/tbx11k/v1-fold-9.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-fold-9.json rename to src/ptbench/config/data/tbx11k/v1-fold-9.json diff --git a/src/ptbench/data/tbx11k/v1-healthy-vs-atb.json b/src/ptbench/config/data/tbx11k/v1-healthy-vs-atb.json similarity index 100% rename from src/ptbench/data/tbx11k/v1-healthy-vs-atb.json rename to src/ptbench/config/data/tbx11k/v1-healthy-vs-atb.json diff --git a/src/ptbench/data/tbx11k/v1_fold_0.py b/src/ptbench/config/data/tbx11k/v1_fold_0.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_0.py rename to src/ptbench/config/data/tbx11k/v1_fold_0.py index ecf1e295..9ba42d52 100644 --- a/src/ptbench/data/tbx11k/v1_fold_0.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_0.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-0.json") diff --git a/src/ptbench/data/tbx11k/v1_fold_1.py b/src/ptbench/config/data/tbx11k/v1_fold_1.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_1.py rename to src/ptbench/config/data/tbx11k/v1_fold_1.py index b74f9ac9..ca3fe104 100644 --- a/src/ptbench/data/tbx11k/v1_fold_1.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_1.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-1.json") diff --git a/src/ptbench/data/tbx11k/v1_fold_2.py b/src/ptbench/config/data/tbx11k/v1_fold_2.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_2.py rename to src/ptbench/config/data/tbx11k/v1_fold_2.py index c52f415a..c3ec4fe4 100644 --- a/src/ptbench/data/tbx11k/v1_fold_2.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_2.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-2.json") diff --git a/src/ptbench/data/tbx11k/v1_fold_3.py b/src/ptbench/config/data/tbx11k/v1_fold_3.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_3.py rename to src/ptbench/config/data/tbx11k/v1_fold_3.py index 32794848..09fb16b2 100644 --- a/src/ptbench/data/tbx11k/v1_fold_3.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_3.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-3.json") diff --git a/src/ptbench/data/tbx11k/v1_fold_4.py b/src/ptbench/config/data/tbx11k/v1_fold_4.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_4.py rename to src/ptbench/config/data/tbx11k/v1_fold_4.py index 1c149232..8f96d1e5 100644 --- a/src/ptbench/data/tbx11k/v1_fold_4.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_4.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-4.json") diff --git a/src/ptbench/data/tbx11k/v1_fold_5.py b/src/ptbench/config/data/tbx11k/v1_fold_5.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_5.py rename to src/ptbench/config/data/tbx11k/v1_fold_5.py index 2a74b219..8ced06d4 100644 --- a/src/ptbench/data/tbx11k/v1_fold_5.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_5.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-5.json") diff --git a/src/ptbench/data/tbx11k/v1_fold_6.py b/src/ptbench/config/data/tbx11k/v1_fold_6.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_6.py rename to src/ptbench/config/data/tbx11k/v1_fold_6.py index 67562a35..28e9f16a 100644 --- a/src/ptbench/data/tbx11k/v1_fold_6.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_6.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-6.json") diff --git a/src/ptbench/data/tbx11k/v1_fold_7.py b/src/ptbench/config/data/tbx11k/v1_fold_7.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_7.py rename to src/ptbench/config/data/tbx11k/v1_fold_7.py index 3d80b71e..09886b94 100644 --- a/src/ptbench/data/tbx11k/v1_fold_7.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_7.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-7.json") diff --git a/src/ptbench/data/tbx11k/v1_fold_8.py b/src/ptbench/config/data/tbx11k/v1_fold_8.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_8.py rename to src/ptbench/config/data/tbx11k/v1_fold_8.py index f8e45fe1..5fd2dd23 100644 --- a/src/ptbench/data/tbx11k/v1_fold_8.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_8.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-8.json") diff --git a/src/ptbench/data/tbx11k/v1_fold_9.py b/src/ptbench/config/data/tbx11k/v1_fold_9.py similarity index 67% rename from src/ptbench/data/tbx11k/v1_fold_9.py rename to src/ptbench/config/data/tbx11k/v1_fold_9.py index 0d394354..440f724f 100644 --- a/src/ptbench/data/tbx11k/v1_fold_9.py +++ b/src/ptbench/config/data/tbx11k/v1_fold_9.py @@ -6,9 +6,10 @@ cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-fold-9.json") diff --git a/src/ptbench/data/tbx11k/v1_healthy_vs_atb.py b/src/ptbench/config/data/tbx11k/v1_healthy_vs_atb.py similarity index 81% rename from src/ptbench/data/tbx11k/v1_healthy_vs_atb.py rename to src/ptbench/config/data/tbx11k/v1_healthy_vs_atb.py index 0845f03b..785b6bfb 100644 --- a/src/ptbench/data/tbx11k/v1_healthy_vs_atb.py +++ b/src/ptbench/config/data/tbx11k/v1_healthy_vs_atb.py @@ -27,9 +27,10 @@ Split v1 contains healthy subjects against active TB cases (total samples = - Active TB only: 157 - Total: 957 -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v1-healthy-vs-atb.json") diff --git a/src/ptbench/data/tbx11k/v2-fold-0.json b/src/ptbench/config/data/tbx11k/v2-fold-0.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-0.json rename to src/ptbench/config/data/tbx11k/v2-fold-0.json diff --git a/src/ptbench/data/tbx11k/v2-fold-1.json b/src/ptbench/config/data/tbx11k/v2-fold-1.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-1.json rename to src/ptbench/config/data/tbx11k/v2-fold-1.json diff --git a/src/ptbench/data/tbx11k/v2-fold-2.json b/src/ptbench/config/data/tbx11k/v2-fold-2.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-2.json rename to src/ptbench/config/data/tbx11k/v2-fold-2.json diff --git a/src/ptbench/data/tbx11k/v2-fold-3.json b/src/ptbench/config/data/tbx11k/v2-fold-3.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-3.json rename to src/ptbench/config/data/tbx11k/v2-fold-3.json diff --git a/src/ptbench/data/tbx11k/v2-fold-4.json b/src/ptbench/config/data/tbx11k/v2-fold-4.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-4.json rename to src/ptbench/config/data/tbx11k/v2-fold-4.json diff --git a/src/ptbench/data/tbx11k/v2-fold-5.json b/src/ptbench/config/data/tbx11k/v2-fold-5.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-5.json rename to src/ptbench/config/data/tbx11k/v2-fold-5.json diff --git a/src/ptbench/data/tbx11k/v2-fold-6.json b/src/ptbench/config/data/tbx11k/v2-fold-6.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-6.json rename to src/ptbench/config/data/tbx11k/v2-fold-6.json diff --git a/src/ptbench/data/tbx11k/v2-fold-7.json b/src/ptbench/config/data/tbx11k/v2-fold-7.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-7.json rename to src/ptbench/config/data/tbx11k/v2-fold-7.json diff --git a/src/ptbench/data/tbx11k/v2-fold-8.json b/src/ptbench/config/data/tbx11k/v2-fold-8.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-8.json rename to src/ptbench/config/data/tbx11k/v2-fold-8.json diff --git a/src/ptbench/data/tbx11k/v2-fold-9.json b/src/ptbench/config/data/tbx11k/v2-fold-9.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-fold-9.json rename to src/ptbench/config/data/tbx11k/v2-fold-9.json diff --git a/src/ptbench/data/tbx11k/v2-others-vs-atb.json b/src/ptbench/config/data/tbx11k/v2-others-vs-atb.json similarity index 100% rename from src/ptbench/data/tbx11k/v2-others-vs-atb.json rename to src/ptbench/config/data/tbx11k/v2-others-vs-atb.json diff --git a/src/ptbench/data/tbx11k/v2_fold_0.py b/src/ptbench/config/data/tbx11k/v2_fold_0.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_0.py rename to src/ptbench/config/data/tbx11k/v2_fold_0.py index 8ccb73ed..c713c479 100644 --- a/src/ptbench/data/tbx11k/v2_fold_0.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_0.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-0.json") diff --git a/src/ptbench/data/tbx11k/v2_fold_1.py b/src/ptbench/config/data/tbx11k/v2_fold_1.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_1.py rename to src/ptbench/config/data/tbx11k/v2_fold_1.py index 9e1c3aca..10b3b183 100644 --- a/src/ptbench/data/tbx11k/v2_fold_1.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_1.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-1.json") diff --git a/src/ptbench/data/tbx11k/v2_fold_2.py b/src/ptbench/config/data/tbx11k/v2_fold_2.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_2.py rename to src/ptbench/config/data/tbx11k/v2_fold_2.py index 24a00ece..f7fd10a6 100644 --- a/src/ptbench/data/tbx11k/v2_fold_2.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_2.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-2.json") diff --git a/src/ptbench/data/tbx11k/v2_fold_3.py b/src/ptbench/config/data/tbx11k/v2_fold_3.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_3.py rename to src/ptbench/config/data/tbx11k/v2_fold_3.py index 9da2630d..b744251d 100644 --- a/src/ptbench/data/tbx11k/v2_fold_3.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_3.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-3.json") diff --git a/src/ptbench/data/tbx11k/v2_fold_4.py b/src/ptbench/config/data/tbx11k/v2_fold_4.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_4.py rename to src/ptbench/config/data/tbx11k/v2_fold_4.py index 0555b567..17215495 100644 --- a/src/ptbench/data/tbx11k/v2_fold_4.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_4.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-4.json") diff --git a/src/ptbench/data/tbx11k/v2_fold_5.py b/src/ptbench/config/data/tbx11k/v2_fold_5.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_5.py rename to src/ptbench/config/data/tbx11k/v2_fold_5.py index 1fddcc2f..41a5ba43 100644 --- a/src/ptbench/data/tbx11k/v2_fold_5.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_5.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-5.json") diff --git a/src/ptbench/data/tbx11k/v2_fold_6.py b/src/ptbench/config/data/tbx11k/v2_fold_6.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_6.py rename to src/ptbench/config/data/tbx11k/v2_fold_6.py index d9085af1..0f82163d 100644 --- a/src/ptbench/data/tbx11k/v2_fold_6.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_6.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-6.json") diff --git a/src/ptbench/data/tbx11k/v2_fold_7.py b/src/ptbench/config/data/tbx11k/v2_fold_7.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_7.py rename to src/ptbench/config/data/tbx11k/v2_fold_7.py index b324e129..6f3d958b 100644 --- a/src/ptbench/data/tbx11k/v2_fold_7.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_7.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-7.json") diff --git a/src/ptbench/data/tbx11k/v2_fold_8.py b/src/ptbench/config/data/tbx11k/v2_fold_8.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_8.py rename to src/ptbench/config/data/tbx11k/v2_fold_8.py index 31ed229a..3b10a652 100644 --- a/src/ptbench/data/tbx11k/v2_fold_8.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_8.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-8.json") diff --git a/src/ptbench/data/tbx11k/v2_fold_9.py b/src/ptbench/config/data/tbx11k/v2_fold_9.py similarity index 68% rename from src/ptbench/data/tbx11k/v2_fold_9.py rename to src/ptbench/config/data/tbx11k/v2_fold_9.py index 74db9a28..86922305 100644 --- a/src/ptbench/data/tbx11k/v2_fold_9.py +++ b/src/ptbench/config/data/tbx11k/v2_fold_9.py @@ -6,9 +6,10 @@ TB vs. active TB cases). Database reference: [TBX11K-2020]_ -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-fold-9.json") diff --git a/src/ptbench/data/tbx11k/v2_others_vs_atb.py b/src/ptbench/config/data/tbx11k/v2_others_vs_atb.py similarity index 83% rename from src/ptbench/data/tbx11k/v2_others_vs_atb.py rename to src/ptbench/config/data/tbx11k/v2_others_vs_atb.py index b5f78019..a5e8c480 100644 --- a/src/ptbench/data/tbx11k/v2_others_vs_atb.py +++ b/src/ptbench/config/data/tbx11k/v2_others_vs_atb.py @@ -27,9 +27,10 @@ active TB cases (total samples = 8369): - Active TB only: 157 - Total: 1793 -See :py:class:`.tbx11k.datamodule.DataModule` for technical details. +See :py:class:`ptbench.config.data.tbx11k.datamodule.DataModule` for technical +details. """ -from .datamodule import DataModule +from ptbench.config.data.tbx11k.datamodule import DataModule datamodule = DataModule("v2-others-vs-atb.json") diff --git a/src/ptbench/config/models/__init__.py b/src/ptbench/config/models/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/ptbench/models/config/alexnet.py b/src/ptbench/config/models/alexnet.py similarity index 90% rename from src/ptbench/models/config/alexnet.py rename to src/ptbench/config/models/alexnet.py index 9adcfec8..fce6ba64 100644 --- a/src/ptbench/models/config/alexnet.py +++ b/src/ptbench/config/models/alexnet.py @@ -4,7 +4,7 @@ """AlexNet_, to be trained from scratch. This configuration contains a version of AlexNet_ (c.f. `TorchVision's -page <alexnet_pytorch_>`), modified for a variable number of outputs +page <alexnet-pytorch_>`_), modified for a variable number of outputs (defaults to 1). """ diff --git a/src/ptbench/models/config/alexnet_pretrained.py b/src/ptbench/config/models/alexnet_pretrained.py similarity index 100% rename from src/ptbench/models/config/alexnet_pretrained.py rename to src/ptbench/config/models/alexnet_pretrained.py diff --git a/src/ptbench/models/config/densenet.py b/src/ptbench/config/models/densenet.py similarity index 100% rename from src/ptbench/models/config/densenet.py rename to src/ptbench/config/models/densenet.py diff --git a/src/ptbench/models/config/densenet_pretrained.py b/src/ptbench/config/models/densenet_pretrained.py similarity index 100% rename from src/ptbench/models/config/densenet_pretrained.py rename to src/ptbench/config/models/densenet_pretrained.py diff --git a/src/ptbench/models/config/densenet_rs.py b/src/ptbench/config/models/densenet_rs.py similarity index 100% rename from src/ptbench/models/config/densenet_rs.py rename to src/ptbench/config/models/densenet_rs.py diff --git a/src/ptbench/models/config/logistic_regression.py b/src/ptbench/config/models/logistic_regression.py similarity index 100% rename from src/ptbench/models/config/logistic_regression.py rename to src/ptbench/config/models/logistic_regression.py diff --git a/src/ptbench/models/config/mlp.py b/src/ptbench/config/models/mlp.py similarity index 100% rename from src/ptbench/models/config/mlp.py rename to src/ptbench/config/models/mlp.py diff --git a/src/ptbench/models/config/pasa.py b/src/ptbench/config/models/pasa.py similarity index 100% rename from src/ptbench/models/config/pasa.py rename to src/ptbench/config/models/pasa.py diff --git a/tests/test_cli.py b/tests/test_cli.py index 888794b4..04fa19e4 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -62,8 +62,8 @@ def test_config_list(): runner = CliRunner() result = runner.invoke(list) _assert_exit_0(result) - assert "module: ptbench.data" in result.output - assert "module: ptbench.models.config" in result.output + assert "module: ptbench.config.data" in result.output + assert "module: ptbench.config.models" in result.output @pytest.mark.skip(reason="Test need to be updated") @@ -72,8 +72,8 @@ def test_config_list_v(): result = CliRunner().invoke(list, ["--verbose"]) _assert_exit_0(result) - assert "module: ptbench.data" in result.output - assert "module: ptbench.models.config" in result.output + assert "module: ptbench.config.data" in result.output + assert "module: ptbench.config.models" in result.output def test_config_describe_help(): diff --git a/tests/test_hivtb.py b/tests/test_hivtb.py index eb6513f0..13119812 100644 --- a/tests/test_hivtb.py +++ b/tests/test_hivtb.py @@ -33,7 +33,7 @@ def id_function(val): def test_protocol_consistency( database_checkers, split: str, lenghts: dict[str, int] ): - from ptbench.data.hivtb.datamodule import make_split + from ptbench.config.data.hivtb.datamodule import make_split database_checkers.check_split( make_split(f"{split}.json"), @@ -69,7 +69,7 @@ def test_protocol_consistency( ) def test_loading(database_checkers, name: str, dataset: str): datamodule = importlib.import_module( - f".{name}", "ptbench.data.hivtb" + f".{name}", "ptbench.config.data.hivtb" ).datamodule datamodule.model_transforms = [] # should be done before setup() diff --git a/tests/test_indian.py b/tests/test_indian.py index de428b16..e86b56f6 100644 --- a/tests/test_indian.py +++ b/tests/test_indian.py @@ -37,7 +37,7 @@ def id_function(val): def test_protocol_consistency( database_checkers, split: str, lenghts: dict[str, int] ): - from ptbench.data.indian.datamodule import make_split + from ptbench.config.data.indian.datamodule import make_split database_checkers.check_split( make_split(f"{split}.json"), @@ -74,7 +74,7 @@ def test_protocol_consistency( ) def test_loading(database_checkers, name: str, dataset: str): datamodule = importlib.import_module( - f".{name}", "ptbench.data.indian" + f".{name}", "ptbench.config.data.indian" ).datamodule datamodule.model_transforms = [] # should be done before setup() diff --git a/tests/test_montgomery.py b/tests/test_montgomery.py index 973350aa..1e8227d3 100644 --- a/tests/test_montgomery.py +++ b/tests/test_montgomery.py @@ -34,7 +34,7 @@ def id_function(val): def test_protocol_consistency( database_checkers, split: str, lenghts: dict[str, int] ): - from ptbench.data.montgomery.datamodule import make_split + from ptbench.config.data.montgomery.datamodule import make_split database_checkers.check_split( make_split(f"{split}.json"), @@ -71,7 +71,7 @@ def test_protocol_consistency( ) def test_loading(database_checkers, name: str, dataset: str): datamodule = importlib.import_module( - f".{name}", "ptbench.data.montgomery" + f".{name}", "ptbench.config.data.montgomery" ).datamodule datamodule.model_transforms = [] # should be done before setup() diff --git a/tests/test_montgomery_shenzhen.py b/tests/test_montgomery_shenzhen.py index 4618e25f..9af425a5 100644 --- a/tests/test_montgomery_shenzhen.py +++ b/tests/test_montgomery_shenzhen.py @@ -26,23 +26,23 @@ import pytest ) def test_split_consistency(name: str): montgomery = importlib.import_module( - f".{name}", "ptbench.data.montgomery" + f".{name}", "ptbench.config.data.montgomery" ).datamodule shenzhen = importlib.import_module( - f".{name}", "ptbench.data.shenzhen" + f".{name}", "ptbench.config.data.shenzhen" ).datamodule combined = importlib.import_module( - f".{name}", "ptbench.data.montgomery_shenzhen" + f".{name}", "ptbench.config.data.montgomery_shenzhen" ).datamodule MontgomeryLoader = importlib.import_module( - ".datamodule", "ptbench.data.montgomery" + ".datamodule", "ptbench.config.data.montgomery" ).RawDataLoader ShenzhenLoader = importlib.import_module( - ".datamodule", "ptbench.data.shenzhen" + ".datamodule", "ptbench.config.data.shenzhen" ).RawDataLoader for split in ("train", "validation", "test"): diff --git a/tests/test_montgomery_shenzhen_indian.py b/tests/test_montgomery_shenzhen_indian.py index 7ff4985b..b3c7f5f5 100644 --- a/tests/test_montgomery_shenzhen_indian.py +++ b/tests/test_montgomery_shenzhen_indian.py @@ -26,31 +26,31 @@ import pytest ) def test_split_consistency(name: str): montgomery = importlib.import_module( - f".{name}", "ptbench.data.montgomery" + f".{name}", "ptbench.config.data.montgomery" ).datamodule shenzhen = importlib.import_module( - f".{name}", "ptbench.data.shenzhen" + f".{name}", "ptbench.config.data.shenzhen" ).datamodule indian = importlib.import_module( - f".{name}", "ptbench.data.indian" + f".{name}", "ptbench.config.data.indian" ).datamodule combined = importlib.import_module( - f".{name}", "ptbench.data.montgomery_shenzhen_indian" + f".{name}", "ptbench.config.data.montgomery_shenzhen_indian" ).datamodule MontgomeryLoader = importlib.import_module( - ".datamodule", "ptbench.data.montgomery" + ".datamodule", "ptbench.config.data.montgomery" ).RawDataLoader ShenzhenLoader = importlib.import_module( - ".datamodule", "ptbench.data.shenzhen" + ".datamodule", "ptbench.config.data.shenzhen" ).RawDataLoader IndianLoader = importlib.import_module( - ".datamodule", "ptbench.data.indian" + ".datamodule", "ptbench.config.data.indian" ).RawDataLoader for split in ("train", "validation", "test"): diff --git a/tests/test_montgomery_shenzhen_indian_padchest.py b/tests/test_montgomery_shenzhen_indian_padchest.py index bb1f7be4..95b59bf1 100644 --- a/tests/test_montgomery_shenzhen_indian_padchest.py +++ b/tests/test_montgomery_shenzhen_indian_padchest.py @@ -16,39 +16,39 @@ import pytest ) def test_split_consistency(name: str, padchest_name: str): montgomery = importlib.import_module( - f".{name}", "ptbench.data.montgomery" + f".{name}", "ptbench.config.data.montgomery" ).datamodule shenzhen = importlib.import_module( - f".{name}", "ptbench.data.shenzhen" + f".{name}", "ptbench.config.data.shenzhen" ).datamodule indian = importlib.import_module( - f".{name}", "ptbench.data.indian" + f".{name}", "ptbench.config.data.indian" ).datamodule padchest = importlib.import_module( - f".{padchest_name}", "ptbench.data.padchest" + f".{padchest_name}", "ptbench.config.data.padchest" ).datamodule combined = importlib.import_module( - f".{name}", "ptbench.data.montgomery_shenzhen_indian_padchest" + f".{name}", "ptbench.config.data.montgomery_shenzhen_indian_padchest" ).datamodule MontgomeryLoader = importlib.import_module( - ".datamodule", "ptbench.data.montgomery" + ".datamodule", "ptbench.config.data.montgomery" ).RawDataLoader ShenzhenLoader = importlib.import_module( - ".datamodule", "ptbench.data.shenzhen" + ".datamodule", "ptbench.config.data.shenzhen" ).RawDataLoader IndianLoader = importlib.import_module( - ".datamodule", "ptbench.data.indian" + ".datamodule", "ptbench.config.data.indian" ).RawDataLoader PadChestLoader = importlib.import_module( - ".datamodule", "ptbench.data.padchest" + ".datamodule", "ptbench.config.data.padchest" ).RawDataLoader for split in ("train", "validation", "test"): diff --git a/tests/test_montgomery_shenzhen_indian_tbx11k.py b/tests/test_montgomery_shenzhen_indian_tbx11k.py index 6abde7b9..71956b49 100644 --- a/tests/test_montgomery_shenzhen_indian_tbx11k.py +++ b/tests/test_montgomery_shenzhen_indian_tbx11k.py @@ -37,39 +37,40 @@ import pytest ) def test_split_consistency(name: str, tbx11k_name: str): montgomery = importlib.import_module( - f".{name}", "ptbench.data.montgomery" + f".{name}", "ptbench.config.data.montgomery" ).datamodule shenzhen = importlib.import_module( - f".{name}", "ptbench.data.shenzhen" + f".{name}", "ptbench.config.data.shenzhen" ).datamodule indian = importlib.import_module( - f".{name}", "ptbench.data.indian" + f".{name}", "ptbench.config.data.indian" ).datamodule tbx11k = importlib.import_module( - f".{tbx11k_name}", "ptbench.data.tbx11k" + f".{tbx11k_name}", "ptbench.config.data.tbx11k" ).datamodule combined = importlib.import_module( - f".{tbx11k_name}", "ptbench.data.montgomery_shenzhen_indian_tbx11k" + f".{tbx11k_name}", + "ptbench.config.data.montgomery_shenzhen_indian_tbx11k", ).datamodule MontgomeryLoader = importlib.import_module( - ".datamodule", "ptbench.data.montgomery" + ".datamodule", "ptbench.config.data.montgomery" ).RawDataLoader ShenzhenLoader = importlib.import_module( - ".datamodule", "ptbench.data.shenzhen" + ".datamodule", "ptbench.config.data.shenzhen" ).RawDataLoader IndianLoader = importlib.import_module( - ".datamodule", "ptbench.data.indian" + ".datamodule", "ptbench.config.data.indian" ).RawDataLoader TBX11kLoader = importlib.import_module( - ".datamodule", "ptbench.data.tbx11k" + ".datamodule", "ptbench.config.data.tbx11k" ).RawDataLoader for split in ("train", "validation", "test"): diff --git a/tests/test_nih_cxr14.py b/tests/test_nih_cxr14.py index 0870c99a..83f45212 100644 --- a/tests/test_nih_cxr14.py +++ b/tests/test_nih_cxr14.py @@ -25,7 +25,7 @@ def id_function(val): def test_protocol_consistency( database_checkers, split: str, lenghts: dict[str, int] ): - from ptbench.data.nih_cxr14.datamodule import make_split + from ptbench.config.data.nih_cxr14.datamodule import make_split database_checkers.check_split( make_split(split), @@ -52,7 +52,7 @@ def test_protocol_consistency( ) def test_loading(database_checkers, name: str, dataset: str): datamodule = importlib.import_module( - f".{name}", "ptbench.data.nih_cxr14" + f".{name}", "ptbench.config.data.nih_cxr14" ).datamodule datamodule.model_transforms = [] # should be done before setup() diff --git a/tests/test_nih_cxr14_padchest.py b/tests/test_nih_cxr14_padchest.py index 4a9379e3..5c5bb5ef 100644 --- a/tests/test_nih_cxr14_padchest.py +++ b/tests/test_nih_cxr14_padchest.py @@ -16,23 +16,23 @@ import pytest ) def test_split_consistency(name: str, padchest_name: str, combined_name: str): nih_cxr14 = importlib.import_module( - f".{name}", "ptbench.data.nih_cxr14" + f".{name}", "ptbench.config.data.nih_cxr14" ).datamodule padchest = importlib.import_module( - f".{padchest_name}", "ptbench.data.padchest" + f".{padchest_name}", "ptbench.config.data.padchest" ).datamodule combined = importlib.import_module( - f".{combined_name}", "ptbench.data.nih_cxr14_padchest" + f".{combined_name}", "ptbench.config.data.nih_cxr14_padchest" ).datamodule CXR14Loader = importlib.import_module( - ".datamodule", "ptbench.data.nih_cxr14" + ".datamodule", "ptbench.config.data.nih_cxr14" ).RawDataLoader PadChestLoader = importlib.import_module( - ".datamodule", "ptbench.data.padchest" + ".datamodule", "ptbench.config.data.padchest" ).RawDataLoader for split in ("train", "validation", "test"): diff --git a/tests/test_padchest.py b/tests/test_padchest.py index 4dd91623..54b42b6d 100644 --- a/tests/test_padchest.py +++ b/tests/test_padchest.py @@ -30,7 +30,7 @@ def id_function(val): def test_protocol_consistency( database_checkers, split: str, lenghts: dict[str, int] ): - from ptbench.data.padchest.datamodule import make_split + from ptbench.config.data.padchest.datamodule import make_split database_checkers.check_split( make_split(split), @@ -56,7 +56,7 @@ def test_protocol_consistency( ) def test_loading(database_checkers, name: str, dataset: str): datamodule = importlib.import_module( - f".{name}", "ptbench.data.padchest" + f".{name}", "ptbench.config.data.padchest" ).datamodule datamodule.model_transforms = [] # should be done before setup() diff --git a/tests/test_shenzhen.py b/tests/test_shenzhen.py index 12532cde..b45ce0db 100644 --- a/tests/test_shenzhen.py +++ b/tests/test_shenzhen.py @@ -34,7 +34,7 @@ def id_function(val): def test_protocol_consistency( database_checkers, split: str, lenghts: dict[str, int] ): - from ptbench.data.shenzhen.datamodule import make_split + from ptbench.config.data.shenzhen.datamodule import make_split database_checkers.check_split( make_split(f"{split}.json"), @@ -71,7 +71,7 @@ def test_protocol_consistency( ) def test_loading(database_checkers, name: str, dataset: str): datamodule = importlib.import_module( - f".{name}", "ptbench.data.shenzhen" + f".{name}", "ptbench.config.data.shenzhen" ).datamodule datamodule.model_transforms = [] # should be done before setup() diff --git a/tests/test_summary.py b/tests/test_summary.py index de8c55c5..0f3a7689 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -4,7 +4,7 @@ import unittest -import ptbench.models.config.pasa as pasa_config +import ptbench.config.models.pasa as pasa_config from ptbench.utils.summary import summary diff --git a/tests/test_tbpoc.py b/tests/test_tbpoc.py index 7125efb1..cf3327d4 100644 --- a/tests/test_tbpoc.py +++ b/tests/test_tbpoc.py @@ -33,7 +33,7 @@ def id_function(val): def test_protocol_consistency( database_checkers, split: str, lenghts: dict[str, int] ): - from ptbench.data.tbpoc.datamodule import make_split + from ptbench.config.data.tbpoc.datamodule import make_split database_checkers.check_split( make_split(f"{split}.json"), @@ -72,7 +72,7 @@ def test_protocol_consistency( ) def test_loading(database_checkers, name: str, dataset: str): datamodule = importlib.import_module( - f".{name}", "ptbench.data.tbpoc" + f".{name}", "ptbench.config.data.tbpoc" ).datamodule datamodule.model_transforms = [] # should be done before setup() diff --git a/tests/test_tbx11k.py b/tests/test_tbx11k.py index 39c54174..0c44a85a 100644 --- a/tests/test_tbx11k.py +++ b/tests/test_tbx11k.py @@ -137,7 +137,7 @@ def test_protocol_consistency( lenghts: dict[str, int], prefixes: typing.Sequence[str], ): - from ptbench.data.tbx11k.datamodule import make_split + from ptbench.config.data.tbx11k.datamodule import make_split database_checkers.check_split( make_split(f"{split}.json"), @@ -187,7 +187,7 @@ def test_loading( database_checkers, name: str, dataset: str, prefixes: typing.Sequence[str] ): datamodule = importlib.import_module( - f".{name}", "ptbench.data.tbx11k" + f".{name}", "ptbench.config.data.tbx11k" ).datamodule datamodule.model_transforms = [] # should be done before setup() -- GitLab