# spacr.measure

## Module Contents

spacr.measure.get_components(cell_mask, nucleus_mask, pathogen_mask)

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

  Parameters:

    - cell_mask (ndarray) – Binary mask of cell labels.

    - nucleus_mask (ndarray) – Binary mask of nucleus labels.

    - pathogen_mask (ndarray) – Binary mask of pathogen labels.

  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.

  Return type:

    tuple

spacr.measure.save_and_add_image_to_grid(png_channels, img_path, grid, plot=False)

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

  Parameters:

    - png_channels (ndarray) – The array representing the image channels.

    - img_path (str) – The path to save the image as PNG.

    - grid (list) – The grid of images to be plotted later.

  Returns:

    Updated grid with the new image added.

  Return type:

    grid (list)

spacr.measure.img_list_to_grid(grid, titles=None)

  Plot a grid of images with optional titles.

  Parameters:

    - grid (list) – List of images to be plotted.

    - titles (list) – List of titles for the images.

  Returns:

    The matplotlib figure object containing the image grid.

  Return type:

    fig (Figure)

spacr.measure.measure_crop(settings)

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

  Parameters:

    settings (dict) – The settings for measuring the crop.

  Returns:

    None

spacr.measure.process_meassure_crop_results(partial_results, settings)

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

  Parameters:

    - partial_results (list) – List of partial results.

    - settings (dict) – Settings dictionary.

    - save_figures (bool) – Flag to save figures or not.

spacr.measure.generate_cellpose_train_set(folders, dst, min_objects=5)

spacr.measure.get_object_counts(src)