Automatic CELLPOSE 2.2 segmentation of neurons in human neocortex

CELLPOSE (1,2,  is a powerful image segmentation library , written in Python, based on AI and deep neuronal network approaches, developed specifically for microscopy and cell biology.  It includes “model zoo” – a collection of several built-in models, obtained after training on large set of morphological image data. It also includes very convenient GUI application that permits visualizing segmentation results, running different models on user’s image data and creation custom trained models, witch can include new image data using “human in the loop” approach. The source code of Cellpose is available on GitHub (

Here we demonstrate the results of application of this library for segmentation of neurons of human brain cortex by running custom model created with “human in the loop” approach. All data processing was done using NVIDIA Titan RTX GPU with 24 GB of dedicated graphic memory.

1. Selection of the optimal built-in  model and size parameter tuning

At the first step it was necessary to select from available pre-trained models the model optimal for our images. The specific model (“Cyto2” ) was selected by running through all available models and selection of the best results. Additionally, it was necessary to fine-tune the initial value of size parameter, which requires more explanations.

It seems, that available set of pre-trained models was developed with presumption, that the size (diameter) of cell populations in any particular microscopic image is rather homogeneous. However, it is not so for the images of human cortex (and any brain image in general). Different layers, as well as different cell types in the brain have significantly different sizes, which vary from a few microns for nuclei of glia cells, to up to 100 micrometers and more for large pyramidal neurons (Betz pyramids of human or monkey motor cortex,,, see Fig 1.

Fig.1. Cell size variability in monkey motor cortex.

With this in mind, we decided to test the impact of size parameter value on CELLPOSE segmentation. Surprisingly, it turned out to be possible to adjust its value to selectively include or exclude different cell types from segmentation results (see Fig.2). For initial testing of CELLPOSE 2 and model training we selected size value 30, which seems to select neurons and ignore glia cells in segmentation result. This was advantageous for our final goals.

Fig.2 The effect of different size parameter values on the segmentation results of CELLPOSE “Cyto2” model. Left image: size =5 produces segmentation of small nuclei only (mostly glia cells); all other size classes are ignored. Middle image: size =15 produces results which includes all cell images. Right image: size = 30 produces segmentation where small cell classes are ignored.