CerebNet.data_loader.augmentation

class CerebNet.data_loader.augmentation.RandomAffine(cfg)[source]

Apply a random affine transformation to images, label and weight the transformation includes translation, rotation and scaling.

Methods

__call__(sample)

Call self as a function.

class CerebNet.data_loader.augmentation.RandomBiasField(cfg, seed=None)[source]

Add random MRI bias field artifact.

Based on https://github.com/fepegar/torchio

It was implemented in NiftyNet by Carole Sudre and used in Sudre et al., 2017, Longitudinal segmentation of age-related white matter hyperintensities.

Methods

__call__(sample)

Call self as a function.

apply_transform

generate_bias_field

get_random_params

class CerebNet.data_loader.augmentation.RandomFlip(cfg)[source]

Random horizontal flipping.

Methods

__call__(sample)

Call self as a function.

class CerebNet.data_loader.augmentation.RandomLabelsToImage(mean, std, cfg, blur_factor=0.3)[source]

Generate image from segmentation using the dataset intensity priors. based on Billot et al.: A Learning Strategy for Contrast-agnostic MRI Segmentation and Partial Volume Segmentation of Brain MRI Scans of any Resolution and Contrast.

Methods

__call__(sample)

Call self as a function.

class CerebNet.data_loader.augmentation.ToTensor[source]

Convert ndarrays in sample to Tensors.

Methods

__call__(sample)

Call self as a function.

class CerebNet.data_loader.augmentation.ToTensorTest[source]

Methods

__call__(sample)

Call self as a function.

CerebNet.data_loader.augmentation.sample_intensity_stats_from_image(image, segmentation, labels_list, classes_list=None, keep_strictly_positive=True)[source]

This function takes an image and corresponding segmentation as inputs.

It estimates the mean and std intensity for all specified label values. Labels can share the same statistics by being regrouped into K classes.

Parameters:
imagearray_like

Image from which to evaluate mean intensity and std deviation.

segmentationarray_like

Segmentation of the input image. Must have the same size as image.

labels_listarray_like

List of labels for which to evaluate mean and std intensity. Can be a sequence, a 1d numpy array, or the path to a 1d numpy array.

classes_listarray_like, optional

Enables grouping structures into classes of similar intensity statistics. The intensities associated with regrouped labels will contribute to the same Gaussian during statistics estimation. Can be a sequence, a 1D numpy array, or the path to a 1D numpy array. It should have the same length as labels_list, and contain values between 0 and K-1, where K is the total number of classes. By default, each label is considered its own class (K=len(labels_list)).

keep_strictly_positiveoptional

Whether to only keep strictly positive intensity values when computing stats. This doesn’t apply to the first label in label_list (or class if class_list is provided), for which we keep positive and zero values, as we consider it to be the background label.

Returns:
numpy.ndarray

A numpy array of size (2, K), the first row being the mean intensity for each structure, and the second being the median absolute deviation (robust estimation of std).