CropPad#

vision_architectures.transforms.croppad.get_updated_crop_start(current_crop_start, new_crop_start)[source]#
class vision_architectures.transforms.croppad.CropForegroundWithCropTrackingd(crop_offset_key='crop_offset', *args, **kwargs)[source]#

Bases: CropForegroundd

__init__(crop_offset_key='crop_offset', *args, **kwargs)[source]#
Parameters:
  • keys – keys of the corresponding items to be transformed. See also: monai.transforms.compose.MapTransform

  • source_key – data source to generate the bounding box of foreground, can be image or label, etc.

  • select_fn – function to select expected foreground, default is to select values > 0.

  • channel_indices – if defined, select foreground only on the specified channels of image. if None, select foreground on the whole image.

  • margin – add margin value to spatial dims of the bounding box, if only 1 value provided, use it for all dims.

  • allow_smaller – when computing box size with margin, whether to allow the image edges to be smaller than the final box edges. If False, part of a padded output box might be outside of the original image, if True, the image edges will be used as the box edges. Default to True.

  • k_divisible – make each spatial dimension to be divisible by k, default to 1. if k_divisible is an int, the same k be applied to all the input spatial dimensions.

  • mode – available modes for numpy array:{"constant", "edge", "linear_ramp", "maximum", "mean", "median", "minimum", "reflect", "symmetric", "wrap", "empty"} available modes for PyTorch Tensor: {"constant", "reflect", "replicate", "circular"}. One of the listed string values or a user supplied function. Defaults to "constant". See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html it also can be a sequence of string, each element corresponds to a key in keys.

  • start_coord_key – key to record the start coordinate of spatial bounding box for foreground.

  • end_coord_key – key to record the end coordinate of spatial bounding box for foreground.

  • allow_missing_keys – don’t raise exception if key is missing.

  • lazy – a flag to indicate whether this transform should execute lazily or not. Defaults to False.

  • pad_kwargs – other arguments for the np.pad or torch.pad function. note that np.pad treats channel dimension as the first dimension.

class vision_architectures.transforms.croppad.RandSpatialCropSamplesWithCropTracking(crop_offset_key='crop_offset', *args, **kwargs)[source]#

Bases: RandSpatialCropSamples

__init__(crop_offset_key='crop_offset', *args, **kwargs)[source]#
__call__(img, lazy=None)[source]#

Apply the transform to img, assuming img is channel-first and cropping doesn’t change the channel dim.

Return type:

list[Tensor]

class vision_architectures.transforms.croppad.RandSpatialCropSamplesWithCropTrackingd(keys, roi_size, num_samples, max_roi_size=None, random_center=True, random_size=False, allow_missing_keys=False, lazy=False, crop_offset_key='crop_offset')[source]#

Bases: RandSpatialCropSamplesd

__init__(keys, roi_size, num_samples, max_roi_size=None, random_center=True, random_size=False, allow_missing_keys=False, lazy=False, crop_offset_key='crop_offset')[source]#