Training Models

class InnerEye.ML.photometric_normalization.PhotometricNormalization(config_args: Optional[SegmentationModelBase] = None, **params: Any)[source]
name = 'PhotometricNormalization'
param = <param.parameterized.Parameters object>
transform(image: Union[ndarray, Tensor], mask: Optional[Union[ndarray, Tensor]] = None, patient_id: Optional[int] = None) Union[ndarray, Tensor][source]
class InnerEye.ML.photometric_normalization.WindowNormalizationForScalarItem(output_range: Tuple[float, float] = (0, 1), sharpen: float = 1.9, tail: float = 1.0)[source]

Transform3D to apply window normalization to “images” of a ScalarItem.

name = 'WindowNormalizationForScalarItem'
param = <param.parameterized.Parameters object>
InnerEye.ML.photometric_normalization.mri_window(image_in: ndarray, mask: Optional[ndarray], output_range: Tuple[float, float] = (- 1.0, 1.0), sharpen: float = 1.9, tail: Union[List[float], float] = 1.0, debug_mode: bool = False) Tuple[array, str][source]

This function takes an MRI Image, removes to first peak of values (air). Then a window range is found centered around the mean of the remaining values and with a range controlled by the standard deviation and the sharpen input parameter. The larger sharpen is, the wider the range. The resulting values are the normalised to the given output_range, with values below and above the range being set the the boundary values.

Parameters:
  • image_in – The image to normalize.

  • mask – Consider only pixel values of the input image for which the mask is non-zero. If None the whole image is considered.

  • output_range – The desired value range of the result image.

  • sharpen – number of standard deviation either side of mean to include in the window

  • tail – Default 1, allow window range to include more of tail of distribution.

  • debug_mode – If true, create diagnostic plots.

Returns:

normalized image

InnerEye.ML.photometric_normalization.normalize_trim(image: ndarray, mask: ndarray, output_range: Tuple[float, float] = (- 1.0, 1.0), sharpen: float = 1.9, trim_percentiles: Tuple[float, float] = (2.0, 98.0), debug_mode: bool = False) array[source]

Normalizes a single image to have mean 0 and standard deviation 1 Normalising occurs after percentile thresholds have been applied to strip out extreme values

Parameters:
  • image – The image to normalize, size Channels x Z x Y x X

  • mask – Consider only pixel values of the input image for which the mask is non-zero. Size Z x Y x X

  • output_range – The desired value range of the result image.

  • sharpen – number of standard deviation either side of mean to include in the window.

  • trim_percentiles – Only consider voxel values between those two percentiles when computing mean and std.

  • debug_mode – If true, create a diagnostic plot (interactive)

Returns:

trimmed-normalized image

InnerEye.ML.photometric_normalization.robust_mean_std(data: ndarray) Tuple[float, float, float, float][source]

Computes robust estimates of mean and standard deviation in the given array. The median is the robust estimate for the mean, the standard deviation is computed from the inter-quartile ranges.

Parameters:

data – The data for which mean and std should be computed.

Returns:

A 4-tuple with values (median, robust_std, minimum data value, maximum data value)

InnerEye.ML.photometric_normalization.simple_norm(image_in: ndarray, mask: ndarray, debug_mode: bool = False) array[source]

Normalizes a single image to have mean 0 and standard deviation 1

Parameters:
  • image_in – image to normalize

  • mask – image, has W x H x D

  • debug_mode – whether to log means and SDs

Returns:

normalized image