nabu.preproc.ccd module

class nabu.preproc.ccd.CCDFilter(radios_shape: tuple, correction_type: str = 'median_clip', median_clip_thresh: float = 0.1, abs_diff=False, preserve_borders=False)[source]

Bases: object

Filtering applied on radios.

Initialize a CCDCorrection instance.

Parameters:
  • radios_shape (tuple) – A tuple describing the shape of the radios stack, in the form (n_radios, n_z, n_x).

  • correction_type (str) – Correction type for radios (“median_clip”, “sigma_clip”, …)

  • median_clip_thresh (float, optional) – Threshold for the median clipping method.

  • abs_diff (boolean) – by default False: the correction is triggered when img - median > threshold. If equals True: correction is triggered for abs(img-media) > threshold

  • borders (preserve) – by default False: If equals True: the borders (width=1) are not modified.

Notes

A CCD correction is a process (usually filtering) taking place in the radios space. Available filters:

  • median_clip: if the value of the current pixel exceeds the median of adjacent pixels (a 3x3 neighborhood) more than a threshold, then this pixel value is set to the median value.

static median_filter(img)[source]

Perform a median filtering on an image.

median_clip_mask(img, return_medians=False)[source]

Compute a mask indicating whether a pixel is valid or not, according to the median-clip method.

Parameters:
  • img (numpy.ndarray) – Input image

  • return_medians (bool, optional) – Whether to return the median values additionally to the mask.

median_clip_correction(radio, output=None)[source]

Compute the median clip correction on one image.

Parameters:
  • radios (numpy.ndarray, optional) – A radio image.

  • output (numpy.ndarray, optional) – Output array

class nabu.preproc.ccd.Log(radios_shape, clip_min=None, clip_max=None)[source]

Bases: object

Helper class to take -log(radios)

Parameters:
  • clip_min (float, optional) – Before taking the logarithm, the values are clipped to this minimum.

  • clip_max (float, optional) – Before taking the logarithm, the values are clipped to this maximum.

take_logarithm(radios)[source]

Take the negative logarithm of a radios chunk. Processing is done in-place !

Parameters:

radios (array) – Radios chunk.