Skip to content
Adam Tupper edited this page Jul 18, 2025 · 8 revisions

USAugment provides ultrasound-specific image transforms for training deep neural networks. It accompanies our article Revisiting Data Augmentation for Ultrasound Images.

Examples of each augmentation.

How to install USAugment

This package can be installed from PyPI by running:

pip install usaugment

Get started using USAugment

The following example shows how to use the augmentations with Albumentations. Note that the augmentations also require a binary scan mask identifying the region of the scan in the image (1 = pixels in the scan, 0 = otherwise).

>>> import albumentations as A
>>> from usaugment.albumentations import DepthAttenuation, GaussianShadow, HazeArtifact, SpeckleReduction
>>> transform = A.Compose(
...     [
...         DepthAttenuation(p=0.5),
...         GaussianShadow(p=0.5),
...         HazeArtifact(p=0.5),
...         SpeckleReduction(p=0.5),
...     ],
...     additional_targets={"scan_mask": "mask"}
...)
>>> image = ... # Load image
>>> scan_mask = ... # Load scan mask
>>> transformed = transform(image=image, scan_mask=scan_mask)

Checkout the Augmentations for detailed descriptions of each augmentation.

Running the examples

There's a notebook in the examples directory that provides examples that visualize the effects of each augmentation. You can run these examples on Binder or locally by installing the optional examples dependencies (Matplotlib and Jupyter Notebook):

pip install '.[examples]'

Contributing

I'd love for this package to grow and flourish into a resource that anyone with an interest in training deep neural networks for ultrasound analysis tasks can pick up and use quickly and easily. Any help addressing bugs, contributing new augmentations, or any other improvements are welcome and appreiciated! I only ask that you respect the community guidelines laid out in the CODE_OF_CONDUCT.md. For more information on how to contribute, checkout out the Contributing page.

To ensure that your code meets the style guidelines etc., make sure you install the optional development dependencies:

pip install '.[dev]'
nbstripout --install
pre-commit install

How to cite USAugment

If you use the augmentations in USAugment in your research, please cite our article Revisiting Data Augmentation for Ultrasound Images. This helps more people find and use the package and encourages us to continue maintaining and improving it!

@article{
tupper2025,
title={Revisiting Data Augmentation for Ultrasound Images},
author={Adam Tupper and Christian Gagn{\'e}},
journal={Transactions on Machine Learning Research},
issn={2835-8856},
year={2025},
url={https://openreview.net/forum?id=iGcxlTLIL5},
note={}
}

Clone this wiki locally