List of Samplers

Table of contents

CenterROISampler

Sampler which samples one ROI from the input image and label map with a target size. The ROI is centered on the image center. The arrays will be padded if the target size is larger than the input image.

DefaultROISampler

Sampler which simply returns the image and the label map, after padding of a specified dimension divisor: each spatial dimension of the output arrays will be divisible by dimension_divisor.

LabelROISampler

Sampler which samples ROIs from the input image and label map, such that one particular label appears. For each ROI, one of the labels_values will be selected and the sampler will make sure that the ROI includes this label. If the sample_boundaries_only flag is set to true, regions will at least have two different label values. If the constraints are not feasible, the sampler will either extract a random ROI with the target size or return an empty image, based on the flag fallback_to_random. (The actual purpose of returning an empty image is to actually chain this sampler with a FilterDataLoader, so that images without a valid label are just completely skipped).

OrientedROISampler

The OrientedROISampler draws num_samples ROIs of size roi_size with spacing roi_spacing per dataset. sample_from_labels_proportion controls the expected fraction of ROI centers drawn from the target instead of uniformly from the full image; the actual number of target-guided samples is binomially distributed around that proportion. Label maps and Keypoints are supported for target-guided sampling. For targets with LABEL, ROI centers are drawn with class-agnostic foreground sampling by default: every non-zero voxel has equal probability regardless of label value, so larger structures dominate the draw. Setting equalize_label_classes to True switches to class-balanced sampling: a present label value is first picked uniformly at random and then a voxel of that class is picked uniformly at random, so small and large structures are centered with equal probability. For target images of any other modality, target values act as relative heatmap weights: zero-valued voxels are never selected, larger values are sampled more often, values do not need to sum to 1, and negative values are not supported. For Keypoint targets, a random keypoint is selected as the ROI center. If no valid target voxels are present, target-guided slots fall back to uniform random sampling. Random augmentations can applied, including rotation, flipping, shearing, scaling and jitter. These augmentations are directly changing the matrix of the sample, thus the samples are not guaranteed to be affine or even in a right-handed coordinate system. The samples retain their matrices, so they can be viewed in their original position. May throw an ImageSamplerError

RandomROISampler

Sampler which randomly samples ROIs from the input image and label map with a target The images will be padded if the target size is larger than the input image.

SplitROISampler

Sampler which splits the input image into overlapping ROIs for sliding window inference.

This sampler mimics the situation at test-time, when one image needs to be processed in regularly spaced patches. The step size is used to compute valid ROI positions that cover the full input image. The sampling behavior is controlled by the patch_step_size parameter, which is used to compute the ROIs offsets in the input image as a fraction of the specified ROI size.