MaskResampler#

class zrad.preprocessing.interpolation.MaskResampler(resolution, method='nearest_neighbor', partial_volume_threshold=0.5)[source]#

Resample a mask or RoiData.morphological_mask onto a target voxel grid.

Mask resampling aligns ROI geometry with the analysis grid. The interpolated mask is thresholded back to a binary image, which supports partial-volume handling when non-nearest interpolation is used.

Parameters:
  • resolution (float or sequence of float) – Target voxel spacing in millimetres. A single positive value is applied to all three axes. A sequence must contain three positive values in (x, y, z) order.

  • method (str, optional) – Interpolation method used before thresholding the mask. Supported values are "nearest_neighbor", "linear", "bspline", and "gaussian" including common aliases. The default is "nearest_neighbor".

  • partial_volume_threshold (float, optional) – Threshold applied after interpolation. Voxels greater than or equal to this value are assigned to the ROI; all other voxels are set to zero. If None is supplied, 0.5 is used.

Methods

apply(data)

Return a resampled mask or ROI data with a resampled morphological mask.

get_params()

Return mask-resampling parameters mapped to their configured values.

MaskResampler.apply(data)[source]#

Return a resampled mask or ROI data with a resampled morphological mask.

Parameters:

data (Image or RoiData) – Mask image to resample. If RoiData is supplied, morphological_mask is resampled and intensity-derived fields are cleared.

Returns:

resampled – Binary resampled mask, or ROI data with a resampled morphological_mask.

Return type:

Image or RoiData

MaskResampler.get_params()[source]#

Return mask-resampling parameters mapped to their configured values.

Returns:

params – Dictionary containing resolution, method, and partial_volume_threshold.

Return type:

dict