List of Operations

Table of contents

AddCenterBoxOperation

Add an additional channel to the input image with a binary box at its center. The purpose of that operation is to give a location information to the model.

AddDegradedLabelAsChannelOperation

Append a channel to the image that contains a degraded version of the label. Given provided blob coordinates, the channel is zero except for at blobs at specified locations. The nonzero values are positive/negative based on whether the values are inside/outside of a label that has been eroded/dilated based on the label_dilation parameter.

AddPixelwisePredictionChannelOperation

Run an existing pixelwise model and add result to the input image as additional channels. The prediction is automatically resampled to the input image resolution.

AddPositionChannelOperation

Add additional channels with the position of the pixels. Execute the algorithm AddPositionAsChannelAlgorithm internally, and uses the same configuration (parameter names and values).

AddRandomNoiseOperation

Apply a pixelwise random noise to the image intensities.

For type == "uniform": noise is drawn in \([-\textnormal{intensity}, \textnormal{intensity}]\).
For type == "gaussian: noise is drawn from a Gaussian with zero mean and standard deviation equal to \(\textnormal{intensity}\).
For type == "gamma": noise is drawn from a Gamma distribution with \(k = \theta = \textnormal{intensity}\) (note that this noise has a mean of 1.0 so it is biased).
For type == "shot": noise is drawn from a Gaussian with zero mean and standard deviation equal to \(\textnormal{intensity} * \sqrt{\textnormal{pixel_value}}\).

AdjustShiftScaleOperation

Apply a shift and scale to each channel of the input image. If shift and scale are vectors with multiple values, then for each channel c, \(\textnormal{output}_c = (\textnormal{input}_c + \textnormal{shift}_c) / \textnormal{scale}_c\). If shift and scale have a single value, then for each channel c, \(\textnormal{output}_c = (\textnormal{input} + \textnormal{shift}_c) / \textnormal{scale}\).

ApplyTopDownFlagOperation

Flip the input image if it has a topDown flag set to false.

Note

The topDown flag is not accessible from Python

ApproximateToHigherResolutionOperation

Replicate the input image of the operation from the original reference image (in ReferenceImageDataComponent) This operation is to be used mainly as post-processing, when a model produces a filtered image at a sub-resolution: it then tries to replicate the output from the original image so that no resolution is lost. It consists in estimating a multiplicative scalar field between the input and the downsampled original image, upsample it and then re-apply it on the original image.

ArgMaxOperation

Create a label map with the indices corresponding of the input channel with the highest value. The output of this operation is zero indexed, i.e. no matter which channels where selected the output is always in range [0; n - 1] where n is the number of selected channels (+ 1 if background threshold selected).

AxisFlipOperation

Flip image content along specified set of axes.

AxisRotationOperation

Rotate image around image axis with axis-specific rotation angles that are signed multiples of 90 degrees.

BakeDeformationOperation

Deform an image with its attached Deformation and store the result into the returned output image. This operation will return a clone of the input image if it does not have any deformation attached. The output image will not have an attached Deformation.

BakePhotometricInterpretationOperation

Bake the Photometric Interpretation into the intensities of the image. If the image has a Photometric Interpretation of MONOCHROME1, the intensities will run be inverted using: \(\textnormal{output} = \textnormal{max} - (\textnormal{input} - \textnormal{min})\)

BakeTransformationOperation

Apply the rotation contained in the input image matrix.

BlobsFromKeypointsOperation

Transforms keypoints into an actual image (blob map with the same size of the image). Requires an input image called “data” (can be overwritten with the parameter image_field_name) and some keypoints called “keypoints” (can be overwritten with the parameter apply_to).

CheckDataOperation

Checks if all input data match a set of expected conditions. If parameters are zero or empty, they are not checked.

ClipOperation

Clip the intensities to a minimum and maximum value: all intensities outside this range will be clipped to the range border.

ConcatenateNeighboringFramesToChannelsOperation

This function iterates over each frame, augmenting the channel dimension by appending or adding information from neighboring frames from both sides. For instance, with radius=1 concatenation, an image with dimensions (10, 1, 256, 256, 1) becomes an (10, 1, 256, 256, 3) image, meaning each frame will now include its predecessor (channel 0), itself (channel 1), and its successor (channel 2). For multi-channel inputs, only the first channel is used for concatenation; other channels are appended after these in the output. With reduction_mode, central and augmented frames can be reduced to a single frame to preserve the original number of channels.

ConvertSlicesToVolumeOperation

Stacks a set of 2D images extracted along a specified axis into an actual 3D volume.

ConvertToGrayOperation

Convert the input image to a single channel image by averaging all channels.

ConvertVolumeToSlicesOperation

Unstacks a 3D volume to a set of 2D images extracted along one of the axes.

ConvolutionalCRFOperation

Adapt segmentation map or raw output of model to image content.

CopyOperation

Copies a set of fields of a data item.

CropAroundLabelMapOperation

Crops the input image and label to the bounds of the specified label value, and sets the label value to 1 and all other values to zero in the resulting label.

CropOperation

Crop input images and label maps with a given size and offset.

CutOutOperation

Cut out input images and label maps with a given size, offset and fill values.

DeformationOperation

Apply a deformation to the image using a specified control point grid and specified displacements.

EnsureExplicitMaskOperation

Converts the existing mask of all input images into explicit masks. If an image does not have a mask, no mask will be created. Warning: This operation might be computationally extensive since it processes every frame of the SharedImageSet independently.

EnsureOneToOneMatrixMappingOperation

Ensures that it is possible to get/set the matrix of each frame of the input image set independently. This operation is targeted at TrackedSharedImageSets, which might define their matrices via a tracking sequence with timestamps (there is then no one-to-one correspondence between matrices and images, but matrices are looked-up and interpolated via their timestamps). In such cases, the operation creates a new tracking sequence with as many samples as images and turns off the timestamp usage.

ExtractRandomSubsetOperation

Extracts a random subset from a SharedImageSet.

ExtractSubsetOperation

Extracts a subset from a SharedImageSet.

ForegroundGuidedLabelUpsamplingOperation

Generates a high-resolution label map by upsampling a multi-class softmax prediction guided by a high-resolution binary segmentation. This operation combines a high-resolution binary segmentation (e.g., from a sigmoid prediction) with a lower-resolution multi-class one-hot encoded segmentation (e.g., from a softmax prediction) to produce a refined high-resolution multi-class label map. The approach is inspired by pan-sharpening techniques used in remote sensing (https://arxiv.org/abs/1504.04531). The multi-class one hot image should contain the background class as the first channel.

GammaCorrectionOperation

Apply a gamma correction which changes the overall contrast (see https://en.wikipedia.org/wiki/Gamma_correction)

GenerateRandomKeypointsOperation

Generate uniformly distributed random keypoints in the image. Optionally the distribution is restricted to label values that are nonzero, otherwise (or if there are no nonzero label values), then the keypoints are sampled from the entire image extent. There is a fixed (but configurable) number of keypoints per channel, and a fixed (but configurable) number of output channels in the output keypoint element.

HighPassOperation

Smooths the input image with a Gaussian kernel with half_kernel_size, then subtracts the smoothed image from the input, resulting in a reduction of low-frequency components.

ImageMattingOperation

Refine edges of label-map based on the intensities of the input image. This can make coarse predictions smoother or may correct wrong predictions on the boundaries. It applies the method from the paper “Guided Image Filtering” by Kaiming He et al.

InvertOperation

Invert the intensities of the image: \(\textnormal{output} = -\textnormal{input}\).

KeepLargestComponentOperation

Create a label map with the largest components above the specified threshold. The output label map encodes each component with a different label value (1 for the largest, 2 for the second largest, etc.). Input images may be float or integer, output are unsigned 8-bit integer images (i.e. max 255 components). The operation will automatically set the default processing policy based on its input (if the input contains more than than one image, then only the label maps will be processed).

KeypointsFromBlobsOperation

Extracts keypoints from blob image. Takes ImageElement specified in :code:’apply_to’ as input. If :code:’apply_to’ is not specified and there is only one image in the data item, this image will automatically be selected.

LinearIntensityMappingOperation

Apply a linear shift and scale to the image intensities. \(\textnormal{output} = \textnormal{factor} * \textnormal{input} + \textnormal{bias}\)

MRIBiasFieldCorrectionOperation

Perform bias field correction using an implicitly trained neural network (see MRIBiasFieldCorrectionAlgorithm for more details and the parameters description).

MRIBiasFieldGenerationOperation

Apply or generate a multiplicative intensity modulation field. If the output is a field, it is shifted as close to mean 1 as possible while remaining positive everywhere. If the output is not a field, the image intensity is shifted so that the mean intensity of the input image is preserved.

MakeFloatOperation

Convert the input image to float with original values (internal shifts and scales are baked in).

MarkAsTargetOperation

Mark elements from the input data item as learning “target” which might affect the behaviour of the subsequent operations that rely on ProcessingPolicy or use other custom target-specific logic.

MergeAsChannelsOperation

Merge multiple DataElements into a single one along the channel dimension. Only applicable for ImageElements and VectorElements.

MorphologicalFilterOperation

Runs a morphological operation on the input.

NormalizeMADOperation

Normalize the input image based on robust statistics. The image is shifted so that the median corresponds to 0 and normalized with the median absolute deviation (see https://en.wikipedia.org/wiki/Median_absolute_deviation). The operation is performed channel-wise.

NormalizeNormalOperation

Normalize the input image so that it has a zero-mean and a unit-standard deviation. A particular intensity value can be set to be ignored during the computations.

NormalizePercentileOperation

Normalize the input image based on its intensity distribution, in particular on a lower and upper percentile. The output image is not guaranteed to be in [0;1] but the lower percentile will be mapped to 0 and the upper one to 1.

NormalizeUniformOperation

Normalize the input image based so their minimum/maximum intensity so that the output image has a [min; max] range. The operation is performed channel-wise.

OneHotOperation

Encode a single channel label image, to a one-hot representation of ‘channels’ channels. If encode_background is off, label ‘0’ will denote the background and doesn’t encode to anything, Label ‘1’ will set the value ‘1’ in the first channel, Label ‘2’ will set the value ‘1’ in the second channels, etc. If encode_background is on, label ‘0’ will be the background and set the value ‘1’ in the first channel, Label ‘1’ will set the value ‘1’ in the second channel, etc. The number of channels must be large enough to contain this encoding.

PadDimsOperation

This operation expands an image by adding padding pixels to any or all sides.

The value of the border can be specified by the padding mode:
- Clamp: The border pixels are the same as the closest image pixel.
- Mirror: The border pixels are the same as the closest image pixel.
- Zero: Constant padding with zeros or, if provided, with paddingValue.

For label maps (i.e. modality == Modality.LABEL), a separate padding mode and value can be specified:
- If both label padding mode and label padding value are specified, those values are used to pad the label map.
- If only the label padding mode is specified, the paddingValue is used to fill the label map (only for zero padding).
- If only the label padding value is specified, the paddingMode is used as the label padding mode.
- If neither label padding mode nor label padding value is specified, paddingMode and paddingValue are used for label maps as well.

Note: the padding widths are evenly distributed to the left and right of the input image.

If the difference delta between the target dimensions and the input dimensions is odd, the padding is distributed as delta / 2 to the left and delta / 2 + 1 to the right.

PadDimsToNextMultipleOperation

Pads each dimension of the input image to the next multiple of the specified divisor.

For example, if an image has dimensions (100, 150, 200) and dimension_divisor is (32, 16, 64), the output will have dimensions (128, 160, 256).

This operation is useful for ensuring that the input dimensions are compatible with a ML model (e.g. a CNN or UNet) that expects specific dimensions.

The value of the border can be specified by the padding mode:
- Clamp: The border pixels are the same as the closest image pixel.
- Mirror: The border pixels are the same as the closest image pixel.
- Zero: Constant padding with zeros or, if provided, with paddingValue.
For label maps (i.e. modality == Modality.LABEL), a separate padding mode and value can be specified:
- If both label padding mode and label padding value are specified, those values are used to pad the label map.
- If only the label padding mode is specified, the paddingValue is used to fill the label map (only for zero padding).
- If only the label padding value is specified, the paddingMode is used as the label padding mode.
- If neither label padding mode nor label padding value is specified, paddingMode and paddingValue are used for label maps as well.
Note: the padding widths are evenly distributed to the left and right of the input image.

If the difference delta between the target dimensions and the input dimensions is odd, the padding is distributed as delta / 2 to the left and delta / 2 + 1 to the right.

PadOperation

Pad an image to a specific padding size in each dimension.

This operation expands an image by adding padding pixels to any or all sides.

The value of the border can be specified by the padding mode:
- Clamp: The border pixels are the same as the closest image pixel.
- Mirror: The border pixels are the same as the closest image pixel.
- Zero: Constant padding with zeros or, if provided, with paddingValue.
For label maps (i.e. modality == Modality.LABEL), a separate padding mode and value can be specified:
- If both label padding mode and label padding value are specified, those values are used to pad the label map.
- If only the label padding mode is specified, the paddingValue is used to fill the label map (only for zero padding).
- If only the label padding value is specified, the paddingMode is used as the label padding mode.
- If neither label padding mode nor label padding value is specified, paddingMode and paddingValue are used for label maps as well.

Note: Padding sizes are specified in pixels, and can be positive, negative or mixed. Negative padding means cropping. Note: Both GPU and CPU implementations are provided.

PolyCropOperation

Masks the image with a convex polygon as described in Markova et al. 2022. (https://arxiv.org/abs/2205.03439)

RandomAddDegradedLabelAsChannelOperation

Append a channel to the image that contains a randomly degraded version of the label.

RandomAddRandomNoiseOperation

Apply AddRandomNoiseOperation to images with randomized intensity parameter.

RandomAxisFlipOperation

Flip image content along specified set of axes, with independent sampling for each axis.

RandomAxisRotationOperation

Rotate image around image axis with independently drawn axis-specific random rotation angle of +-{90, 180, 270} degrees.

RandomChoiceOperation

Meta-operation that picks one operation from its configuration randomly and executes it. This is particularly useful for image samplers, where we might want to alternate between different ways of sampling the input images.

RandomCropAroundLabelMapOperation

Crops the input image and label to the bounds of a random label value, and sets the label value to 1 and all other values to zero in the resulting label.

RandomCropOperation

Crop input images and label maps with a matching random size and offset.

RandomCutOutOperation

Apply a random cutout to the image.

RandomDeformationOperation

Apply a deformation to the image using a specified control point grid and random displacements

RandomGammaCorrectionOperation

Apply a random gamma correction to the image intensities. Output = Unnormalize(pow(Normalize(Input), gamma)) where gamma is drawn uniformly in [1-random_range; 1+random_range].

RandomImageFromLabelOperation

Creates a random image from a label map, each label is sampled from a Gaussian distribution. Each Gaussian distribution parameters (mean and standard deviation) are uniformly sampled withing the provided intervals (respectively mean_range and standard_dev_range).

RandomInvertOperation

Invert the intensities of the image: \(\textnormal{output} = -\textnormal{input}\).

RandomKeypointJitterOperation

Adds an individually and randomly sampled offset to each keypoint of each KeypointElement.

RandomLinearIntensityMappingOperation

Apply a random linear shift and scale to the image intensities. \(\textnormal{output} = \textnormal{factor}_\textnormal{random} * \textnormal{input} + \textnormal{bias}_\textnormal{random}\) ,

where \(\textnormal{factor}_\textnormal{random}\) is drawn uniformly in \([1-\textnormal{random_range}, 1+\textnormal{random_range}]\)
and \(\textnormal{bias}_\textnormal{random}\) is drawn uniformly in \([-\textnormal{random_range}*(\max(\textnormal{input})-\min(\textnormal{input})), \textnormal{random_range}*(\max(\textnormal{input})-\min(\textnormal{input}))]\).

RandomMRIBiasFieldGenerationOperation

Apply or generate a random multiplicative intensity modulation field. If the output is a field, it is shifted as close to mean 1 as possible while remaining positive everywhere. If the output is not a field, the image intensity is shifted so that the mean intensity of the input image is preserved.

RandomPolyCropOperation

Masks the image with a random convex polygon as described in Markova et al. 2022 (https://arxiv.org/abs/2205.03439). The convex polygon mask is constructed by sampling random planes, each plane splits the volume in two parts, the part of the image that doesn’t contain the image center is discarded.

RandomResolutionReductionOperation

Downsamples the image to a target_spacing and upsamples again to the original spacing to reduce image information. The target_spacing is sampled uniformly and independently in each dimension between the corresponding image spacing and max_spacing.

RandomRotationOperation

Rotate input images and label maps with random angles.

RandomScalingOperation

Scale input images and label maps with random factors.

RandomSmoothOperation

Apply a random smoothing on the image (Gaussian kernel). The kernel can be parameterized either in pixel or in mm, and can be anisotropic. The half kernel size is distributed uniformly between half_kernel_bounds[0] and half_kernel_bounds[1]. \(\textnormal{image_output} = \textnormal{image} * \textnormal{gaussian_kernel}(\sigma)\) , with \(\sigma \sim U(\textnormal{half_kernel_bounds}[0], \textnormal{half_kernel_bounds}[1])\)

RandomTemplateInpaintingOperation

Inpaints a template into an image with randomly selected spatial and intensity transformation in a given range.

RecombinePatchesOperation

Operation to recombine image patches back into a full image.

This operation is typically used in conjunction with SplitROISampler to reconstruct a full image from its patches after processing (e.g., after neural network inference).

The operation handles overlapping patches by averaging the overlapping regions. For each output pixel, the final value is computed as the weighted average of all patches that contain that pixel. The weighting mode is specified by the RecombineMode parameter.

The operation requires input images to have a PatchesFromImageDataComponent that stores the location of each patch in the original image. This component is automatically added by the SplitROISampler.

Two recombination modes are supported: - Default: Simple averaging of overlapping regions - Weighted: Weighted averaging of overlapping regions (currently same as Default)

Both GPU and CPU computing devices are supported, via the ComputingDevice parameter in Operation.

Note: RecombineMode can be automatically converted from a string. This means you can directly pass a string like “default” or “weighted” to the mode parameter instead of using the enum values.

RectifyRotationOperation

Sets the image matrix to the closest xyz-axis aligned rotation, effectively making every rotation angle a multiple of 90 degrees. This is useful when the values of the rotation are unimportant but the axis flips need to be preserved. If used before BakeTransformationOperation, this operation will avoid oblique angles and a lot of zero padding.

RemoveMaskOperation

Removes the mask of all input images.

RemoveOperation

Removes a set of fields from a data item.

RenameOperation

Renames a set of fields of a data item.

ReplaceLabelsValuesOperation

Replace some label values with other values (only works for integer-typed labels).

For convenience purposes, a default value can be set, in which case all not explicitly defined non-zero input values will be assigned this value.

ResampleDimsOperation

Resample the input to fixed target dimensions.

ResampleKeepingAspectRatioOperation

Resample input to target dimensions while keeping aspect ratio of original images. The target dimensions are specified by either:

  1. one target dimension, i.e.: target_dim_x: 128. In such case the resampling will keep the aspect ratio of dimension y and z wrt x.

  2. two target dimensions, i.e.: target_dim_x: 128, i.e.: target_dim_y: 128 and which dimension to consider for preserving the aspect ratio of the leftover dimension, i.e. keep_aspect_ratio_wrt: x.

ResampleOperation

Resample the input to a fixed target resolution.

ResampleToInputOperation

Resample the input image with respect to the image in ReferenceImageDataComponent

ResolutionReductionOperation

Downsamples the image to the target_spacing and upsamples again to the original spacing to reduce image information.

RotationOperation

Rotate input images and label maps with fixed angles.

RunModelOperation

Run a machine learning model on the input item and merge the prediction to the input item. The input field names specified in the model config yaml will be use to determine which fields in the input data item the model is run. If the model doesn’t specify any input field, i.e. is a single input model, the user can either provide an input data item with a single image element, or use the apply_to to specify on which field the model should be run. The input item will be populated with the model prediction. The field names are those specified in the model configuration. If no output name is specified (i.e. single output case), the prediction will be associated to the field “Prediction”

ScalingOperation

Scale input images and label maps with fixed factors.

SelectChannelsOperation

Keeps a subset of the input channels specified by the selected channel indices (0-based indexing).

SetLabelModalityOperation

Sets the input modality. If the target modality is LABEL, warns and skips fields that are not unsigned 8-bit integer. The default processing policy is to apply to targets only.

SetMatrixToIdentityOperation

Set the matrices of all images to identity (associated landmarks and boxes will be moved accordingly).

SetModalityOperation

Sets the input modality. If the target modality is LABEL, warns and skips fields that are not unsigned 8-bit integer. The default processing policy is to apply to all fields.

SetSpacingOperation

Modify images so that image elements have specified spacing (associated landmarks and boxes will be moved accordingly).

SigmoidOperation

Apply a sigmoid function on the input image. \(\textnormal{output} = 1.0/(1.0 + \exp(- \textnormal{scale} * \textnormal{input}))\)

SmoothOperation

Run a convolution with a Gaussian kernel on the input image. The kernel can be parameterized either in pixel or in mm, and can be anisotropic.

SoftmaxOperation

Computes channel-wise softmax on input.

StandardizeImageAxesOperation

Reorganize the memory buffer of a medical image to ensure anatomical consistency.

This operation rearranges the axes and orientation of the input image following the LPS convention (https://slicer.readthedocs.io/en/latest/user_guide/coordinate_systems.html#anatomical-coordinate-system) which is the standard for DICOM images (https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.2.html), i.e.:
- the x-axis is increasing to the left hand side of the patient;
- the y-axis is increasing to the posterior side of the patient;
- the z-axis is increasing toward the head of the patient.

The operation uses the rotation matrix of the image and modifies it so that only a non-axis aligned rotation remains.

Note that this operation only re-arranges internal representations but does not modify the actual spatial position and orientation of the image (as opposed to RectifyRotationOperation). This operation differs from BakeTransformationOperation because it only applies axis-based rotations or flips and therefore does not do any kind of interpolation. Unlike BakeTransformationOperation, a residual rotation might remain in the matrix of the output image.

SwapImageAndLabelsOperation

Swaps image and label map.

SyncOperation

Synchronizes shared memory (CPU <-> OpenGL) of images.

TanhOperation

Apply a tanh function on the input image. \(\textnormal{output} = \tanh(\textnormal{scale} * \textnormal{input})\)

TemplateInpaintingOperation

Inpaints a template into an image with specified spatial and intensity transformation.

ThresholdOperation

Threshold the input image to a binary map with only 0 or 1 values.

UnmarkAsTargetOperation

Unmark elements from the input data item as learning “target”. This operation is the opposite of MarkAsTargetOperation.