monai.transforms.utility.array#

A collection of “vanilla” transforms for utility functions.

Classes

AddCoordinateChannels(spatial_dims)

Appends additional channels encoding coordinates of the input.

AddExtremePointsChannel([background, pert])

Add extreme points of label to the image as a new channel.

ApplyTransformToPoints([dtype, affine, ...])

Transform points between image coordinates and world coordinates.

AsChannelLast([channel_dim])

Change the channel dimension of the image to the last dimension.

CastToType([dtype])

Cast the Numpy data to specified numpy data type, or cast the PyTorch Tensor to specified PyTorch data type.

ClassesToIndices([num_classes, ...])

ConvertToMultiChannelBasedOnBratsClasses()

Convert labels to multi channels based on brats18 classes, which include TC (Tumor core), WT (Whole tumor) and ET (Enhancing tumor): label 1 is the necrotic and non-enhancing tumor core, which should be counted under TC and WT subregion, label 2 is the peritumoral edema, which is counted only under WT subregion, label 4 is the GD-enhancing tumor, which should be counted under ET, TC, WT subregions.

CuCIM(name, *args, **kwargs)

Wrap a non-randomized cuCIM transform, defined based on the transform name and args.

DataStats([prefix, data_type, data_shape, ...])

Utility transform to show the statistics of data for debug or analysis.

EnsureChannelFirst([strict_check, channel_dim])

Adjust or add the channel dimension of input data to ensure channel_first shape.

EnsureType([data_type, dtype, device, ...])

Ensure the input data to be a PyTorch Tensor or numpy array, support: numpy array, PyTorch Tensor, float, int, bool, string and object keep the original.

FgBgToIndices([image_threshold, output_shape])

Compute foreground and background of the input label data, return the indices.

Identity()

Do nothing to the data.

ImageFilter(filter[, filter_size])

Applies a convolution filter to the input image.

IntensityStats(ops, key_prefix[, channel_wise])

Compute statistics for the intensity values of input image and store into the metadata dictionary.

LabelToMask(select_labels[, merge_channels])

Convert labels to mask for other tasks.

Lambda([func, inv_func, track_meta])

Apply a user-defined lambda as a transform.

MapLabelValue(orig_labels, target_labels[, ...])

Utility to map label values to another set of values.

RandCuCIM(name, *args, **kwargs)

Wrap a randomized cuCIM transform, defined based on the transform name and args For deterministic non-randomized transforms use monai.transforms.CuCIM.

RandIdentity()

Do nothing to the data.

RandImageFilter(filter[, filter_size, prob])

Randomly apply a convolutional filter to the input data.

RandLambda([func, prob, inv_func, track_meta])

Randomizable version monai.transforms.Lambda, the input func may contain random logic, or randomly execute the function based on prob.

RandTorchIO(name, *args, **kwargs)

This is a wrapper for TorchIO randomized transforms based on the specified transform name and args.

RandTorchVision(name, *args, **kwargs)

This is a wrapper transform for PyTorch TorchVision randomized transform based on the specified transform name and args.

RemoveRepeatedChannel(repeats)

RemoveRepeatedChannel data to undo RepeatChannel The repeats count specifies the deletion of the origin data, for example: RemoveRepeatedChannel(repeats=2)([[1, 2], [1, 2], [3, 4], [3, 4]]) generates: [[1, 2], [3, 4]]

RepeatChannel(repeats)

Repeat channel data to construct expected input shape for models.

SimulateDelay([delay_time])

This is a pass through transform to be used for testing purposes.

SplitDim([dim, keepdim, update_meta])

Given an image of size X along a certain dimension, return a list of length X containing images.

SqueezeDim([dim, update_meta])

Squeeze a unitary dimension.

ToCupy([dtype, wrap_sequence])

Converts the input data to CuPy array, can support list or tuple of numbers, NumPy and PyTorch Tensor.

ToDevice(device, **kwargs)

Move PyTorch Tensor to the specified device.

ToNumpy([dtype, wrap_sequence])

Converts the input data to numpy array, can support list or tuple of numbers and PyTorch Tensor.

ToPIL()

Converts the input image (in the form of NumPy array or PyTorch Tensor) to PIL image

ToTensor([dtype, device, wrap_sequence, ...])

Converts the input image to a tensor without applying any other transformations.

TorchIO(name, *args, **kwargs)

This is a wrapper for TorchIO non-randomized transforms based on the specified transform name and args.

TorchVision(name, *args, **kwargs)

This is a wrapper transform for PyTorch TorchVision non-randomized transform based on the specified transform name and args.

Transpose(indices)

Transposes the input image based on the given indices dimension ordering.