| # AbdCTBench Code |
|
|
| Training and evaluation pipeline for comorbidity prediction from abdominal CT scans. |
|
|
| ## What This Code Does |
|
|
| - Train single-task or multi-task models from CSV + PNG data |
| - Evaluate checkpoints with reproducible metrics |
| - Load released checkpoints in `.safetensors` or `.pth` format |
|
|
| ## Install |
|
|
| ```bash |
| pip install -r requirements.txt |
| ``` |
|
|
| ## Data Layout |
|
|
| Pass `--data_dir` pointing to: |
|
|
| ```text |
| data_dir/ |
| ├── train.csv |
| ├── val.csv |
| ├── test.csv |
| └── data/ |
| ├── <FILE>.png |
| └── ... |
| ``` |
|
|
| `FILE` values in CSV must match PNG basenames. |
|
|
| ## Train |
|
|
| ```bash |
| python train.py \ |
| --model "ResNet-18" \ |
| --data_dir ../AbdCTBench_dataset \ |
| --biomarker_config ./config/biomarker_config_multitask_example.yaml \ |
| --output_dir ./outputs |
| ``` |
|
|
| Reproducibility flags: |
|
|
| - `--seed 42` |
| - `--deterministic` |
|
|
| ## Evaluate |
|
|
| ```bash |
| python test.py \ |
| --data_dir ../AbdCTBench_dataset \ |
| --checkpoint_path ../models/mi_only/ResNet-18_lr1e-05_bs16/best_checkpoint.safetensors \ |
| --biomarker_config ../models/mi_only/ResNet-18_lr1e-05_bs16/biomarker_config.json \ |
| --output_dir ./test_results |
| ``` |
|
|
| Useful options: |
|
|
| - `--save_predictions` |
| - `--save_metrics` |
| - `--only_pred` |
|
|
| ## Checkpoint Folder Contents |
|
|
| Each released model folder contains: |
|
|
| - `best_checkpoint.safetensors` |
| - `config.json` |
| - `biomarker_config.json` |
|
|
| ## DICOM to PNG Pipeline |
|
|
| The DICOM -> STL -> PNG conversion scripts are in: |
|
|
| - `dicom_stl_png_pipeline/` |
|
|
| Key files: |
|
|
| - `dicom2stl.py`: converts a DICOM series (folder/zip) to STL |
| - `stl2png_centered.py`: renders STL to a centered PNG |
| - `parseargs.py` and `utils/`: argument parsing and volume/mesh helper utilities |
| - `requirements.txt` in this folder: extra dependencies for this conversion pipeline |
|
|
| Install pipeline dependencies: |
|
|
| ```bash |
| pip install -r dicom_stl_png_pipeline/requirements.txt |
| ``` |
|
|
| Minimal usage: |
|
|
| ```bash |
| python dicom_stl_png_pipeline/dicom2stl.py \ |
| --type skin \ |
| --output ./sample.stl \ |
| /path/to/dicom_series_folder |
| ``` |
|
|
| ```bash |
| python dicom_stl_png_pipeline/stl2png_centered.py \ |
| ./sample.stl \ |
| ./sample.png |
| ``` |
|
|
| Notes: |
|
|
| - This conversion pipeline is optional and separate from model train/test. |
| - `train.py` and `test.py` consume PNG + CSV data and do not run DICOM conversion internally. |
|
|
| ## Biomarker Config Templates |
|
|
| - `config/biomarker_config_single_task_example.yaml` |
| - `config/biomarker_config_multitask_example.yaml` |
|
|