> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mantlebio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cellular segmentation from fluorescence microscopy images using Cellpose on Mantle

## Introduction

Fluorescence microscopy experiments enable researchers to visualize specific biological macromolecules in tissues or cell cultures, using probes, antibody staining, or fluorescent protein conjugation, to visualize proteins of interest. These samples are imaged in multiple channels to capture each fluorophore separately. Using image analysis techniques, the molecules of interest can be quantified to study disease mechanisms and infer biological pathways. The first step in per-cell quantification is to perform cellular segmentation to determine which pixels in a microscopy image belong to a single cell.

`cellpose` is a set of segmentation network models for [anatomical segmentation of cells in microscopy images](https://www.cellpose.org/). We have written the Mantle `cellpose-segmentation` pipeline to read image directories from your Mantle Database, perform segmentation using `cellpose`, and write the resulting masks to your Mantle Database.

## Managing image data

In your [Mantle Database](/features/database), data is stored as entities, which have properties that can be files or metadata. Sets of microscopy images can be stored in Mantle as entities of the `image_directory` data type. Expand to view the properties of `image_directory` entities:

<Accordion title="Properties">
  <ParamField query="image_directory" type="file" required>
    Directory of images in TIFF, PNG, or JPEG format
  </ParamField>

  <ParamField query="experiment_name" type="string">
    An identifier for the experiment that the images were collected in
  </ParamField>
</Accordion>

For demonstration purposes, your Mantle Database comes with images from the BBBC014v1 dataset from the Broad Bioimage Benchmark Collection:

> Ljosa, V., Sokolnicki, K. L., & Carpenter, A. E. (2012). Annotated high-throughput microscopy image sets for validation. Nature Methods, 9(7), 637-637.

These images are taken from human MCF7 (human breast adenocarcinoma) and A549 (human alveolar basal epithelial) cell lines that are stained for 1) DNA and 2) NFκB. The cells are plated on a 96-well plate and each well was treated with one of 12 concentration points of TNFα. Higher concentrations of TNFα should induce cytoplasm to nucleus translocation of NFκB. 2-channel images were acquired from this experiment (channel 1: DNA, channel 2: NFκB).

## Producing cytoplasm and nuclei masks from images

The Mantle `cellpose-segmentation` pipeline adapts the [Cellpose CLI](https://cellpose.readthedocs.io/en/latest/cli.html#cellpose-cli) to allow it to take `image_directory` entities as inputs and to structure the output directory of masks into a `segmentation_mask_directory` entity.

Expand to view the parameters for the `cellpose-segmentation` pipeline:

<Accordion title="Input parameters">
  <ParamField query="cellpose_model" type="string" required>
    Name of the pre-trained Cellpose model (e.g. "nuclei", "cyto3").

    See the [Cellpose documentation](https://cellpose.readthedocs.io/en/latest/models.html) for more information.
  </ParamField>

  <ParamField query="nuclei_channel" type="string" required>
    Value for the channel with a nuclei marker.

    0 = None, 1 = red, 2 = green, 3 = blue
  </ParamField>

  <ParamField query="cytoplasm_channel" type="string" required>
    Value for the channel with a cytoplasm marker.

    For nuclei segmentation, this can be the same as “nuclei\_channel” to load a single-channel grayscale image of just the nuclei channel.

    0 = grayscale, 1 = red, 2 = green, 3 = blue
  </ParamField>

  <ParamField query="diameter" type="string" required>
    Expected pixel diameter of the objects being segmented.

    `None` can be used for automatic estimation of the object diameter by Cellpose.
  </ParamField>
</Accordion>
