Skip to content

cornucopia.synth

SynthShape generator

Reference
  1. Billot, B., Greve, D., Van Leemput, K., Fischl, B., Iglesias, J.E. and Dalca, A.V., 2020. A learning strategy for contrast-agnostic MRI segmentation. In Proceedings of the Third Conference on Medical Imaging with Deep Learning, PMLR 121, pp. 75-93.

    @inproceedings{billot2020learning,
        title       = {A Learning Strategy for Contrast-agnostic MRI Segmentation},
        author      = {Billot, Benjamin and Greve, Douglas N. and Van Leemput, Koen and Fischl, Bruce and Iglesias, Juan Eugenio and Dalca, Adrian},
        booktitle   = {Proceedings of the Third Conference on Medical Imaging with Deep Learning},
        pages       = {75--93},
        year        = {2020},
        editor      = {Arbel, Tal and Ben Ayed, Ismail and de Bruijne, Marleen and Descoteaux, Maxime and Lombaert, Herve and Pal, Christopher},
        volume      = {121},
        series      = {Proceedings of Machine Learning Research},
        month       = {06--08 Jul},
        publisher   = {PMLR},
        pdf         = {http://proceedings.mlr.press/v121/billot20a/billot20a.pdf},
        url         = {https://proceedings.mlr.press/v121/billot20a.html}
    }
    
  2. Billot, B., Robinson, E., Dalca, A.V. and Iglesias, J.E., 2020. Partial volume segmentation of brain MRI scans of any resolution and contrast. In Medical Image Computing and Computer Assisted Intervention-MICCAI 2020: 23rd International Conference, Lima, Peru, October 4-8, 2020, Proceedings, Part VII 23 (pp. 177-187). Springer International Publishing.

    @inproceedings{billot2020partial,
    title         = {Partial volume segmentation of brain MRI scans of any resolution and contrast},
    author        = {Billot, Benjamin and Robinson, Eleanor and Dalca, Adrian V and Iglesias, Juan Eugenio},
    booktitle     = {Medical Image Computing and Computer Assisted Intervention--MICCAI 2020: 23rd International Conference, Lima, Peru, October 4--8, 2020, Proceedings, Part VII 23},
    pages         = {177--187},
    year          = {2020},
    organization  = {Springer},
    url           = {https://arxiv.org/abs/2004.10221}
    }
    
  3. Hoffmann, M., Billot, B., Greve, D.N., Iglesias, J.E., Fischl, B. and Dalca, A.V., 2021. SynthMorph: learning contrast-invariant registration without acquired images. IEEE transactions on medical imaging, 41(3), pp.543-558.

    @article{hoffmann2021synthmorph,
    title     = {SynthMorph: learning contrast-invariant registration without acquired images},
    author    = {Hoffmann, Malte and Billot, Benjamin and Greve, Douglas N and Iglesias, Juan Eugenio and Fischl, Bruce and Dalca, Adrian V},
    journal   = {IEEE transactions on medical imaging},
    volume    = {41},
    number    = {3},
    pages     = {543--558},
    year      = {2021},
    publisher = {IEEE},
    url       = {https://arxiv.org/pdf/2004.10282}
    }
    
  4. Billot, B., Greve, D.N., Puonti, O., Thielscher, A., Van Leemput, K., Fischl, B., Dalca, A.V. and Iglesias, J.E., 2023. SynthSeg: Segmentation of brain MRI scans of any contrast and resolution without retraining. Medical image analysis, 86, p.102789.

    @article{billot2023synthseg,
    title     = {SynthSeg: Segmentation of brain MRI scans of any contrast and resolution without retraining},
    author    = {Billot, Benjamin and Greve, Douglas N and Puonti, Oula and Thielscher, Axel and Van Leemput, Koen and Fischl, Bruce and Dalca, Adrian V and Iglesias, Juan Eugenio and others},
    journal   = {Medical image analysis},
    volume    = {86},
    pages     = {102789},
    year      = {2023},
    publisher = {Elsevier},
    url       = {https://www.sciencedirect.com/science/article/pii/S1361841523000506}
    }
    

IntensityTransform

IntensityTransform(bias=7, bias_strength=0.5, gamma=0.6, motion_fwhm=3, resolution=8, snr=10, gfactor=5, order=3, **kwargs)

Bases: SequentialTransform

Common intensity augmentation for MRI and related images

The arguments control the range of the distributions from which the transform parameters are sampled.

It is also possible to directly provide the probability distribution from which to sample the parametes. In this case, it must be a Sampler instance.

Setting any argument to False disables the corresponding transform entirely.

Reference

Billot, B., Greve, D.N., Puonti, O., Thielscher, A., Van Leemput, K., Fischl, B., Dalca, A.V. and Iglesias, J.E., 2023. SynthSeg: Segmentation of brain MRI scans of any contrast and resolution without retraining. Medical image analysis, 86, p.102789.

@article{billot2023synthseg,
  title     = {SynthSeg: Segmentation of brain MRI scans of any contrast and resolution without retraining},
  author    = {Billot, Benjamin and Greve, Douglas N and Puonti, Oula and Thielscher, Axel and Van Leemput, Koen and Fischl, Bruce and Dalca, Adrian V and Iglesias, Juan Eugenio and others},
  journal   = {Medical image analysis},
  volume    = {86},
  pages     = {102789},
  year      = {2023},
  publisher = {Elsevier},
  url       = {https://www.sciencedirect.com/science/article/pii/S1361841523000506}
}

Parameters:

Name Type Description Default
bias Sampler | int | {False}

The sampled value controls the smoothness of the intensity bias field (smaller values yield smoother fields). If an int, sample from RandInt(2, value).

7
bias_strength Sampler | float in (0..1)

The maximum magnitude of the bias field (about 1). If a float, sample from Uniform(0, value). The minimum and maximum values of the bias field will be 1 - bias_strength and 1 + bias_strength.

0.5
gamma Sampler | float | {False}

The Gamma transform squeezes intensities such that the contrast to noise ratio is decreased (positive values lead to less decreased contrast, positive values lead to increased contrast). If a float, sample the gamma exponent from LogNormal(0, value).

0.6
motion_fwhm Sampler | float | {False}

A blur can be perform to model the point spread function or motion-related smearing. The amount of smoothing is encoded by the full-width at half-maximum (FWHM) of the underlying Gaussian kernel. If a float, sample the FWHM from Uniform(0, value).

3
resolution Sampler | float | {False}

Thick-slice or isotropic low-resolution (LR) images are randomly applied. and their (through-slice or iso) resolution is controlled here. It is defined as a proportion of the high-resolution voxel size (i.e., a resolution of 4 mean that the LR voxel size will be four times as large as the input voxel size) If a float, sampled form Uniform(0, value).

8
snr Sampler | float | {False}

The amount of noise added is encoded by the signal-to-noise ratio (SNR) of the noisy image (larger sampled values yield less noisy images). If a float, the value is a lower bound for SNR (no image will have a poorer SNR than this). The noise variance is then sampled from Uniform(0, 1/snr).

10
gfactor Sampler | int | {False}

The g-factor is a smooth field that locally scales the noise variance. The gfactor argument controls the smoothness of the g-factor field. If an int, sample from RandInt(2, value).

5
order 1..7

Spline order of the bias/g-factor fields (1 is much faster)

1..7

ApplySynthFromLabelTransform

ApplySynthFromLabelTransform(gmm, deform=None, intensity=None, load=None, preproc=None, postproc=None, **kwargs)

Bases: FinalTransform

Apply the sequence of tranformations that synthesizes an image from a label map.

Parameters:

Name Type Description Default
gmm Transform

The Gaussian mixture model (GMM) transform that generates an image from a label map.

required
deform Transform | None

The deformation transform that deforms the label map before generation.

None
intensity Transform | None

The intensity transform that augments the generated image.

None
load Transform | None

The transform that loads the input label map from disk.

None
preproc Transform | None

The transform that preprocesses the labels. Only labels returned by preproc are used for generation.

None
postproc Transform | None

The transform that postprocesses the labels. Only labels returned by postproc are used as targets.

None

Other Parameters:

Name Type Description
returns [(list | dict) of] {'input', 'deformed', 'generators', 'target', 'label', 'image', 'output'}

Tensors to return

  • 'input': the input label map (after loading, if load is provided)
  • 'deformed': the deformed label map (after deform, if provided)
  • 'generators': the generator maps (after preproc, if provided)
  • 'target', 'label': the target label map (after postproc, if provided)
  • 'image', 'output': the generated image (after intensity, if provided)

SynthFromLabelTransform

SynthFromLabelTransform(*, patch=None, from_disk=False, one_hot=False, synth_labels=None, synth_labels_maybe=None, target_labels=None, order=3, geom=True, translations=0.1, rotation=15, shears=0.012, zooms=0.15, elastic=0.05, elastic_nodes=10, elastic_steps=0, bound='border', gmm_fwhm=10, bias=7, bias_strength=0.5, gamma=0.6, motion_fwhm=3, resolution=8, snr=10, gfactor=5, sample_in_background=False, dtype=None, device=None, returns=Kwargs(image='image', label='label'))

Bases: NonFinalTransform

Synthesize an MRI from an existing label map

Example

# if inputs are preloaded label tensors (default)
synth = SynthFromLabelTransform()

# if inputs are filenames
synth = SynthFromLabelTransform(from_disk=True)

# memory-efficient patch-synthesis
synth = SynthFromLabelTransform(patch=64)

img, lab = synth(input)
Reference

Billot, B., Greve, D.N., Puonti, O., Thielscher, A., Van Leemput, K., Fischl, B., Dalca, A.V. and Iglesias, J.E., 2023. SynthSeg: Segmentation of brain MRI scans of any contrast and resolution without retraining. Medical image analysis, 86, p.102789.

@article{billot2023synthseg,
  title     = {SynthSeg: Segmentation of brain MRI scans of any contrast and resolution without retraining},
  author    = {Billot, Benjamin and Greve, Douglas N and Puonti, Oula and Thielscher, Axel and Van Leemput, Koen and Fischl, Bruce and Dalca, Adrian V and Iglesias, Juan Eugenio and others},
  journal   = {Medical image analysis},
  volume    = {86},
  pages     = {102789},
  year      = {2023},
  publisher = {Elsevier},
  url       = {https://www.sciencedirect.com/science/article/pii/S1361841523000506}
}

Parameters:

Name Type Description Default
patch [list of] int

If provided, patches of this size are extracted. Note that patches are extracted after application of the geometric transforms (altough both operations are combined efficiently).

None
from_disk bool

Assume inputs are filenames and load from disk

False
one_hot bool

Return one-hot labels. Else return a label map.

False
synth_labels tuple of [tuple of] int

List of labels to use for synthesis. If multiple labels are grouped in a sublist, they share the same intensity in the GMM. All labels not listed are assumed background. For example, this option can be used to ensure that symmetric structures share the same intensity.

None
synth_labels_maybe dict[tuple of [tuple of] int, float]

List of labels to sometimes use for synthesis, and their probability of being sampled. This options allow groups parts of the anatomy to be hidden in a random subset of images. This can be used to e.g. model the presence of skull-stripped images.

None
target_labels tuple of [tuple of] int

List of target labels. If multiple labels are grouped in a sublist, they are fused. All labels not listed are assumed background. The final label map is relabeled in the order provided, starting from 1 (background is 0). This option can be used to predict a coarser set of labels, than those used for synthesis.

None
order int

Spline order of the elastic and bias fields (1 is much faster)

3

Other Parameters:

Name Type Description
geom (affine, elastic, affine + elastic, '')

Which geometric transforms to apply. True (default) corresponds to affine+elastic. False corresponds to no geometric transform.

v0.5 Added geom argument.

translations Sampler | float | {False}

Distribution from which random translations (in percentage of field-of-view) are sampled. If a float, sample from Uniform(-value, value).

rotation Sampler | float | {False}

Distribution from which random rotations (in degree) are sampled. If a float, sample from Uniform(-value, value).

shears Sampler | float | {False}

Distribution from which random shears are sampled. If a float, sample from Uniform(-value, value).

zooms Sampler | float | {False}

Distribution from which random zooms (about one) are sampled. If a float, sample from Uniform(-value, value). The zoom effectively applied is 1 plus the sampled value (i.e., the zoom is sampled from Uniform(1-value, 1+value)).

elastic Sampler | float | {False}

Distribution from which the maximum of the displacement magnitude (in proportion of the field-of-view) is sampled. If a float, sample from Uniform(0, value).

elastic_nodes Sampler | int

The sampled value controls the smoothness of the displacement field (smaller values yield smoother fields). If a float, sample from RandInt(2, value).

elastic_steps Sampler | int

Number of scaling-and-squaring integration steps. Scaling-and-squaring ensure that the elastic field is diffeomorphic (one-to-one and onto). If 0, the field is not integrated, which is faster but may result in image foldings.

bound (zeros, border, reflection)

Padding mode when sampling outside the field-of-view.

Other Parameters:

Name Type Description
gmm_fwhm Sampler | float | {False}

In contrast with the SynthSeg paper, we perform an edge-preserving smoothing after intensities are sampled, in order to mimic texture. This parameter controls the width of the smoothing kernel. If a float, sample from Uniform(0, value).

bias Sampler | int | {False}

The sampled value controls the smoothness of the intensity bias field (smaller values yield smoother fields). If a float, sample from RandInt(2, value).

bias_strength Sampler | (0..1)

The maximum magnitude of the bias field (about 1). If a float, sample from Uniform(0, value). The minimum and maximum values of the bias field will be 1 - bias_strength and 1 + bias_strength.

gamma Sampler | float | {False}

The Gamma transform squeezes intensities such that the contrast to noise ratio is decreased (positive values lead to less decreased contrast, positive values lead to increased contrast). If a float, sample the gamma exponent from LogNormal(0, value).

motion_fwhm Sampler | float | {False}

A blur can be perform to model the point spread function or motion-related smearing. The amount of smoothing is encoded by the full-width at half-maximum (FWHM) of the underlying Gaussian kernel. If a float, sample the FWHM from Uniform(0, value).

resolution Sampler | float | {False}

Thick-slice or isotropic low-resolution (LR) images are randomly applied. and their (through-slice or iso) resolution is controlled here. It is defined as a proportion of the high-resolution voxel size (i.e., a resolution of 4 mean that the LR voxel size will be four times as large as the input voxel size) If a float, sampled form Uniform(0, value).

snr Sampler | float | {False}

The amount of noise added is encoded by the signal-to-noise ratio (SNR) of the noisy image (larger sampled values yield less noisy images). If a float, the value is a lower bound for SNR (no image will have a poorer SNR than this). The noise variance is then sampled from Uniform(0, 1/snr).

gfactor Sampler | int | {False}

The g-factor is a smooth field that locally scales the noise variance. The sampled value controls the smoothness of the g-factor field. If a float, sample from RandInt(2, value).

sample_in_background bool

If True, sample a Gaussian in the background class. Otherwise, keep it zeros.

Other Parameters:

Name Type Description
returns [(list | dict) of] {'input', 'deformed', 'generators', 'target', 'label', 'image', 'output'}

Tensors to return

  • 'input': the input label map (after loading, if load is provided)
  • 'deformed': the deformed label map (after deform, if provided)
  • 'generators': the generator maps (after preproc, if provided)
  • 'target', 'label': the target label map (after postproc, if provided)
  • 'image', 'output': the generated image (after intensity, if provided)

Final class-attribute instance-attribute

Final = ApplySynthFromLabelTransform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = ApplySynthFromLabelTransform

The transform type returned by make_final.