Spaces:
Sleeping
Sleeping
Simplify documentation and remove README license
Browse files- README.md +0 -3
- docs/configuration.md +4 -34
- docs/getting-started.md +4 -74
- docs/index.md +0 -1
- mkdocs.yml +0 -2
README.md
CHANGED
|
@@ -117,6 +117,3 @@ flowchart TD
|
|
| 117 |
|
| 118 |
For csPCa prediction, the backbone is frozen and a 3-layer MLP (`512 β 256 β 128 β 1`) replaces the classification head.
|
| 119 |
|
| 120 |
-
## License
|
| 121 |
-
|
| 122 |
-
Apache-2.0 β see [LICENSE](LICENSE).
|
|
|
|
| 117 |
|
| 118 |
For csPCa prediction, the backbone is frozen and a 3-layer MLP (`512 β 256 β 128 β 1`) replaces the classification head.
|
| 119 |
|
|
|
|
|
|
|
|
|
docs/configuration.md
CHANGED
|
@@ -1,21 +1,11 @@
|
|
| 1 |
# Configuration
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
Configuration follows a three-level hierarchy:
|
| 6 |
-
|
| 7 |
-
1. **CLI defaults** β Argparse defaults in `run_pirads.py`, `run_cspca.py`, etc.
|
| 8 |
-
2. **YAML overrides** β Values from `--config <file>.yaml` override CLI defaults
|
| 9 |
-
3. **SLURM job name** β If `SLURM_JOB_NAME` is set, it overrides `run_name`
|
| 10 |
|
| 11 |
```bash
|
| 12 |
-
# CLI defaults are overridden by YAML config
|
| 13 |
python run_pirads.py --mode train --config config/config_pirads_train.yaml
|
| 14 |
```
|
| 15 |
|
| 16 |
-
!!! note
|
| 17 |
-
YAML values **always override** CLI defaults for any key present in the YAML file (`args.__dict__.update(config)`). To override a YAML value, edit the YAML file or omit the key from YAML so the CLI default is used.
|
| 18 |
-
|
| 19 |
## PI-RADS Training Parameters
|
| 20 |
|
| 21 |
| Parameter | Default | Description |
|
|
@@ -42,7 +32,7 @@ python run_pirads.py --mode train --config config/config_pirads_train.yaml
|
|
| 42 |
| `wandb` | `False` | Enable Weights & Biases logging |
|
| 43 |
| `project_name` | `Classification_prostate` | W&B project name |
|
| 44 |
| `run_name` | `train_pirads` | Run name for logging |
|
| 45 |
-
| `dry_run` | `False` | Quick test mode |
|
| 46 |
|
| 47 |
## csPCa Training Parameters
|
| 48 |
|
|
@@ -52,22 +42,16 @@ python run_pirads.py --mode train --config config/config_pirads_train.yaml
|
|
| 52 |
| `config` | β | Path to YAML config file |
|
| 53 |
| `data_root` | β | Root folder of images |
|
| 54 |
| `dataset_json` | β | Path to dataset JSON file |
|
| 55 |
-
| `num_classes` | `4` | PI-RADS classes (for backbone initialization) |
|
| 56 |
-
| `mil_mode` | `att_trans` | MIL algorithm for backbone |
|
| 57 |
-
| `tile_count` | `24` | Number of patches per scan |
|
| 58 |
-
| `tile_size` | `64` | Patch spatial size |
|
| 59 |
-
| `depth` | `3` | Slices per patch |
|
| 60 |
-
| `use_heatmap` | `True` | Enable heatmap-guided patch sampling |
|
| 61 |
-
| `workers` | `2` | DataLoader workers |
|
| 62 |
| `checkpoint_pirads` | β | Path to pre-trained PI-RADS model (required for train) |
|
| 63 |
| `checkpoint_cspca` | β | Path to csPCa checkpoint (required for test) |
|
| 64 |
| `epochs` | `30` | Max training epochs |
|
| 65 |
| `batch_size` | `32` | Scans per batch |
|
| 66 |
| `optim_lr` | `2e-4` | Learning rate |
|
| 67 |
| `num_seeds` | `20` | Number of random seeds for CI |
|
| 68 |
-
| `val_every` | `1` | Validation frequency |
|
| 69 |
| `dry_run` | `False` | Quick test mode |
|
| 70 |
|
|
|
|
|
|
|
| 71 |
## Preprocessing Parameters
|
| 72 |
|
| 73 |
| Parameter | Default | Description |
|
|
@@ -131,17 +115,3 @@ python run_pirads.py --mode train --config config/config_pirads_train.yaml
|
|
| 131 |
output_dir: /path/to/processed
|
| 132 |
project_dir: /path/to/WSAttention-Prostate
|
| 133 |
```
|
| 134 |
-
|
| 135 |
-
## Dry-Run Mode
|
| 136 |
-
|
| 137 |
-
The `--dry_run` flag configures a minimal run for quick testing:
|
| 138 |
-
|
| 139 |
-
- Epochs: 2
|
| 140 |
-
- Batch size: 2
|
| 141 |
-
- Workers: 0
|
| 142 |
-
- Seeds: 2
|
| 143 |
-
- W&B: disabled
|
| 144 |
-
|
| 145 |
-
```bash
|
| 146 |
-
python run_pirads.py --mode train --config config/config_pirads_train.yaml --dry_run
|
| 147 |
-
```
|
|
|
|
| 1 |
# Configuration
|
| 2 |
|
| 3 |
+
YAML values always override CLI defaults (`args.__dict__.update(config)`). To override a YAML value, edit the YAML file or omit the key so the CLI default is used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
```bash
|
|
|
|
| 6 |
python run_pirads.py --mode train --config config/config_pirads_train.yaml
|
| 7 |
```
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
## PI-RADS Training Parameters
|
| 10 |
|
| 11 |
| Parameter | Default | Description |
|
|
|
|
| 32 |
| `wandb` | `False` | Enable Weights & Biases logging |
|
| 33 |
| `project_name` | `Classification_prostate` | W&B project name |
|
| 34 |
| `run_name` | `train_pirads` | Run name for logging |
|
| 35 |
+
| `dry_run` | `False` | Quick test mode (2 epochs, batch_size=2, no W&B) |
|
| 36 |
|
| 37 |
## csPCa Training Parameters
|
| 38 |
|
|
|
|
| 42 |
| `config` | β | Path to YAML config file |
|
| 43 |
| `data_root` | β | Root folder of images |
|
| 44 |
| `dataset_json` | β | Path to dataset JSON file |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
| `checkpoint_pirads` | β | Path to pre-trained PI-RADS model (required for train) |
|
| 46 |
| `checkpoint_cspca` | β | Path to csPCa checkpoint (required for test) |
|
| 47 |
| `epochs` | `30` | Max training epochs |
|
| 48 |
| `batch_size` | `32` | Scans per batch |
|
| 49 |
| `optim_lr` | `2e-4` | Learning rate |
|
| 50 |
| `num_seeds` | `20` | Number of random seeds for CI |
|
|
|
|
| 51 |
| `dry_run` | `False` | Quick test mode |
|
| 52 |
|
| 53 |
+
Shared parameters (`num_classes`, `mil_mode`, `tile_count`, `tile_size`, `depth`, `use_heatmap`, `workers`, `val_every`) have the same defaults as PI-RADS.
|
| 54 |
+
|
| 55 |
## Preprocessing Parameters
|
| 56 |
|
| 57 |
| Parameter | Default | Description |
|
|
|
|
| 115 |
output_dir: /path/to/processed
|
| 116 |
project_dir: /path/to/WSAttention-Prostate
|
| 117 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/getting-started.md
CHANGED
|
@@ -1,49 +1,17 @@
|
|
| 1 |
# Getting Started
|
| 2 |
|
| 3 |
-
## Prerequisites
|
| 4 |
-
|
| 5 |
-
- Python 3.11+
|
| 6 |
-
- NVIDIA GPU recommended (CUDA-compatible)
|
| 7 |
-
- ~128 GB RAM for training (configurable via batch size)
|
| 8 |
-
|
| 9 |
## Installation
|
| 10 |
|
| 11 |
```bash
|
| 12 |
git clone https://github.com/anirudhbalaraman/WSAttention-Prostate.git
|
| 13 |
cd WSAttention-Prostate
|
| 14 |
pip install -r requirements.txt
|
|
|
|
| 15 |
```
|
| 16 |
|
| 17 |
-
### External Git Dependencies
|
| 18 |
-
|
| 19 |
-
Two packages are installed directly from GitHub repositories:
|
| 20 |
-
|
| 21 |
-
| Package | Source | Purpose |
|
| 22 |
-
|---------|--------|---------|
|
| 23 |
-
| `AIAH_utility` | `ai-assisted-healthcare/AIAH_utility` | Healthcare imaging utilities |
|
| 24 |
-
| `grad-cam` | `jacobgil/pytorch-grad-cam` | Gradient-weighted class activation maps |
|
| 25 |
-
|
| 26 |
-
These are included in `requirements.txt` and install automatically.
|
| 27 |
-
|
| 28 |
-
## Verify Installation
|
| 29 |
-
|
| 30 |
-
Run the test suite in dry-run mode:
|
| 31 |
-
|
| 32 |
-
```bash
|
| 33 |
-
pytest tests/
|
| 34 |
-
```
|
| 35 |
-
|
| 36 |
-
Tests use `--dry_run` mode internally (2 epochs, batch_size=2, no W&B).
|
| 37 |
-
|
| 38 |
## Data Format
|
| 39 |
|
| 40 |
-
Input MRI scans should be in **NRRD** or **NIfTI** format with three modalities per patient:
|
| 41 |
-
|
| 42 |
-
- T2-weighted (T2W)
|
| 43 |
-
- Diffusion-weighted imaging (DWI)
|
| 44 |
-
- Apparent diffusion coefficient (ADC)
|
| 45 |
-
|
| 46 |
-
### Dataset JSON Structure
|
| 47 |
|
| 48 |
The data pipeline uses MONAI's decathlon-format JSON:
|
| 49 |
|
|
@@ -59,46 +27,8 @@ The data pipeline uses MONAI's decathlon-format JSON:
|
|
| 59 |
"label": 0
|
| 60 |
}
|
| 61 |
],
|
| 62 |
-
"test": [
|
| 63 |
-
...
|
| 64 |
-
]
|
| 65 |
}
|
| 66 |
```
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
## Project Structure
|
| 71 |
-
|
| 72 |
-
```
|
| 73 |
-
WSAttention-Prostate/
|
| 74 |
-
βββ run_pirads.py # PI-RADS training/testing entry point
|
| 75 |
-
βββ run_cspca.py # csPCa training/testing entry point
|
| 76 |
-
βββ run_inference.py # Full inference pipeline
|
| 77 |
-
βββ preprocess_main.py # Preprocessing entry point
|
| 78 |
-
βββ config/ # YAML configuration files
|
| 79 |
-
β βββ config_pirads_train.yaml
|
| 80 |
-
β βββ config_pirads_test.yaml
|
| 81 |
-
β βββ config_cspca_train.yaml
|
| 82 |
-
β βββ config_cspca_test.yaml
|
| 83 |
-
β βββ config_preprocess.yaml
|
| 84 |
-
βββ src/
|
| 85 |
-
β βββ model/
|
| 86 |
-
β β βββ MIL.py # MILModel_3D β core MIL architecture
|
| 87 |
-
β β βββ csPCa_model.py # csPCa_Model + SimpleNN head
|
| 88 |
-
β βββ data/
|
| 89 |
-
β β βββ data_loader.py # MONAI data pipeline
|
| 90 |
-
β β βββ custom_transforms.py
|
| 91 |
-
β βββ train/
|
| 92 |
-
β β βββ train_pirads.py # PI-RADS training loop
|
| 93 |
-
β β βββ train_cspca.py # csPCa training loop
|
| 94 |
-
β βββ preprocessing/
|
| 95 |
-
β β βββ register_and_crop.py
|
| 96 |
-
β β βββ prostate_mask.py
|
| 97 |
-
β β βββ histogram_match.py
|
| 98 |
-
β β βββ generate_heatmap.py
|
| 99 |
-
β βββ utils.py
|
| 100 |
-
βββ job_scripts/ # SLURM job templates
|
| 101 |
-
βββ tests/
|
| 102 |
-
βββ dataset/ # Reference images for histogram matching
|
| 103 |
-
βββ models/ # Pre-trained model checkpoints
|
| 104 |
-
```
|
|
|
|
| 1 |
# Getting Started
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
## Installation
|
| 4 |
|
| 5 |
```bash
|
| 6 |
git clone https://github.com/anirudhbalaraman/WSAttention-Prostate.git
|
| 7 |
cd WSAttention-Prostate
|
| 8 |
pip install -r requirements.txt
|
| 9 |
+
pytest tests/ # verify installation
|
| 10 |
```
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
## Data Format
|
| 13 |
|
| 14 |
+
Input MRI scans should be in **NRRD** or **NIfTI** format with three modalities per patient: T2W, DWI, and ADC.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
The data pipeline uses MONAI's decathlon-format JSON:
|
| 17 |
|
|
|
|
| 27 |
"label": 0
|
| 28 |
}
|
| 29 |
],
|
| 30 |
+
"test": [...]
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
```
|
| 33 |
|
| 34 |
+
Paths are relative to `data_root`. PI-RADS labels are 0-indexed (`0` = PI-RADS 2, `3` = PI-RADS 5). csPCa labels are binary (0 or 1).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/index.md
CHANGED
|
@@ -32,4 +32,3 @@ flowchart LR
|
|
| 32 |
- [Pipeline](pipeline.md) β Full walkthrough of preprocessing, training, and evaluation
|
| 33 |
- [Architecture](architecture.md) β Model design and tensor shapes
|
| 34 |
- [Configuration](configuration.md) β YAML config reference
|
| 35 |
-
- [Inference](inference.md) β Running predictions on new data
|
|
|
|
| 32 |
- [Pipeline](pipeline.md) β Full walkthrough of preprocessing, training, and evaluation
|
| 33 |
- [Architecture](architecture.md) β Model design and tensor shapes
|
| 34 |
- [Configuration](configuration.md) β YAML config reference
|
|
|
mkdocs.yml
CHANGED
|
@@ -59,9 +59,7 @@ nav:
|
|
| 59 |
- Pipeline: pipeline.md
|
| 60 |
- Architecture: architecture.md
|
| 61 |
- Configuration: configuration.md
|
| 62 |
-
- Inference: inference.md
|
| 63 |
- API Reference:
|
| 64 |
- Models: api/models.md
|
| 65 |
- Preprocessing: api/preprocessing.md
|
| 66 |
- Data Loading: api/data.md
|
| 67 |
-
- Contributing: contributing.md
|
|
|
|
| 59 |
- Pipeline: pipeline.md
|
| 60 |
- Architecture: architecture.md
|
| 61 |
- Configuration: configuration.md
|
|
|
|
| 62 |
- API Reference:
|
| 63 |
- Models: api/models.md
|
| 64 |
- Preprocessing: api/preprocessing.md
|
| 65 |
- Data Loading: api/data.md
|
|
|