neuro_morpho.model.breaks_analyzer

Analyzes and patches breaks in predicted binary images.

Attributes

MAX_FIXABLE_DISTANCE

Classes

BreaksAnalyzer

Analyzes and patches breaks in predicted binary images.

Module Contents

neuro_morpho.model.breaks_analyzer.MAX_FIXABLE_DISTANCE = 6
class neuro_morpho.model.breaks_analyzer.BreaksAnalyzer[source]

Analyzes and patches breaks in predicted binary images.

This class provides methods to identify and fix breaks in the dendrite segmentation of the predicted binary images.

masked_max(image: numpy.ndarray, point: tuple[int, int], kernel: numpy.ndarray) tuple[int, int][source]

Find the maximum value and its coordinate in a masked region of an image.

Parameters:
  • image (np.ndarray) – The input image.

  • point (tuple[int, int]) – The center of the mask.

  • kernel (np.ndarray) – The mask to apply.

Returns:

The coordinate of the maximum value.

Return type:

tuple[int, int]

create_connecting_line(line_mask: numpy.ndarray, pt1: tuple[int, int], pt2: tuple[int, int], pred_bin_img: numpy.ndarray, pred_img: numpy.ndarray) bool[source]

Draw a line on the mask connecting two points.

The line is drawn with respect to the predicted image, following the path of highest probability.

Parameters:
  • line_mask (np.ndarray) – The mask to draw the line on.

  • pt1 (tuple[int, int]) – The starting point of the line.

  • pt2 (tuple[int, int]) – The ending point of the line.

  • pred_bin_img (np.ndarray) – The binary prediction image.

  • pred_img (np.ndarray) – The probability map prediction image.

Returns:

True if the line was successfully connected, False otherwise.

Return type:

bool

analyze_breaks(pred_bin_img: numpy.ndarray, pred_img: numpy.ndarray) numpy.ndarray[source]

Find and patch potential breaks in the predicted binary image.

Parameters:
  • pred_bin_img (np.ndarray) – The binary prediction image.

  • pred_img (np.ndarray) – The probability map prediction image.

Returns:

The patched binary image.

Return type:

np.ndarray