neuro_morpho.model.base ======================= .. py:module:: neuro_morpho.model.base .. autoapi-nested-parse:: Base class for all models. Attributes ---------- .. autoapisummary:: neuro_morpho.model.base.ERR_NOT_IMPLEMENTED Classes ------- .. autoapisummary:: neuro_morpho.model.base.BaseModel Module Contents --------------- .. py:data:: ERR_NOT_IMPLEMENTED :value: 'The {name} method is not implemented' .. py:class:: BaseModel Base class for all models. This class defines the interface for all models. All models should inherit from this class and implement the methods defined here. .. py:method:: fit(data_dir: str | pathlib.Path) -> BaseModel :abstractmethod: Fit the model to the data. :param data_dir: The directory containing the data files to fit the model images should have the size (n_samples, channels, height, width) :type data_dir: str|Path :returns: The fitted model :rtype: BaseModel .. py:method:: predict_dir(in_dir: str | pathlib.Path, out_dir: str | pathlib.Path, threshold: float, mode: str, tile_size: tuple[int, int], tile_assembly: str, binarize: bool, fix_breaks: bool) -> None :abstractmethod: Predict the output for all images in the given directory. :param in_dir: The directory containing the data files to predict images should have the size (n_samples, channels, height, width) :type in_dir: str|Path :param out_dir: The directory to save the output :type out_dir: str|Path :param threshold: Use to get the hard prediction (binary output) :type threshold: float :param mode: The mode of the prediction, can be 'test' or 'infer' 'test' - runs the model on the test set (same size images) and saves the statistics 'infer' - runs the model on the inference set (images may be of different size) and saves the output :type mode: str :param tile_size: The size of the tiles to use for tiling the input images :type tile_size: tuple[int, int] :param tile_assembly: The method for assembling the tiles, can be 'nn' (nearest neighbor), 'mean', or 'max' :type tile_assembly: str :param binarize: Whether to binarize the output :type binarize: bool :param fix_breaks: Whether to fix breaks in the binarized output :type fix_breaks: bool .. py:method:: predict(x: numpy.ndarray) -> numpy.ndarray :abstractmethod: Predict the output given the input x :param x: The input data should be size of (n_samples, channels, height, width) :type x: np.ndarray :param thresh: The threshold to use for the prediction :type thresh: float :returns: The predicted output :rtype: np.ndarray .. py:method:: predict_proba(x: numpy.ndarray, tiler: neuro_morpho.model.tiler.Tiler) -> numpy.ndarray :abstractmethod: Predict a soft version of the output given the input x and tiling params as an option :param x: The input data should be size of (n_samples, channels, height, width) :type x: np.ndarray :param tiler: The tiler object to use for tiling the input data :type tiler: Tiler :returns: The predicted output :rtype: np.ndarray .. py:method:: find_threshold(in_dir: str | pathlib.Path, out_dir: str | pathlib.Path, model_dir: str | pathlib.Path, model_out_val_y_dir: str | pathlib.Path, min_thresh: float, max_thresh: float, thresh_step: float) -> float :abstractmethod: Predict the output for all images in the given directory. :param in_dir: The directory containing images (validation set) :type in_dir: str|Path :param out_dir: The directory containing labels (validation set) :type out_dir: str|Path :param model_dir: The directory containing model checkpoints :type model_dir: str|Path .. py:method:: save(path: pathlib.Path | str) -> None :abstractmethod: Save the model to the given path. :param path: The path to save the model :type path: Path|str .. py:method:: load(path: pathlib.Path | str) -> None :abstractmethod: Load the model from the given path. :param path: The path to load the model :type path: Path|str