Marina Domínguez · Nélida Mirabet-Herranz · Valery Naranjo
Instituto Universitario de Investigación en Tecnología Centrada en el Ser Humano,
HUMAN-tech, Universitat Politècnica de València
DGM4MICCAI 2026
This repository contains the official implementation of Feature-Space Candidate Guidance (FSCG), a training-free inference-time guidance strategy for realistic mask-conditioned ultrasound image synthesis.
FSCG combines local correction in the feature space of a frozen ultrasound foundation model with stochastic candidate selection during reverse diffusion. The conditioning mask specifies the target anatomy, while an OpenUS feature bank built exclusively from real training images guides the samples toward realistic ultrasound appearance.
- Training-free guidance: the DiT generator, VAE decoder, and OpenUS encoder remain frozen during sampling.
- Local feature correction: predicted clean images are compared with their nearest real-image neighbours in OpenUS feature space.
- Candidate selection: multiple stochastic reverse-step candidates are evaluated, and the lowest-energy candidate is retained.
- Cross-domain evaluation: experiments cover cardiac, breast, and ovarian ultrasound.
- Improved realism: averaged across the three datasets, FSCG reduces FID64 by 56%, FID192 by 57%, and nearest-neighbour feature distance by 47% relative to standard conditional diffusion sampling.
The following results are averaged across CAMUS, BUS-UC, and MMOTU. Lower is better.
| Method | FID64 ↓ | FID192 ↓ | OpenUS NN cosine ↓ | OpenUS NN L2 ↓ |
|---|---|---|---|---|
| Mask-conditioned DiT | 0.524 | 2.670 | 0.112 | 0.426 |
| FSCG | 0.230 | 1.161 | 0.030 | 0.226 |
FSCG improves both image-distribution metrics and local alignment with the real-image ultrasound feature distribution.
OpenUS feature-space projections for CAMUS, BUS-UC, and MMOTU.
Qualitative comparison under matched conditioning masks.
FSCG preserves the specified anatomy while improving local speckle appearance, contrast, and boundary definition.
At selected reverse-diffusion steps, FSCG performs two operations:
- Local gradient guidance. The frozen DiT predicts a clean latent estimate, which is decoded and embedded with OpenUS. A local k-nearest-neighbour energy is computed against a real-image training feature bank and differentiated with respect to the current noisy latent.
- Candidate scoring and selection. From the corrected latent, the frozen sampler proposes multiple stochastic reverse-step candidates. Each candidate is evaluated with the same OpenUS kNN energy, and the lowest-energy candidate becomes the next latent state.
The feature bank contains training images only. Validation and test images are never included.
The main paper configuration uses:
| Setting | Value |
|---|---|
| Image resolution | 256 × 256 |
| Latent resolution | 4 × 32 × 32 |
| DDPM sampling steps | 100 |
| Guided portion of the trajectory | Final 10% |
| Number of neighbours, k | 5 |
| Number of candidates, M | 4 |
| Guidance strength, eta | 1.0 |
| Evaluation samples per dataset | 50 |
The OpenUS feature banks contain non-augmented training images only:
| Dataset | Domain | Feature-bank images |
|---|---|---|
| CAMUS | Cardiac ultrasound | 400 |
| BUS-UC | Breast ultrasound | 647 |
| MMOTU | Ovarian ultrasound | 445 |
assets/ Figures used in this README.
configs/ DiT training configurations.
scripts/data_preparation/ Dataset preparation and augmentation tools.
scripts/evaluation/ Image- and feature-space evaluation scripts.
scripts/sampling/ Notes on sampling entry points.
src/dit_openus_guided_sampling/ DiT-based training and sampling code.
LICENSE Repository license.
THIRD_PARTY_NOTICES.md Third-party licenses and attributions.
Clone the repository and install the dependencies:
git clone https://github.com/marinadominguez/FSCG.git
cd FSCG
pip install -r requirements.txtThe research release expects the following external resources:
- an ultrasound dataset with conditioning masks;
- a trained mask-conditioned DiT checkpoint;
- a local copy of the OpenUS repository;
- an OpenUS checkpoint;
- a train-only OpenUS feature bank.
Datasets, trained DiT checkpoints, OpenUS checkpoints, feature banks, and experiment outputs are not redistributed in this repository.
Set the paths for your local environment:
export DATA_ROOT=/path/to/datasets
export CHECKPOINT_ROOT=/path/to/checkpoints
export OPENUS_REPO=/path/to/OpenUS
export OPENUS_CKPT=/path/to/openus_checkpoint.pth
export FEATURE_BANK=/path/to/openus_train_feature_bank.pt
export OUTPUT_ROOT=/path/to/outputsExample CAMUS training command:
python src/dit_openus_guided_sampling/train.py \
--config configs/camus_dit_xl2.yaml \
--results-dir "${OUTPUT_ROOT}/camus_dit_xl2"Training configurations are also provided for BUS-UC and MMOTU:
configs/camus_dit_xl2.yaml
configs/bus_uc_dit_xl2.yaml
configs/mmotu_dit_xl2.yaml
Example unguided mask-conditioned DiT sampling:
python src/dit_openus_guided_sampling/sample_contmask.py \
--model DiT-XL/2 \
--image-size 256 \
--ckpt "${CHECKPOINT_ROOT}/dit_checkpoint.pt" \
--dit-weights ema \
--mask-dir "${DATA_ROOT}/CAMUS_AUG/2CH_ED_augmented/sector_annotations/validation" \
--mask-rotate-deg 270 \
--num-samples 50 \
--batch-size 4 \
--num-sampling-steps 100 \
--output-dir "${OUTPUT_ROOT}/samples_dit"The example above uses the CAMUS mask orientation. For BUS-UC and MMOTU,
adapt --mask-dir, --mask-value-mode, and --mask-rotate-deg according to
the corresponding dataset configuration.
Example FSCG sampling with local kNN correction and candidate selection:
python src/dit_openus_guided_sampling/sample_contmask.py \
--model DiT-XL/2 \
--image-size 256 \
--ckpt "${CHECKPOINT_ROOT}/dit_checkpoint.pt" \
--dit-weights ema \
--mask-dir "${DATA_ROOT}/CAMUS_AUG/2CH_ED_augmented/sector_annotations/validation" \
--mask-rotate-deg 270 \
--num-samples 50 \
--batch-size 4 \
--num-sampling-steps 100 \
--openus-guidance-enabled true \
--openus-energy-mode knn_treeg \
--openus-feature-bank "${FEATURE_BANK}" \
--openus-repo-path "${OPENUS_REPO}" \
--openus-ckpt "${OPENUS_CKPT}" \
--openus-start-ratio 0.9 \
--openus-eta 1.0 \
--openus-k 5 \
--treeg-candidates 4 \
--treeg-select argmin \
--output-dir "${OUTPUT_ROOT}/samples_fscg"The main FSCG method reported in the paper corresponds to:
--openus-energy-mode knn_treeg
The implementation includes the following modes for comparison and ablation:
knn
centroid
pdm
dtm
pcd
treeg
das_smc
lidar
knn_treeg
knn_treeg_pcd
A mode is selected with --openus-energy-mode <mode>.
Example comparison between generated and real images:
python scripts/evaluation/compare_dit_50_vs_real.py \
--real-dir "${DATA_ROOT}/CAMUS_AUG/2CH_ED_augmented/images/validation" \
--gen-dir "${OUTPUT_ROOT}/samples_fscg" \
--openus-repo "${OPENUS_REPO}" \
--openus-ckpt "${OPENUS_CKPT}" \
--out-dir "${OUTPUT_ROOT}/evaluation_fscg"Additional PCA, feature-space, FID, perceptual, and ultrasound-specific
evaluation utilities are available under scripts/evaluation/.
- Feature banks must contain training images only.
- Validation and test images must never be included in the guidance bank.
- Comparisons should use the same DiT checkpoint, conditioning masks, sampling schedule, feature bank, and number of samples.
- Compared methods should differ only in their inference-time guidance rule.
- Results are stochastic; record the random seed and sampling configuration for each run.
The pre-review manuscript is available on arXiv. The proceedings citation will be added when the final publication record becomes available.
@misc{dominguez2026fscg,
title = {Feature-Space Guided Diffusion for Realistic Ultrasound Image Synthesis},
author = {Domínguez, Marina and Mirabet-Herranz, Nélida and Naranjo, Valery},
year = {2026},
eprint = {2607.11655},
archivePrefix = {arXiv},
primaryClass = {cs.CV},
doi = {10.48550/arXiv.2607.11655},
url = {https://arxiv.org/abs/2607.11655}
}This repository is released under the Creative Commons Attribution-NonCommercial 4.0 International License.
The DiT-derived implementation and third-party components retain their original copyright notices and license conditions. See THIRD_PARTY_NOTICES.md for details.
IMPLANTEU is funded by the European Union's Horizon Europe research and innovation programme under the Marie Skłodowska-Curie Actions Doctoral Network (MSCA-DN) [Grant Agreement No. 101169308]. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Commission. Neither the European Union nor the granting authority can be held responsible for them.


