Skip to content

Commit bda0d05

Browse files
fix readme and docker dependencies
1 parent 5d38a2a commit bda0d05

4 files changed

Lines changed: 57 additions & 24 deletions

File tree

README.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ train/
8989
│ ├── organ_seg.nii.gz # TotalSegmentator organ labels
9090
│ └── face_seg.nii.gz # face mask
9191
├── recon/ # sinogram data (labeled train + val)
92-
│ ├── mult_factors_forSTIR_SSRB.hs/s # multiplicative correction sinogram
93-
│ ├── additive_term_SSRB.hs/s # additive correction sinogram (scatter + randoms)
94-
│ ├── prompts_SSRB.hs/s # prompt (raw) sinogram
92+
│ ├── mult_nac_rd85.hs/.s # multiplicative correction sinogram
93+
│ ├── add_nac_rd85.hs/.s # additive correction sinogram (scatter + randoms)
94+
│ ├── prompts_rd85.hs/.s # prompt (raw) sinogram
9595
│ ├── offset.json # bed position and gantry offset
96-
│ ├── ct_face.nii.gz # GT CT face region (for face swap)
97-
│ └── face_mask.nii.gz # face mask
96+
│ ├── ct_face_and_bed.nii.gz # GT CT values at face + scanner bed (for swap-back)
97+
│ └── face_and_bed_mask.nii.gz # face + scanner bed mask
9898
└── pet-label/ # ground-truth PET (labeled train only)
99-
├── pet.nii.gz # CT-attenuation-corrected PET (reference)
99+
├── acpet.nii.gz # CT-attenuation-corrected PET (reference)
100100
├── body_seg.nii.gz # body mask in PET space
101101
└── organ_seg.nii.gz # organ labels in PET space
102102
```
@@ -124,14 +124,15 @@ python src/baseline/model.py data/sub-000/features/ results/sub-000/ct_pred.nii.
124124
Converts a predicted pseudo-CT into a reconstructed ACPET image using [STIR](http://stir.sourceforge.net/) (Software for Tomographic Image Reconstruction). The pipeline:
125125

126126
1. Validates CT shape, affine, and HU range
127-
2. Converts HU → linear attenuation coefficients (μ-map) at 511 keV using the Carney et al. (2006) bilinear model
128-
3. Smooths the μ-map (4mm FWHM Gaussian)
129-
4. Resamples the μ-map to STIR sinogram format
130-
5. Computes the ACF (attenuation correction factor) sinogram
131-
6. Applies ACF to multiplicative/additive sinograms
132-
7. Reconstructs using OSEM (ordered subsets expectation maximisation)
133-
8. Applies 4mm post-reconstruction filter
134-
9. Converts to NIfTI with correct bed/gantry offset origin
127+
2. Swaps face and scanner bed region back from ground-truth CT (to avoid evaluating face/bed prediction)
128+
3. Converts HU → linear attenuation coefficients (μ-map) at 511 keV using the Carney et al. (2006) bilinear model
129+
4. Smooths the μ-map (4mm FWHM Gaussian)
130+
5. Resamples the μ-map to STIR format (ring spacing 3.29114 mm)
131+
6. Computes the ACF (attenuation correction factor) sinogram
132+
7. Applies ACF to the additive sinogram
133+
8. Applies ACF to the multiplicative sinogram
134+
9. Reconstructs using OSEM (ordered subsets expectation maximisation, with post-filter)
135+
10. Converts to NIfTI with correct bed/gantry offset origin
135136

136137
### Option 1: Docker (recommended)
137138

@@ -147,26 +148,29 @@ docker run --rm \
147148
ghcr.io/bic-mac-challenge/recon:latest
148149
```
149150

150-
The reconstructed PET is written to `/data/output/pet.nii.gz`.
151+
The reconstructed PET is written to `/data/output/pet.nii.gz`. Intermediate files (mu-map, ACF sinogram, etc.) are written to `/data/output/intermediates/` and a full debug log to `/data/output/intermediates/recon.log`.
151152

152-
Optionally mount a local directory to `/data/intermediates` to persist intermediate files (mu-map, ACF sinogram, etc.). When mounted, the pipeline resumes from any existing intermediates rather than recomputing them; set `OVERWRITE=1` to forcefully restart from scratch instead.
153+
The pipeline resumes from any existing intermediates automatically; set `OVERWRITE=1` to forcefully restart from scratch:
153154

154155
```bash
155156
docker run --rm \
157+
-e OVERWRITE=1 \
156158
-v /path/to/sub-000/recon:/data/recon \
157159
-v /path/to/ct_pred.nii.gz:/data/ct/ct.nii.gz \
158160
-v /path/to/output:/data/output \
159-
-v /path/to/intermediates:/data/intermediates \
160161
ghcr.io/bic-mac-challenge/recon:latest
161162
```
162163

164+
Set `VERBOSE=1` to stream STIR subprocess output to the terminal in addition to the log file.
165+
163166
### Option 2: Direct Python (requires local STIR)
164167

165168
```bash
166-
python src/recon/main.py <recon_dir> <ct.nii.gz> <pet_out.nii.gz> \
167-
[--overwrite] [--intermediates_dir <dir>]
169+
python src/recon/main.py <recon_dir> <ct.nii.gz> <output_dir> [-w] [-v]
168170
```
169171

172+
`pet.nii.gz` and `intermediates/` are written inside `output_dir`. Use `-w`/`--overwrite` to rerun from scratch and `-v`/`--verbose` to stream STIR output to the terminal.
173+
170174
---
171175

172176
## 📊 Evaluation (`src/evaluation/`)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
88
"nibabel>=5.3.3",
9+
"tqdm>=4.67.3",
910
]

src/recon/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN mkdir /build && cd /build \
2222
&& make -j$(nproc) \
2323
&& make install
2424

25-
RUN pip install --no-cache-dir nibabel scipy
25+
RUN pip install --no-cache-dir nibabel scipy tqdm
2626

2727
# ── Stage 2: Runtime ─────────────────────────────────────────────────────────
2828
FROM ubuntu:22.04
@@ -37,7 +37,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3737
libboost-iostreams1.74.0 \
3838
libboost-date-time1.74.0 \
3939
libhdf5-103 \
40+
libhdf5-cpp-103 \
4041
libfftw3-double3 \
42+
libinsighttoolkit5.2 \
4143
&& rm -rf /var/lib/apt/lists/*
4244

4345
# Copy STIR install (executables, libs, Python bindings) + pip packages
@@ -49,10 +51,11 @@ COPY . .
4951

5052
ENV PYTHONPATH="/usr/local/python"
5153
ENV OVERWRITE=""
54+
ENV VERBOSE=""
5255

5356
CMD python3 main.py \
5457
/data/recon \
5558
/data/ct/ct.nii.gz \
56-
/data/output/pet.nii.gz \
57-
--intermediates_dir /data/intermediates \
58-
${OVERWRITE:+--overwrite}
59+
/data/output \
60+
${OVERWRITE:+--overwrite} \
61+
${VERBOSE:+--verbose}

uv.lock

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)