This Napari plugin streamlines the process of segmenting, analyzing, and counting cells in 3D datasets. Designed with researchers in mind, it provides an intuitive interface to handle bioimaging data, offering seamless integration with the Jaworski Lab datasets and their acquisition hardware.
- Load BioFormat Files: Easily load .oir files created by lab acquisition hardware (e.g., Imaris), ensuring compatibility and a smooth workflow for researchers.
- Preprocess Data: Adjust contrast and apply a Gaussian filter to enhance the dataset, followed by thresholding to create binary masks. This step improves the segmentation and labeling of cells for subsequent analysis.
- Count Cells in Dataset: Count the number of cells present by combining the enhanced dataset with binary maps. The plugin enables users to focus on regions of interest and generate accurate cell counts.
- Install napari
pip install "napari[all]"
- Install napari cell-seg3d
pip install napari-cellseg3d
- Install this plugin
pip install git+https://github.com/brown-ccv/[email protected]
- (Optional) Install PyTorch and CUDA . Refer to the PyTorch website for instructions on installing the appropriate version that matches the CUDA version in your environment.
-
Run napari from your python environment
-
Select the Plugins > Jaworski lab cell seg option from the top menu bar
-
After a few seconds the widgets will be added at the right side of the napari window
-
Load your data and follow the series of steps illustrated in the diagram below to segment, label, and count cells. See below for detailed instructions for each step.
The top tool includes a button to open a file selection window. Click on "Select File," choose the .oir dataset, and then click the "Open BioImage" button to load the data.
You may pre-process the image with a Gaussian filter and contrast adjustments. Default values are set to optimal values for the Jaworski lab datasets. Once values are to your preference, click "Pre-process BioImage" and additional layers will be added to the visualizer.
This process creates 2 additional layers (Keep track of these):
- Pre-processed Data: An enhanced version of the dataset that sharpens cell borders and brightens the interior of blobs to help identify multiple cells within a single blob.
- Cloud Binary: A binary image representing the region of interest with the highest probability of containing cells.
The napari-CellSeg3D plugin is used for segmentation and is automatically loaded. Please refer to their documentation for guidance on usage and achieving optimal segmentation results. By default, this plugin loads the best values for the Jaworski Lab datasets. Click the "Start" button and wait for the process to complete. It may take a long time to finish if you are not using a GPU with CUDA support.
Keep track of the segmentation result layer, as it highlights all the potential spots in the image that may contain a cell. This is the layer you will use during the "Label and Count" step.
It's possible to count cells in sub regions of the dataset. In order to do so, add a shape layer with the following steps:
-
In the top-left corner of the Napari viewer, click the “Add Shapes” button (a rectangle icon in the layer controls).
-
Look for the mode buttons in the top-left corner (below the menu bar). Choose the shape type (e.g., rectangle, ellipse, polygon, or line).
-
Click and drag on the canvas to draw your desired shape.
To select regions defined by the shapes, navigate to the "Select Region" tool in the plugin. The first dropdown menu lists the available shape layers, while the second dropdown menu displays the cloud binary images. This process uses the shape layer to isolate and subtract specific regions from the binary image.
Start by selecting the shape layer containing the subregions you want to analyze and the binary image created during the "Preprocess Dataset" step. Then, click the "Select Region" button. A new layer will be generated, representing the result of the operation.
This new subregion layer is a binary image that will appear during the "Label and Count" step and can be used to identify cells within those regions.
The final step of the pipeline multiplies the layer of potential cells (see the "Preprocess Data" step) by the binary map that highlights regions likely containing cells. This can be accomplished using the "Label and Count" tool.
The first dropdown lists layers containing all potential spots, while the second dropdown displays all available binary images, including subregion binary images. If you'd like to save the results in CSV format, click "Select File" to specify and confirm the file name and path. Finally, press the "Label and Count" button to complete the process. A new layer with the final results will be added to the viewer.
The "Label and Count" section will display the number of cells in the dataset.
We use astral-sh/uv to run and build this project. This tool handles virtual environment creation and dependency installation seamlessly. For detailed setup and installation instructions, please refer to their official documentation.
- Python >= 3.9
- Napari
- Napari cell-seg3d
- PyTorch and CUDA for rapid segmentation. Refer to the PyTorch website on how to install it with CUDA support
Once uv
is installed on your system, clone this repository and run the following command to install the plugin:
uv install
This command will download and install all required dependencies
To start working with the plugin use the command:
uv run napari