neuro_morpho.model.simple_baseline

A simple baseline model for testing.

Classes

SimpleBaseLine

A simple baseline model for image segmentation.

Functions

make_binary(→ numpy.ndarray)

Binarize an image based on a percentile threshold.

Module Contents

neuro_morpho.model.simple_baseline.make_binary(x: numpy.ndarray, percentile: int) numpy.ndarray[source]

Binarize an image based on a percentile threshold.

This function thresholds the input image x at the given percentile and then skeletonizes the result.

Parameters:
  • x (np.ndarray) – The input image. Should be of shape (n_samples, width, height).

  • percentile (int) – The percentile to use as the threshold.

Returns:

The binarized and skeletonized image.

Return type:

np.ndarray

class neuro_morpho.model.simple_baseline.SimpleBaseLine(percentile: int = 95, name: str | None = None)[source]

Bases: neuro_morpho.model.base.BaseModel

A simple baseline model for image segmentation.

This model binarizes the input image based on a percentile threshold and then skeletonizes the result.

percentile = 95
name = 'simple_base_line'
fit(training_x_dir: pathlib.Path | str, training_y_dir: pathlib.Path | str, testing_x_dir: pathlib.Path | str, testing_y_dir: pathlib.Path | str) SimpleBaseLine[source]

This model does not require fitting, so this method just returns self.

predict(x: numpy.ndarray) numpy.ndarray[source]

Predict the segmentation for the input image.

predict_dir(in_dir: str | pathlib.Path, out_dir: str | pathlib.Path, tile_size: int = 512, tile_assembly: str = 'mean') None[source]

Predict the segmentation for all images in a directory.

save(path: pathlib.Path | str) None[source]

Save the model’s percentile threshold to a file.

load(path: pathlib.Path | str) None[source]

Load the model’s percentile threshold from a file.