Advertisement

Annotating Images in Cellpose

Posted by , on 5 June 2025

In this blog post, I’ll show you how to manually annotate cells in 2D and 3D images using the Cellpose Graphical User Interface (GUI). Manual annotation is a key step in many bioimage analysis workflows. It allows you to create labeled data that can serve as a reference for evaluating segmentation quality – or even for fine-tuning a model to perform better on your specific dataset (a blog post on that is in the making 😉).

Whether you’re a life scientist, a developer, or just getting started with Cellpose, this guide will walk you through the basics of creating and editing manual labels using the GUI.

Cellpose Installation. If you don’t already have Cellpose installed and would like to annotate data yourself, please follow the official installation instructions. During step 5, make sure to choose Option 1.

2D Image

Let’s start with the simpler case of annotating a 2D image.

Once Cellpose is installed, you can open the GUI from the terminal using the following command.

python -m cellpose

Now, navigate through the menu to open an image: “File” → “Load image (*.tif, *.png, *.jpg)”. Alternatively, you can also drag and drop your image into the GUI.

To start drawing a mask, use “right-click”. Then, hover your mouse to outline the area you would like to segment (you don’t need to press anything). Once you’ve selected the desired area, return to the starting point or use “right-click” to end drawing the mask. Repeat this process for each mask you’d like to create.

If you make a mistake, you can select the incorrect mask with “left-click” and delete it via the menu: “Edit” → “Remove selected cell”. Alternatively, hold “CTRL” on your keyboard and use “left-click” on the mask to delete it.

Important: Overlapping masks are not allowed. If you draw a mask on top of an existing one, Cellpose will automatically crop the new mask to prevent overlap.

Want to see it in action? Check out the video below!

The 2D-GUI automatically saves any changes you make to a _seg.npy mask file.

⚠️ Note: If you want to modify an existing annotation, I recommend saving a copy of the original mask file before making any changes. Otherwise, Cellpose will override it.

3D Image

Now we’re ready to do the same in 3D. The steps are fairly similar, except for some minor differences.

First, in order to let the GUI know that we want to work in 3D mode, we need to add the --Zstack parameter to our command:

python -m cellpose --Zstack

Opening an image works the same way as in 2D.

Important: Before drawing masks in 3D, make sure to uncheck the single_stroke option.

You can now start drawing a mask using “right-click” and hovering over the desired area. Keep in mind that this will only select what is visible in the current Z-plane (basically like in 2D). To annotate more of the same cell in a different Z-plane, use the slide-bar at the bottom of the GUI to navigate through the Z-dimension and outline additional areas as before. Once you’re happy with your selection, press “ENTER” on your keyboard. This will tell Cellpose that all of the selected areas belong to the same object (in our case, one cell). Cellpose will merge them into a single mask.

Important: You don’t need to annotate your object in every single Z-plane (i.e. dense labeling). Instead, you can skip some Z-planes (i.e. sparse labeling). Cellpose will automatically interpolate between the slices and fill in the skipped areas once you press “ENTER”.

Repeat this process for all the masks you’d like to generate. Deleting works the same way as in 2D in case you make a mistake.

Hint: Depending on your image and cell shape, it can be helpful to do the annotations in orthogonal view.

Here’s a video that walks you through all the steps in 3D:

In contrast to 2D mode, changes in 3D are not saved automatically. You’ll need to save your annotations manually by navigating in the menu to “File” → “Save”, or by pressing “CTRL”+”S”.

Keywords

In Cellpose, annotated objects are referred to as regions of interest (ROIs). You may also see terms like mask, label, segmentation, or annotation used interchangeably.

Acknowledgements

This tutorial uses Cellpose-SAM (4.0.3), which is licensed under BSD-3-Clause. The 2D cell masks were generated from a Cellpose example image, licensed under CC-BY-NC. The 3D cell masks were generated from an image by Chen et al. (2024), shared on EMBL-EBI, licensed under CC BY 4.0. Many thanks to both teams for making their data openly available. Below, you’ll find the corresponding materials and useful links for further reading. 

Reusing this material

This blog post is open-access. Reuse of figures or text is permitted under the terms of the CC BY 4.0 license, unless stated otherwise.

Feedback welcome

I’m interested in the day-to-day challenges life scientists face when working with imaging data. My goal is to support the community in this field – whether through developing practical tools or creating training materials with blog posts like these. Feel free to reach out if anything is unclear or if you’d simply like to connect with ideas for tool developments or collaboration! 🤝

1 Star (No Ratings Yet)

Tags: , , , , ,
Categories: How to, Tools

Leave a Reply

Your email address will not be published. Required fields are marked *

Get involved

Create an account or log in to post your story on FocalPlane.

More posts like this

How to
Tools

Filter by