Home

Awesome

Volumentations 3D

3D Volume data augmentation package inspired by albumentations.

Volumentations is a working project, which originated from the following Git repositories:

Nevertheless, if you are using this subpackage, please give credit to all authors including ashawkey, ZFTurbo, qubvel and muellerdo.

Initially inspired by albumentations library for augmentation of 2D images.

Installation

pip install volumentations-3D

Simple Example

from volumentations import *

def get_augmentation(patch_size):
    return Compose([
        Rotate((-15, 15), (0, 0), (0, 0), p=0.5),
        RandomCropFromBorders(crop_value=0.1, p=0.5),
        ElasticTransform((0, 0.25), interpolation=2, p=0.1),
        Resize(patch_size, interpolation=1, resize_type=0, always_apply=True, p=1.0),
        Flip(0, p=0.5),
        Flip(1, p=0.5),
        Flip(2, p=0.5),
        RandomRotate90((1, 2), p=0.5),
        GaussianNoise(var_limit=(0, 5), p=0.2),
        RandomGamma(gamma_limit=(80, 120), p=0.2),
    ], p=1.0)

aug = get_augmentation((64, 128, 128))

img = np.random.randint(0, 255, size=(128, 256, 256), dtype=np.uint8)
lbl = np.random.randint(0, 1, size=(128, 256, 256), dtype=np.uint8)

# with mask
data = {'image': img, 'mask': lbl}
aug_data = aug(**data)
img, lbl = aug_data['image'], aug_data['mask']

# without mask
data = {'image': img}
aug_data = aug(**data)
img = aug_data['image']

Difference from initial version

Implemented 3D augmentations

Check the EXAMPLES page for visual demonstrations

CenterCrop
ColorJitter
Contiguous
CropNonEmptyMaskIfExists
Downscale
ElasticTransform
ElasticTransformPseudo2D
Flip
Float
GaussianNoise
GlassBlur
GridDistortion
GridDropout
ImageCompression
Normalize
PadIfNeeded
RandomBrightnessContrast
RandomCrop
RandomCropFromBorders
RandomDropPlane
RandomGamma
RandomResizedCrop
RandomRotate90
RandomScale
RandomScale2
RemoveEmptyBorder
Resize
ResizedCropNonEmptyMaskIfExists
Rotate
RotatePseudo2D
Transpose

Speed table

Speed in seconds per one sample.

Aug nameCube = 64pxCube = 96pxCube = 128pxCube = 224pxCube = 256px
Rotate0.04020.13660.32461.75462.6349
RandomCropFromBorders0.00370.01290.03150.16340.2426
ElasticTransform0.15880.54392.864911.893742.3886
Resize (type = 0)0.40290.40770.42450.55450.6278
Resize (type = 1)0.36180.36960.38710.51740.5896
Flip0.00420.01340.03140.16490.2453
RandomRotate900.00400.01400.03060.16720.2439
GaussianNoise0.01430.04060.09560.49920.7381
RandomGamma0.00660.02110.05050.26540.3989
RandomScale0.01580.05180.11980.63910.9457

Related repositories

Citation

For more details, please refer to the publication: https://doi.org/10.1016/j.compbiomed.2021.105089

If you find this code useful, please cite it as:

@article{solovyev20223d,
  title={3D convolutional neural networks for stalled brain capillary detection},
  author={Solovyev, Roman and Kalinin, Alexandr A and Gabruseva, Tatiana},
  journal={Computers in Biology and Medicine},
  volume={141},
  pages={105089},
  year={2022},
  publisher={Elsevier},
  doi={10.1016/j.compbiomed.2021.105089}
}