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). device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

AddRandomNoiseOperation

Apply a pixelwise random noise to the image intensities. For type ‘uniform’: noise is drawn in [-random_range, random_range]. For ‘gaussian’: noise is drawn from a Gaussian with zero mean and standard deviation equal to random_range. For ‘gamma’: noise is drawn from a Gamma distribution with k = theta = random_range (note that this noise has a mean of 1.0 so it is biased). For ‘shot’: noise is drawn from a Gaussian with zero mean and standard deviation equal to random_range * sqrt(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, Output[c] = (Input[c] + shift[c]) / scale[c]. If shift and scale have a single value, then for each channel c, Output[c] = (Input[c] + shift) / scale.

ApplyTopDownFlagOperation

Flip the input image if it has a topDown flag set to false. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

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: Output = Max - (Input - Min) device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

BakeTransformationOperation

Apply the rotation contained in the input image matrix. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

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. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

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. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

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. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

ExtractRandomSubsetOperation

Extracts a random subset from a SharedImageSet.

ExtractSubsetOperation

Extracts a subset from a SharedImageSet.

GammaCorrectionOperation

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

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: Output = -Input device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

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 ‘apply_to’ as input. If ‘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. Output = factor * Input + 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). device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

MarkAsLabelOperation

Deprecated: Use MarkAsTargetOperation instead. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

MarkAsTargetOperation

Mark elements from the input data item as learning “target” which might affect the behaviour of the subsequent operations that rely on Operation::ProcessingPolicy or use other custom target-specific logic. Use the apply_to parameter from the Operation interface to define which fields should be marked.

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.

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.

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. Use configure() to set the list of operations.

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].

RandomInvertOperation

Invert the intensities of the image: Output = -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. Output = randomScale * Input + randomBias, where randomScale is drawn uniformly in [1-random_range; 1+random_range] and randomBias is drawn uniformly in [-random_range*(max(Input)-min(Input)); random_range*(max(Input)-min(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]. sigma ~ U(half_kernel_bounds[0], half_kernel_bounds[1]) image_output = image * Gaussian_kernel(sigma)

RandomTemplateInpaintingOperation

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

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. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

RemoveOperation

Removes a set of fields from a data item. Uses ‘apply_to’ from the base class to specify which fields to remove. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

RenameOperation

Renames a set of fields of a data item.

ReplaceLabelsValuesOperation

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

ResampleDimsOperation

Resample the input to fixed target dimensions.

ResampleOperation

Resample the input to a fixed target resolution.

ResampleToInputOperation

Resample the input image with respect to the image in ReferenceImageDataComponent device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

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/set_active_fields 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 Data::Modality::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). device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

SetModalityOperation

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

SigmoidOperation

Apply a sigmoid function on the input image. Output = 1.0/(1.0 + exp(- scale * 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. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

SwapImageAndLabelsOperation

Swaps image and label map. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

SyncOperation

Synchronizes shared memory (CPU <-> OpenGL) of images. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. processing_policy: Heuristic specifying whether this Operation should also / only process labels should be processed. Only relevant if apply_to is not specified as it would take precedence error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

TanhOperation

Apply a tanh function on the input image. Output = tanh(scale * 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. Use the apply_to parameter from the Operation interface to define which fields should be unmarked.

class imfusion.machinelearning.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.

Parameters:
  • box_half_width (int) – Half-width of the box in pixels.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • blob_radius (float) – Radius of each blob, in pixel coordinates. Default: 5.0

  • invert (bool) – Extra channel is positive/negative based on the label values except for at the blobs, where it is zero. Default: False

  • blob_coordinates ([vec3]) – Centers of the blobs in pixel coordinates. Default: []

  • only_positive (bool) – If true, output channel is clamped to zero from below. Default: False

  • label_dilation (float) – The dilation (if positive) or erosion (if negative), none if zero. Default: 0.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • config_path (string) – path to the YAML configuration file of the pixelwise model

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.AddPositionChannelOperation

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

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.AddRandomNoiseOperation

Apply a pixelwise random noise to the image intensities. For type ‘uniform’: noise is drawn in [-random_range, random_range]. For ‘gaussian’: noise is drawn from a Gaussian with zero mean and standard deviation equal to random_range. For ‘gamma’: noise is drawn from a Gamma distribution with k = theta = random_range (note that this noise has a mean of 1.0 so it is biased). For ‘shot’: noise is drawn from a Gaussian with zero mean and standard deviation equal to random_range * sqrt(pixel_value).

Parameters:
  • type (string) – Distribution of the noise (‘uniform’, ‘gaussian’, ‘gamma’). Default: ‘uniform’

  • random_range (float) – Value related to the standard deviation of the generated noise. Default: 0.2

  • probability (float) – Value in [0.0; 1.0] indicating the probability of this operation to be performed. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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, Output[c] = (Input[c] + shift[c]) / scale[c]. If shift and scale have a single value, then for each channel c, Output[c] = (Input[c] + shift) / scale.

Parameters:
  • shift (list) – Shift parameters as double (one value per channel, or one single value for all channels). Default: [0.0]

  • scale (list) – Scaling parameter as double (one value per channel, or one single value for all channels). Default: [1.0]

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ApplyTopDownFlagOperation
Flip the input image if it has a topDown flag set to false.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

  • axes: [‘y’]

class imfusion.machinelearning.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.

Parameters:
  • epsilon (float) – Used to avoid division by zero in case the original image has zero values. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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).

Parameters:
  • selected_channels (list) – List of channels to be selected for the argmax. If empty, use all channels (default). Indices are zero indexed, e.g. [0, 1, 2, 3] selects the first 4 channels.

  • background_threshold (float) – If set, the arg-max operation assumes the background is not explicitly encoded, and is only set when all activations are below background_threshold. The output then encodes 0 as the background. E.g. if the first 4 channels were selected, the possible output values would be [0, 1, 2, 3, 4] with 0 for the background and the rest for the selected channels.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.AxisFlipOperation

Flip image content along specified set of axes.

Parameters:

axes (list) – List of strings from {‘x’,’y’,’z’} specifying the axes to flip. For 2D images, only ‘x’ and ‘y’ are valid. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.AxisRotationOperation

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

Parameters:
  • axes (list) – List of strings from {‘x’,’y’,’z’} specifying the axes to rotate around. For 2D images, only [‘z’] is valid. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

  • angles (list) – List of integers (with same lengths as axis) specifying the rotation angles in degrees. Only +- 0/90/180/270 are valid.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • adjust_size (bool) – whether the size of the output image would be automatically adjusted to fit the deformed content. Default: True

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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: Output = Max - (Input - Min)

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.BakeTransformationOperation
Apply the rotation contained in the input image matrix.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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).

Parameters:
  • blob_radius (float) – Size of the generated blobs in mm. Default: 5.0

  • image_field_name (str) – Field name of the reference image. Default: “data”

  • blobs_field_name (str) – Field name of the output blob map. Default: “label”

  • label_map_mode (bool) – Generate ubyte label map instead of multi-channel gaussian blobs. Default: False

  • sharp_blobs (bool) – Specifies whether to sharpen the profiles of the blob function, making its support more compact. Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 2

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.CheckDataOperation

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

Parameters:
  • num_dimensions (int) – number of input dimensions. Default: 0 (disabled)

  • num_images (int) – number of input images. Default: 0 (disabled)

  • num_channels (int) – number of input channels. Default: 0 (disabled)

  • data_type (string) – dataype of input. Possible types are [“”, “float”, “uint8”, “int8”, “uint16”, “int16”, “uint32”, “int32”, “double”]. Default: “” (disabled)

  • dimensions (vec3i) – spatial dimensions of input image. Default: [0,0,0] (disabled)

  • spacing (vec3) – spacing of input image. Default: [0,0,0] (disabled)

  • label_match_input (bool) – label matches input in spatial dimensions and number of channels. Default: False

  • label_type (string) – datatype of labels. Possible types are [“”, “float”, “uint8”, “int8”, “uint16”, “int16”, “uint32”, “int32”, “double”]. Default: “” (disabled)

  • label_values (vec3i) – values except 0 which have to be present in the label image. Other values and missing values are not allowed. Default: [] (disabled)

  • label_dimensions (vec3i) – spatial dimensions of label image. Default: [0,0,0] (disabled)

  • label_channels (int) – number of label channels. Default: 0 (disabled)

  • check_rotation_matrix (bool) – makes sure the input image does not have a rotation matrix. Default: False

  • check_deformation (bool) – makes sure the input image does not have any deformation. Default: False

  • check_shift_scale (bool) – make sure the input image has an identity intensity transformation. Default: False

  • fail_on_error (bool) – whether to fail if data are inconsistent, otherwise only logs the error. Default: True

  • save_path_on_error (string) – if not empty, will write the offending input to this path (in case of failure). Default: “” (disabled)

  • label_values_check_subset (bool) – if true, the label values are checked as a subset of the label_values parameter (if provided). Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

  • check_label_values_are_subset: False

class imfusion.machinelearning.ClipOperation

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

Parameters:
  • min (float) – Minimum intensity of the output image. Default: 0.0

  • max (float) – Maximum intensity of the output image. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • radius (int) – Defines the number of neighboring frames added to each side within the channel dimension. Default: 0

  • reduction_mode (string) – Determines if and how to reduce neighboring frames. Options: “none” (default, concatenates), “average”, “maximum”.

  • same_padding (bool) – Use frame replication (not zero-padding) at sequence edges. Default: True

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ConvertSlicesToVolumeOperation

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

Parameters:
  • axis (str) – Axis along which to extract slices (must be either ‘x’, ‘y’ or ‘z’)

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ConvertToGrayOperation
Convert the input image to a single channel image by averaging all channels.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ConvertVolumeToSlicesOperation

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

Parameters:
  • axis (str) – Axis along which to extract slices (must be either ‘x’, ‘y’ or ‘z’)

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ConvolutionalCRFOperation

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

Parameters:
  • adaptiveness (float) – Indicates how much the segmentation should be adapted to the image content. Range [0, 1]. Default: 0.5

  • smooth_weight (float) – Weight of the smoothness kernel. Higher values create a greater penalty for nearby pixels having different labels. Default: 0.1

  • radius (int) – Radius of the message passing window in pixels. Default: 5

  • downsampling (int) – Amount of downsampling used in message passing, makes the effective radius of the message passing window larger. Default: 2

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 2

  • error_on_unexpected_behaviour: False

  • label_compatibilites:

  • positive_label_score: 1.0

  • convergence_threshold: 0.00100000004749745

  • negative_label_score: -1.0

  • max_num_iter: 50

  • smoothness_sigma: 1.0

  • appearance_sigma: 0.25

class imfusion.machinelearning.CopyOperation

Copies a set of fields of a data item.

Parameters:
  • source (List[str]) – list of the elements to be copied

  • target (List[str]) – list of names of the new elements (must match the size of source)

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • label_values ([int]) – Label values to select. Default: [1]

  • margin (int) – Margin, in pixels. Default: 1

  • reorder (bool) – Whether label values in result should be mapped to 1,2,3… based on input in label_values. Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.CropOperation

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

Parameters:
  • size (vec3i) – List of integers representing the target dimensions of the image to be cropped. If -1 is specified, the whole dimension will be kept, starting from the corresponding offset.

  • offset (vec3i) – List of integers representing the position of the lower corner of the cropped image

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.CutOutOperation

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

Parameters:
  • size (vector<vec3>) – List of 3-dim vectors representing the target dimensions of the image to be cut out. Default: [1, 1, 1]

  • offset (vector<vec3i>) – List of 3-dim vectors representing the position of the lower corner of the cut out area. Default: [0, 0, 0]

  • fill_value (vector<float>) – List of intensity value (floats) for filling out cutout region. Default: [0.0]

  • size_units (ParamUnit) – Units of the size parameter. Default: ParamUnit::MM

  • offset_units (ParamUnit) – Units of the offset parameter. Default: ParamUnit::Voxel

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.DeformationOperation

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

Parameters:
  • num_subdivisions (vec3i) – list specifying the number of subdivisions for each dimension (the number of control points is subdivisions+1). Default: [1, 1, 1]

  • displacements (vector<vec3f>) – list of 3-dim vectors specifying the displacement (mm) for each control point. Should have length equal to the number of control points. Default: []

  • padding_mode (PaddingMode) – defines which type of padding is used. Default: PaddingMode::Zero

  • adjust_size (bool) – configures whether the resulting image should adjust its size to encompass the deformation. Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ExtractRandomSubsetOperation

Extracts a random subset from a SharedImageSet.

Parameters:
  • subset_size (int) – Size of the extracted subset of images. Default: 1

  • keep_order (bool) – If true the extracted subset will have the same ordering as the input. Default: False

  • probability (float) – Probability of applying this Operation. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ExtractSubsetOperation

Extracts a subset from a SharedImageSet.

Parameters:
  • subset (List[int]) – Indices of the selected images.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.GammaCorrectionOperation

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

Parameters:
  • gamma (float) – Power applied to the normalized intensities. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • half_kernel_size (int) – half kernel size in pixels. Corresponding standard deviation is half_kernel_size / 3.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • img_size (int) – target image dimension. No downsampling if 0.

  • kernel_size (int) – guided filter kernel size.

  • epsilon (float) – guided filter epsilon.

  • num_iters (int) – guided filter number of iterations.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 2

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.InvertOperation

Invert the intensities of the image: Output = -Input

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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).

Parameters:
  • max_number_components (int) – the maximum number of components to keep. Default: 1

  • min_component_size (int) – the minimum size of a component to keep. Default: -1, i.e. no minimum

  • max_component_size (int) – the maximum size of a component to keep Default: -1, i.e. no maximum

  • threshold (float) – the threshold to use for the binarization. Default: 0.5

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.KeypointsFromBlobsOperation

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

Parameters:
  • keypoints_field_name (str) – Field name of the output keypoints. Default: “keypoints”

  • keypoint_extraction_mode (int) – Extraction mode: 0: Max, 1: Mean, 2: Local Max. Default: 0

  • blob_intensity_cutoff (float) – Minimum blob intensity to be considered in analysis. Default: 0.02

  • min_cluster_distance (float) – In case of local aggregation methods, minimum distance allowed among clusters. Default: 10.0

  • min_cluster_weight (float) – In case of local aggregation methods, minimum intensity for cluster to be consider independent. Default: 0.1

  • max_internal_clusters (int) – In case of local aggregation methods, maximum number of internal clusters to be considered; to avoid excessive numbers that stall the algorithm. If there are more, the lower weighted ones are removed first. Default: 1000

  • run_smoothing (bool) – Runs a Gaussian smoothing with 1 pixel standard deviation to improve stability of local maxima. Default: False

  • smoothing_half_kernel (int) – Runs a Gaussian smoothing with 1 pixel standard deviation to improve stability of local maxima. Default: 2

  • run_intensity_based_refinement (bool) – Runs blob intensity based refinement of clustered keypoints. Default: False

  • apply_to (List[str]) – Field containing the blob image. If not specified and if there is only one image in the data item, this image will automatically be selected. Default: []

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 2

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.LinearIntensityMappingOperation

Apply a linear shift and scale to the image intensities. Output = factor * Input + bias,

Parameters:
  • factor (float) – Multiplying factor (see formula). Default: 1.0

  • bias (float) – Additive bias (see formula). Default: 0.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.MRIBiasFieldCorrectionOperation

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

Parameters:
  • iterations (int) – For values > 1, the field is iteratively refined. Default: 1

  • config_path (str) – Path of the machine learning model (use “GENERIC3D” or “GENERIC2D” for the default models). Default: “GENERIC3D”

  • field_smoothing_half_kernel (int) – For values > 0, additional smoothing with a Gaussian kernel. Default: -1

  • preserve_mean_intensity (bool) – Preserve the mean image intensity in the output. Default: True

  • output_is_field (bool) – Produce the field, not the corrected image. Default: False

  • field_dimensions (vec3i) – Internal field dimensions (zeroes represent the model default dimensions). Default: [0, 0, 0]

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • length_scale_mm (float) – Length scale (in mm) of the Gaussian radial basis function. Default: 100.0

  • field_amplitude (float) – Total field amplitude (centered around one). I.e. 0.4 for a 40% field. Default: 0.4

  • center (vec3) – Relative center of the Gaussian with respect to the image axes. Values from [0..1] for locations inside the image. Default: [0.25, 0.25, 0.25]

  • distance_scaling (vec3) – Relative scaling of the x, y, z world coordinates for field anisotropy. Default: [1, 1, 1]

  • invert_field (bool) – Invert the final field: field <- 2 - field. Default: False

  • output_is_field – Produce the field, not the corrupted image. Note, the additive normalization method depends on this. Default: False

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

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

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.MarkAsLabelOperation
Deprecated: Use MarkAsTargetOperation instead.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • apply_to: []

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.MarkAsTargetOperation

Mark elements from the input data item as learning “target” which might affect the behaviour of the subsequent operations that rely on Operation::ProcessingPolicy or use other custom target-specific logic. Use the apply_to parameter from the Operation interface to define which fields should be marked.

Parameters:
  • apply_to (List[str]) – fields to mark as targets (will initialize the underlying apply_to parameter)

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.MergeAsChannelsOperation

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

Parameters:
  • apply_to (List[str]) – fields which should be merged.

  • output_field (str) – name of the resulting field.

  • remove_fields (bool) – remove fields used for merging from the data item. Default: True

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.MorphologicalFilterOperation

Runs a morphological operation on the input.

Parameters:
  • mode (string) – name of the operation in [‘dilation’, ‘erosion’, ‘opening’, ‘closing’]

  • op_size (int) – size of the structuring element

  • use_l1_distance (bool) – flag to use L1 (absolute) or L2 (squared) distance in the local computations

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 2

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • selected_channels (list) – channels selected for MAD normalization. If empty, all channels are normalized (default).

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

  • fix_median: False

class imfusion.machinelearning.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.

Parameters:
  • keep_background (bool) – Should ignore all intensities with background_value. Default: False

  • background_value (float) – Intensity value to be potentially ignored. Default: 0.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • min_percentile (float) – Lower percentile in [0;1]. Default: 0.0

  • max_percentile (float) – Lower percentile in [0;1], Default: 1.0

  • clamp_values (bool) – Intensities are clipped to the new range. Default: False

  • ignore_zeros (bool) – Whether to ignore zeros when computing the percentiles. Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • min (float) – New minimum value of the image after normalization. Default: 0.0

  • max (float) – New maximum value of the image after normalization. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • num_channels (int) – Number of channels in the output. Must be equal or larger to the highest possible label value. Default: 0

  • encode_background (bool) – whether to encode background in first channel. Default: True

  • to_ubyte (bool) – return label as ubyte (=int8) instead of float. Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 2

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.PolyCropOperation

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

Parameters:
  • points (List[vec3]) – Each point (texture coordinates) in points defines a plane (perpendicular to the direction from the center to the point), this plane splits the volume in two parts, the part of the image that doesn’t contain the image center is discarded.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomAddDegradedLabelAsChannelOperation

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

Parameters:
  • blob_radius (float) – Radius of each blob, in pixel coordinates. Default: 5.0.

  • probability_no_blobs (float) – Probability that zero blobs are chosen. Default: 0.1

  • probability_invert (float) – Probability of inverting the blobs, in this case the extra channel is positive/negative based on the label except at blobs, where it is zero. Default: 0.0

  • mean_num_blobs (float) – Mean of (Poisson-distributed) number of blobs to draw, conditional on probability_no_blobs. Default: 100.0

  • only_positive (bool) – If true, output channel is clamped to zero from below. Default: False

  • label_dilation_range ([vec2]) – The label_dilation parameter of the underlying AddDegradedLabelAsChannelOperation is uniformly drawn from this range. Default: [0.0, 0.0]

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

  • dilation_range: 0 0

  • probability: 1.0

class imfusion.machinelearning.RandomAxisFlipOperation

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

Parameters:
  • axes (list) – List of strings from {‘x’,’y’,’z’} specifying the axes to flip. For 2D images, only ‘x’ and ‘y’ are valid. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

  • probability (float) – Float in [0;1] defining the probability for the operation to be executed. Default: 1.0

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomAxisRotationOperation

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

Parameters:
  • axes (list) – List of strings from {‘x’,’y’,’z’} specifying the axes to rotate around. For 2D images, only [‘z’] is valid. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

  • probability (float) – Float in [0;1] defining the probability for the operation to be executed. Default: 1.0

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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. Use configure() to set the list of operations.

Parameters:
  • operation_specs (list[Specs]) – List of operation Specs to configure the operations to be added.

  • operation_weights (list[float]) – Weights associated to the each operation during the sampling process. A higher relative weight given to an operation means that this operation will be sampled more often.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • margin (int) – Margin, in pixels. Default: 1

  • reorder (bool) – Whether label value in result should be mapped to 1. Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

  • probability: 1.0

class imfusion.machinelearning.RandomCropOperation

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

Parameters:
  • crop_range (vec3) – List of floats from [0;1] specifying the maximum percentage of the dimension to crop. Default: [0.0, 0.0, 0.0]

  • probability (float) – Float in [0;1] defining the probability for the operation to be executed. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomCutOutOperation

Apply a random cutout to the image.

Parameters:
  • cutout_size_lower (vec3) – List of doubles specifying the lower bound of the cutout region size for each dimension in mm. Default: [0, 0, 0]

  • cutout_size_upper (vec3) – List of doubles specifying the upper bound of the cutout region size for each dimension in mm. Default: [0, 0, 0]

  • cutout_value_range (vec2f) – List of floats specifying the minimum and maximum fill value for cutout regions. Default: [0, 0]

  • cutout_number_range (vec2i) – List of integers specifying the minimum and maximum number of cutout regions. Default: [0, 0]

  • cutout_size_units (ParamUnit) – Units of the cutout size. Default: ParamUnit::MM

  • probability (float) – Float in [0;1] defining the probability for the operation to be executed.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomDeformationOperation

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

Parameters:
  • num_subdivisions (vec3i) – list specifying the number of subdivisions for each dimension (the number of control points is subdivisions+1). Default: [1, 1, 1]

  • max_abs_displacement (float) – absolute value of the maximum possible displacement (mm). Default: 1

  • padding_mode (PaddingMode) – defines which type of padding is used. Default: PaddingMode::Zero

  • probability (float) – probability of applying this Operation. Default: 1.0

  • adjust_size (bool) – configures whether the resulting image should adjust its size to encompass the deformation. Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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].

Parameters:
  • random_range (float) – Range of the interval used to draw the gamma correction, typically in [0; 0.5]. Default: 0.2

  • probability (float) – Float in [0;1] defining the probability for the operation to be executed. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomInvertOperation

Invert the intensities of the image: Output = -Input.

Parameters:
  • probability (float) – Float in [0;1] defining the probability for the operation to be executed. Default: 0.5

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomKeypointJitterOperation

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

Parameters:
  • offset_std_dev (float) – standard deviation of the normal distribution used to sample the jitter in mm

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomLinearIntensityMappingOperation

Apply a random linear shift and scale to the image intensities. Output = randomScale * Input + randomBias, where randomScale is drawn uniformly in [1-random_range; 1+random_range] and randomBias is drawn uniformly in [-random_range*(max(Input)-min(Input)); random_range*(max(Input)-min(Input))].

Parameters:
  • random_range (float) – Perturbation amplitude, typically in [0.0; 1.0]. Default: 0.2

  • probability (float) – Float in [0;1] defining the probability for the operation to be executed. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • center_beta_dist_params (vec2) – Beta distribution parameters for sampling the relative center coordinate locations. Default: [0.0, 1.0]

  • field_amplitude_random_range (vec2) – Amplitude of the field. Default: [0.2, 0.5]

  • length_scale_mm_random_range (vec2) – Range of length scale of the distance kernel in mm. Default: [50.0, 400.0]

  • distance_scaling_random_range (vec2) – Range of relative scaling of scanner space coordinates for anisotropic fields. Default: [0.5, 1.0]

  • invert_probability (float) – Probability to invert the field (before normalization): field <- 2.0 - field. Default: 0.0

  • output_is_field – Produce field instead of corrupted image. Default: False

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

  • probability: 1.0

class imfusion.machinelearning.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.

Parameters:
  • number_range (vec2i) – Range of integers specifying the minimum and maximum number of cutting planes. Default: [5, 10]

  • min_radius (float) – The minimum distance a cutting plane must have from the center (image coordinates are normalized to [-1, 1]). Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

  • probability: 1.0

class imfusion.machinelearning.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.

Parameters:
  • max_spacing (vec3) – maximum spacing per dimension which the target spacing is randomly sampled from. Minimum sampling spacing is the maximum (over all frames of the image set) spacing per dimension of the input SharedImageSet. Default: [0.0, 0.0, 0.0]

  • probability (float) – probability of applying this Operation. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomRotationOperation

Rotate input images and label maps with random angles.

Parameters:
  • angles_range (vec3) – List of floats specifying the upper bound (in degrees) of the range from with the rotation angles will be drawn uniformly. Default: [0, 0, 0]

  • adjust_size (bool) – Increase image size to include the whole rotated image or keep current dimensions. Default: False

  • apply_now (bool) – Bake transformation right way (otherwise, just changes the matrix). Default: False

  • probability (float) – Float in [0;1] defining the probability for the operation to be executed. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomScalingOperation

Scale input images and label maps with random factors.

Parameters:
  • scales_range (vec3) – List of floats specifying the upper bound of the range from with the scaling factor will be drawn uniformly. Default: [0.5, 0.5, 0.5]

  • apply_now (bool) – Bake transformation right way (otherwise, just changes the matrix). Default: False

  • probability (float) – Float in [0;1] defining the probability for the operation to be executed. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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]. sigma ~ U(half_kernel_bounds[0], half_kernel_bounds[1]) image_output = image * Gaussian_kernel(sigma)

Parameters:
  • half_kernel_bounds (vec2) – Bounds for the half kernel size. The final kernel size is 2 times the sampled half kernel size plus one. Default: [1, 1]

  • kernel_size_in_mm (bool) – Interpret kernel size as mm. Otherwise uses pixels. Default: False

  • isotropic (bool) – Forces the randomly drawn kernel size to be isotropic. Default: True

  • probability (float) – Value in [0.0; 1.0] indicating the probability of this operation to be performed. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RandomTemplateInpaintingOperation

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

Parameters:
  • template_paths (str) – paths from which a template .imf file is randomly loaded.

  • rotation_range (vec3) – rotation of template in degrees per axis randomly sampled from [-rotation_range, rotation_range]. Default: [0, 0, 0]

  • translation_range (vec3) – translation of template in degrees per axis randomly sampled from [-translation_range, translation_range]. Default: [0, 0, 0]

  • template_mult_factor_range (float) – Multiply template intensities with a factor randomly sampled from this range. Default: [0.0, 0.0]

  • add_values_to_existing (bool) – Adding values to input image rather than replacing them. Default: False

  • probability (float) – Float in [0;1] defining the probability for the operation to be executed. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RemoveOperation

Removes a set of fields from a data item. Uses ‘apply_to’ from the base class to specify which fields to remove.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • apply_to: []

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RenameOperation

Renames a set of fields of a data item.

Parameters:
  • source (List[str]) – list of the elements to be replaced

  • target (List[str]) – list of names of the new elements (must match the size of source)

  • throw_error_on_missing_source (bool) – if source field is missing, then throw an error (otherwise warn about unexpected behavior and do nothing). Default: True

  • throw_error_on_existing_target (bool) – if target field already exists, then throw an error (otherwise warn about unexpected behavior and overwrite it). Default: True

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ReplaceLabelsValuesOperation

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

Parameters:
  • old_values (list) –

    List of integer values to be replaced. device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

    All values that are not in this list will remain unchanged.

  • new_values (list) – List of integer values to replace old_values. It must have the same size as old_values, since there should be a one-to-one mapping.

  • update_labelsdatacomponent (bool) – Replaces the old-values in the LabelsDataComponent with the mapped ones. Default: True

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 2

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ResampleDimsOperation

Resample the input to fixed target dimensions.

Parameters:
  • target_dims (vec3i) – Target dimensions in pixels as [Width, Height, Slices].

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ResampleOperation

Resample the input to a fixed target resolution.

Parameters:
  • resolution (vec3) – Target spacing in mm.

  • preserve_extent (bool) – Preserve the exact spatial extent of the image, adjusting the output spacing resolution accordingly (since the extent is not always a multiple of resolution). Default: True

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ResampleToInputOperation
Resample the input image with respect to the image in ReferenceImageDataComponent

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ResolutionReductionOperation

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

Parameters:
  • target_spacing (vec3) – spacing per dimension to which the image is resampled before it is resampled back

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.RotationOperation

Rotate input images and label maps with fixed angles.

Parameters:
  • angles (vec3) – Rotation angles in degrees. Default: [0, 0, 0]

  • adjust_size (bool) – Increase image size to include the whole rotated image or keep current dimensions. Default: False

  • apply_now (bool) – Bake transformation right way (otherwise, just changes the matrix). Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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/set_active_fields 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”

Parameters:
  • config_path (string) – path to the YAML configuration file of the pixelwise model

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ScalingOperation

Scale input images and label maps with fixed factors.

Parameters:
  • scales (vec3) – Scaling factor applied to each dimension. Default: [1, 1, 1]

  • apply_now (bool) – Bake transformation right way (otherwise, just changes the matrix). Default: True

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.SelectChannelsOperation

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

Parameters:
  • selected_channels (list) – List of channels to be selected in input. If empty, use all channels.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.SetLabelModalityOperation

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

Parameters:
  • label_names (list) – List of non-background label names. The label with index zero is assigned the name ‘Background’.

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 2

  • error_on_unexpected_behaviour: False

  • modality: 8

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

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.SetModalityOperation

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

Args:

modality (Data::Modality): Modality to set the input to. label_names (list): List of non-background label names. The label with index zero is assigned the name ‘Background’. Default: []

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.SigmoidOperation

Apply a sigmoid function on the input image. Output = 1.0/(1.0 + exp(- scale * Input))

Parameters:
  • scale (float) – Scale parameter within the sigmoid function. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.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.

Parameters:
  • half_kernel_size (vec3) – Half size of the convolution kernel in pixels or mm.

  • kernel_size_in_mm (bool) – Interpret kernel size as mm. Otherwise uses pixels. Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.SoftmaxOperation
Computes channel-wise softmax on input.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.SwapImageAndLabelsOperation
Swaps image and label map.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.SyncOperation
Synchronizes shared memory (CPU <-> OpenGL) of images.

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.TanhOperation

Apply a tanh function on the input image. Output = tanh(scale * Input)

Parameters:
  • scale (float) – Scale parameter within the tanh function. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.TemplateInpaintingOperation

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

Parameters:
  • template_path (str) – path to load template .imf file.

  • template_rotation (vec3) – rotation of template in degrees per axis. Default: [0, 0, 0]

  • template_translation (vec3) – translation of template in degrees per axis. Default: [0, 0, 0]

  • add_values_to_existing (bool) – Adding values to input image rather than replacing them. Default: False

  • template_mult_factor (float) – Multiply template intensities with this factor. Default: 1.0

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.ThresholdOperation

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

Parameters:
  • value (float) – Threshold value (strictly) above which the pixel will set to 1. Default: 0.0

  • to_ubyte (bool) – Output image must be unsigned byte instead of float. Default: False

  • device – Specifies whether this Operation should run on CPU or GPU.

  • apply_to – Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy)

  • seed – Specifies seeding for any randomness that might be contained in this operation.

  • error_on_unexpected_behaviour – Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 0

  • error_on_unexpected_behaviour: False

class imfusion.machinelearning.UnmarkAsTargetOperation

Unmark elements from the input data item as learning “target”. This operation is the opposite of MarkAsTargetOperation. Use the apply_to parameter from the Operation interface to define which fields should be unmarked.

Args:

apply_to (List[str]): fields to unmark as targets (will initialize the underlying apply_to parameter)

device: Specifies whether this Operation should run on CPU or GPU. apply_to: Specifies fields in a DataItem that this Operation should process (if empty, will select suitable fields based on the current processing_policy) seed: Specifies seeding for any randomness that might be contained in this operation. error_on_unexpected_behaviour: Specifies whether to throw an exception instead of warning about unexpected behaviour.

Other parameters accepted by configure():

  • device: GPUIfOpenGl

  • processing_policy: 1

  • error_on_unexpected_behaviour: False