# Reproduce this session

From the repository root (CPU execution; GPU not required):

```sh
UV_CACHE_DIR=.tmp/uv-cache uv venv .tmp/busbra-venv
UV_CACHE_DIR=.tmp/uv-cache uv pip install --python .tmp/busbra-venv/bin/python \
  -r studies/imaging/ultrasound-within-birads/analysis/requirements.txt \
  --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match
P=.tmp/busbra-venv/bin/python
S=studies/imaging/ultrasound-within-birads
$P "$S/analysis/fetch.py"
$P "$S/analysis/audit.py"
$P "$S/analysis/features.py"
OPENBLAS_NUM_THREADS=1 $P "$S/analysis/model.py"
$P "$S/analysis/evaluate.py"
```

`data/` is not committed. The fetcher validates the Zenodo MD5 and writes SHA256 checksums. Feature extraction downloads torchvision's ImageNet ResNet18 V1 weights to `data/torch`, records their hash, and caches three feature matrices in `data/features.npz`. Delete that file to rerun extraction. All supervised training uses only case-level averaged features and patient-disjoint folds. `results/predictions.csv` has exactly one held-out prediction per case per model, and is the input for all performance summaries.

Read PLAN.md for the pre-outcome decisions. Bootstrap intervals are conditional on the fitted cross-validation models, not full repeated-training uncertainty. They do not justify a clinical claim.

Sources:
- Gómez-Flores W, Gregorio-Calas MJ, de Albuquerque Pereira WC. BUS-BRA: A breast ultrasound dataset for assessing computer-aided diagnosis systems. Medical Physics 51 (2024):3110–3123. https://doi.org/10.1002/mp.16812
- Data version 1.0: https://zenodo.org/records/8231412
- Benchmark MATLAB source: https://github.com/wgomezf/BUS-BRA

The public paper abstract documents a biopsy-proven cohort. Each released case has a histology and pathology label; this session does not independently verify pathology against clinical records. The publisher full text was not accessible during this session. Implementation details of the original benchmark were inspected directly in the authors' code archive, whose hash is recorded.

The optional post-result scanner check is reproduced with `$P "$S/analysis/scanner_check.py"`. It evaluates the same held-out predictions within each device and within device/fold pairs; it does not retrain on different devices. `data/image_montage.jpg` was a temporary manual inspection of nine views, not a systematic annotation-removal audit.

## Second session: joint features, simple shape and split robustness

After the original commands, run:

```sh
for design in released repeat exclude856; do
  OPENBLAS_NUM_THREADS=1 $P "$S/analysis/extend.py" --design "$design"
done
$P "$S/analysis/evaluate_extension.py"
```

`extend.py` retains the first-session crop/mask predictions for the released folds and fits the concatenated 1,024-dimensional crop+mask and five-dimensional geometric baselines. `repeat` refits all four representations on a new outcome-stratified patient split; `exclude856` refits on released folds without the discordant case. All three runs save one row per held-out patient. The geometry uses binary pixel squares, grid-edge perimeter and covariance of foreground-pixel coordinates, without ultrasound intensities or physical-size inputs. The outputs `extension_metrics.csv`, `extension_differences.csv`, `extension_folds.csv` and `extension_calibration.csv` summarize the predictions. Only the released-fold analysis has bootstrap intervals; sensitivity analyses report point estimates. Seeds and all hyperparameter grids are in the scripts. These extensions were planned after seeing the initial outline result, not before the initial experiment.

Generate the paper figure and Markdown table (`results/within_category_table.md`) with `$P "$S/analysis/plot_results.py"` (optionally set `MPLCONFIGDIR` to a writable cache directory).
