spacr.measure
=============

.. py:module:: spacr.measure




Module Contents
---------------

.. py:function:: get_components(cell_mask, nucleus_mask, pathogen_mask)

   Get the components (nucleus and pathogens) for each cell in the given masks.

   :param cell_mask: Binary mask of cell labels.
   :type cell_mask: ndarray
   :param nucleus_mask: Binary mask of nucleus labels.
   :type nucleus_mask: ndarray
   :param pathogen_mask: Binary mask of pathogen labels.
   :type pathogen_mask: ndarray

   :returns:

             A tuple containing two dataframes - nucleus_df and pathogen_df.
                 nucleus_df (DataFrame): Dataframe with columns 'cell_id' and 'nucleus',
                     representing the mapping of each cell to its nucleus.
                 pathogen_df (DataFrame): Dataframe with columns 'cell_id' and 'pathogen',
                     representing the mapping of each cell to its pathogens.
   :rtype: tuple


.. py:function:: save_and_add_image_to_grid(png_channels, img_path, grid, plot=False)

   Add an image to a grid and save it as PNG.

   :param png_channels: The array representing the image channels.
   :type png_channels: ndarray
   :param img_path: The path to save the image as PNG.
   :type img_path: str
   :param grid: The grid of images to be plotted later.
   :type grid: list

   :returns: Updated grid with the new image added.
   :rtype: grid (list)


.. py:function:: img_list_to_grid(grid, titles=None)

   Plot a grid of images with optional titles.

   :param grid: List of images to be plotted.
   :type grid: list
   :param titles: List of titles for the images.
   :type titles: list

   :returns: The matplotlib figure object containing the image grid.
   :rtype: fig (Figure)


.. py:function:: measure_crop(settings)

   Measure the crop of an image based on the provided settings.

   :param settings: The settings for measuring the crop.
   :type settings: dict

   :returns: None


.. py:function:: process_meassure_crop_results(partial_results, settings)

   Process the results, display, and optionally save the figures.

   :param partial_results: List of partial results.
   :type partial_results: list
   :param settings: Settings dictionary.
   :type settings: dict
   :param save_figures: Flag to save figures or not.
   :type save_figures: bool


.. py:function:: generate_cellpose_train_set(folders, dst, min_objects=5)

.. py:function:: get_object_counts(src)

