Postprocessing


Script for applying postprocessing methods to inferred predictions using a the convex hull method as well as morphological operations.

Usage:

postprocess_rhizonet –config_file ./setup_files/setup-processing.json

getLargestCC(segments: numpy.ndarray) numpy.ndarray

Find the largest connected component within a 2D image

Parameters

segments (np.ndarray) – A 2D binary or multi-class array (NumPy array) where labeled regions are to be identified. - Binary image: Where non-zero values represent objects (foreground), and zero values represent the background. - Multi-class image: Where different integer values represent distinct classes.

Returns

A 2D mask corresponding to the largest object.

Return type

np.ndarray

main()
maxProjection(limg: List[numpy.ndarray], ndown: int = 1) numpy.ndarray

Apply maximum projection to a list of 2D slices. The images in the list limg are downsampled by ndown before the maximum intensity projection is computed

Parameters
  • limg (List[np.ndarray]) – list of 2D images.

  • ndown (int, optional) – integer parameter that controls the downsampling factor for the 2D images along dimensions x and y when performing the maximum projection. Defaults to 1 so no downsampling.

Returns

2D projected image.

Return type

np.ndarray

processing(data_path: str, output_path: str, area_opening_param: int = 500, area_closing_param: int = 200, disk_radius: int = 4)

Perform post-processing on predictions for noise removal, using the convex hull method and morphological operations.

Parameters
  • data_path (str) – Data directory

  • output_path (str) – Directory where processed predictions will be saved

  • area_opening_param (int, optional) – minimum area of objects to retain when (eroding, dilating). Defaults to 500.

  • area_closing_param (int, optional) – minimum area of objects to fill when (dilating, eroding). Defaults to 200.

  • disk_radius (int, optional) – radius of the disk object to use when applying morphological operations. Defaults to 4.

Returns: None