Obtaining single cell data from time-lapse microscopy images is critical for quantitative biology, but bottlenecks in cell identification and segmentation must be overcome. We propose a novel, versatile method that uses machine learning classifiers to identify cell morphologies from z-stack bright-field microscopy images. We show that axial information is enough to successfully classify the pixels of an image, without the need to consider in focus morphological features. This fast, robust method can be used to identify different cell morphologies, including the features of E. coli, S. cerevisiae and epithelial cells, even in mixed cultures. Our method demonstrates the potential of acquiring and processing Z-stacks for single-layer, single-cell imaging and segmentation.
Thanks to the development of microfluidics and microscopy, it is now possible to measure the dynamics of single cells over time1,2. In recent years, longitudinal time-lapse studies have emerged as key methods in quantitative biology and are essential to understand the dynamics of cellular processes2,3,4. However, a robust and efficient cell segmentation method is required to obtain high quality single cell traces1,2. Despite years of development, a universal method to segment cells from microscopy images has not yet been established. The numerous existing methods were designed for specific cell types and usually rely on specific morphological features (e.g., size, shape, fluorescent labeling). Although efficient for specific problems, these methods are not versatile, and usually fail when applied to different cell types or other experimental conditions. As a result, research groups design and tweak image analysis software5,6,7,8,9,10,11,12,13 to match their specific segmentation problem. This is a considerable waste of time and energy, and highlights the need for a simple, versatile strategy to segment cells, irrespective of experimental design or cellular characteristics.
Notably, segmentation critically depends on obtaining high-quality images with a constant focus that outlines the borders and main morphological features of the cell. This is an important constraint, which – in practice – requires periodic auto-focusing or a control system to automatically maintain perfect focus. Here, we propose a different segmentation strategy inspired by hyperspectral imaging. Instead of relying on the in-focus image, we systematically acquired multiple stacks of images around the focal plane (i.e. a z-stack) of various cells, and use the information contained within the full z-stack to identify the focal region of the cells in the images. The central idea is that cell contours, the cellular interior or any objects within the field of view do not have the exact same intensity profile throughout the z-dimension. Here, we show it is possible to train an algorithm using machine learning to classify z-pixels (the vector of light intensity along the z-axis for a specific pixel in the image) based on their focal signature. The method is simple, robust, can be run in real-time and – importantly – gives excellent results for E. coli (rod-shaped), S. cerevisiae (round), mammalian epithelial (HeLa) cells, and even a mixture of bacteria and yeast cells.
We used a Piezzo drive (PIFOC, PI) to acquire z-stacks containing 100 images, 100 nm apart, of E. coli using a 100x oil objective (UPlanFL 1.3NA) and CoolSNAP HQ2 camera with a resolution of 1040 × 1392 pixels (Fig. 1A,B). E. coli cells were loaded into a microfluidic device where they were cultured in narrow chambers (Fig. 1C). A graphical user interface (GUI, Supplementary Text) was developed to manually label a training dataset by defining regions of interest (classes), such as the interior of the cell and its contours, then a machine learning classifier was trained on this dataset (see Supplementary Text). Importantly, the algorithm was not trained using the morphological features in the (x–y) plane – as it is classically done – but only a representative set of z-pixels (Fig. 1B) for each class of objects that the user wants to identify and segment in the image. Indeed, many such z-pixels can be found in a z-stack of a monolayer since it usually contains tens to a few hundred E. coli and any 10 × 10 pixels area (representing the typical surface of a cell) contains as many as 100 different profiles. Principal component analysis was used to reduce the dimensionality of the problem from 100 dimensions (if all z-positions in the stack are considered) to a lower dimension space (typically between 5 and 20 dimensions, see Supplementary Text), that enabled separation of the different user-defined classes (Fig. 1D,E). In practical terms, we used Matlab and its Support Vector Machine library (fitcsvm package), to perform training and class identification (see Supplementary Fig. S1). The classification of a z-pixel does not depend on the classification of other z-pixels, so the parallelization of the prediction process is straightforward.
After training, we acquired another z-stack and used the SVM to classify the pixels. As shown in Fig. 2, the different parts of an image of E. coli cells were correctly identified with neither post-processing nor user intervention (see also Supplementary Fig. S2). The cells were detected, and it was even possible to locate and classify the cell contour, cell interior and microfluidic chamber with excellent fidelity. Therefore, this method is markedly more powerful than classic segmentation, since it enables identification of more than one type of structure, without any a priori knowledge of their morphological features in the focal plane. Moreover, Fig. 2C shows how automatic labeling of a pixel is associated with a confidence score that can be used to assess the quality of the classification and further refine cell segmentation (see Supplementary Text, Supplementary Figs S2–S6). Although it’s often interesting to define several classes to identify important objects on the image, classification of cells only requires two classes: “cell” and “not cell” (see supplementary text). The number of images can also be decreased while achieving good performance; the method gave excellent identification scores (classification error less than 1%) if the z-stack contained at least seven images (Fig. 2D, Supplementary Fig. S3). On our computer system (20-cores Xeon, DELL), training the SVM on a typical dataset took from 15 min to 1 hour at most, and a little longer than 1 minute to attribute the pixels to their classes in a 1392 × 1040 × 100 z-stack.
Importantly, this method could be applied to different experimental designs. First, we confirmed our method could efficiently identify single bacteria in a dense monolayer of E. coli (instead of a few lines of cells) grown between a glass slide and an agar pad (Fig. 3A). We then showed that the method also worked well to identify yeast cells, even though budding yeast cells are larger than E. coli cells (~5 µm vs. ~1 µm) and are round (Fig. 3B, Supplementary Fig. S4). We also successfully segmented a mixture of yeast cells and bacteria (Fig. 3D, Supplementary Fig. S5); the system could distinguish between the two types of cells based on their focal signature. This is a particularly hard task for any standard segmentation algorithm based on morphological features alone, indicating this method could represent an important tool for research on infectious diseases or microbial ecology. Additionally, we succeeded in identifying individual epithelial HeLa cells in a confluent monolayer (Fig. 3C, Supplementary Fig. S6). Mammalian cell segmentation is hard, and although deep learning methods have already demonstrated their potential to segment mammalian cells with complex shapes, it came at the expense of large dataset and long computing time14. In our case, a simple machine learning algorithm and limited training datasets were sufficient to enable rapid identification of cells with various shapes in a timescale that allow cell classification to be done on the fly. Importantly, our method showed better classification results (see Supplementary Fig. S7) than the Ilastik classifier10, a reference image analysis software, which does not use axial information, but encodes information from neighboring pixels. This suggests that axial information contained in Z-stack contains enough information to be used directly for pixel classification (see Supplementary Text).
After classification, the cellular regions are already identified and the cellular segmentation becomes easier. The use of even simple segmentation methods downstream of the classification step provided good results (see Supplementary Text). We anticipate that advanced segmentation algorithms, such as active contour methods, could further improve the fidelity of cell segmentation and tracking.
The method presented in this manuscript does not require a complex imaging setup, since only a few images (~10) in a z-stack are required for robust identification of cells. It comes with a GUI to facilitate drawing of the regions of interest in the training dataset. Importantly, it can identify bacteria, yeast, mixture of yeast and bacteria, and mammalian cells (Fig. 3) with the same workflow. Therefore, it appears as a versatile method that can be used to facilitate complex segmentation problems. Moreover, its performance can be further improved. preliminary analysis using Random Forest and Neural Network (See Supplementary Text, Supplementary Fig. S8) showed comparable classification accuracy than SVM, but at much faster speed. Specifically, Random Forest classification was typically 20 times faster than SVM classification. With a single core processor, a full image classification was obtained in typically a minute with a Random Forest classifier. Neural Network classifier also trains in SVM like times, but the prediction usually takes only a couple of minutes. It becomes possible to perform identification in real-time, at least with respect to the typical timescale of single cell microscopy imaging (e.g. several minutes between two frames when observing gene expression by fluorescence microscopy). Of course, the processing time could be also drastically decreased by relying on graphic processor unit (GPU) accelerated libraries. Taken together, we anticipate that this versatile method can be integrated into any image analysis pipeline15 and can thus tremendously facilitate cell segmentation and tracking problems.
Cell culture and imaging
Cells were cultured and imaged following standard protocols (E. coli were grown in LB at 37 °C, yeast in SC at 30 °C and HeLa cells in MDEM at 37 °C and 5% CO2). Unless noted otherwise, z-stacks were acquired using an IX71 Olympus equipped with a piezo (PIFOC, PI). This allows precision positioning of the objective at a resolution in the tens of nanometers.
A graphical user interface (GUI, see supplementary text) was used to simplify training set construction. Images were normalized by performing a standard histogram equalization procedure with 1% loss on the histograms. We used principal component analysis (PCA) to reduce dimensionality of the problem. Only a subset of the main principal component (N < 20) dimensions were used to represent the data used to train the classifiers and later generate predictions. For SVMs, we used a method known as winner-takes-all SVM (WTA-SVM), which has the double advantage of providing a classification score for each class and does not require the experimenter to establish a classification tree. The fit implementation of the SVMs was based on the Matlab fitcsvm package, which features automatic hyper-parameter optimization, with a Gaussian radial basis function as a kernel and a hinge loss function. We built a manually labeled set and divided it into two parts by random data subsampling: the first part, consisting of 90% of all data was used to train the SVMs. The remaining 10% was used as an evaluation set. Once a satisfactory SVM set was obtained for a particular classification problem, it was used to process new stacks (captured under similar conditions) for cell identification. Stacks to be analyzed were first scaled to the same dynamic range as the training stacks (the histogram of the entire stack is equalized over the maximum range of the training data type). Then transformed into the principal components base. The best SVM set was then applied to the transformed data, and – for each z-pixel – a set of classification scores that correspond to each of the classes the SVMs were trained for was computed. Good to very good segmentations were obtained from the classification maps, as shown in supplementary materials. Classification and segmentation methods are described in details in supplementary materials.
The Matlab code and datasets generated for this study are available on our GitHub repository (https://lab513.github.io/Zcells/, https://doi.org/10.5281/zenodo.1307765) and on a dedicated Zenodo archive (https://doi.org/10.5281/zenodo.1307781).
Skylaki, S., Hilsenbeck, O. & Schroeder, T. Challenges in long-term imaging and quantification of single-cell dynamics. Nat. Biotechnol. 34, 1137–1144 (2016).
Young, J. W. et al. Measuring single-cell gene expression dynamics in bacteria using fluorescence time-lapse microscopy. Nat. Protoc. 7, 80–88 (2011).
Meijering, E., Carpenter, A. E., Peng, H., Hamprecht, F. A. & Olivo-Marin, J.-C. Imagining the future of bioimage analysis. Nat. Biotechnol. 34, 1250–1255 (2016).
Mattiazzi Usaj, M. et al. High-Content Screening for Quantitative Cell Biology. Trends Cell Biol. 26, 598–611 (2016).
Marr, C., Theis, F. J. & Schroeder, T. Software tools for single-cell tracking and quantification of cellular and molecular properties. Nat. Biotechnol. 34 (2016).
de Chaumont, F. et al. Icy: an open bioimage informatics platform for extended reproducible research. Nat. Methods 9, 690–696 (2012).
Carpenter, A. E. et al. CellProfiler: image analysis software for identifying and quantifying cell phenotypes. Genome Biol. 7, R100 (2006).
Wang, Q., Niemi, J., Tan, C.-M., You, L. & West, M. Image segmentation and dynamic lineage analysis in single-cell fluorescence microscopy. Cytometry A 77A, 101–110 (2010).
Versari, C. et al. Long-term tracking of budding yeast cells in brightfield microscopy: CellStar and the Evaluation Platform. J. R. Soc. Interface 14, 20160705 (2017).
Sommer, C., Straehle, C., Koethe, U. & Hamprecht, F. A. Ilastik: Interactive learning and segmentation toolkit. in Biomedical Imaging: From Nano to Macro, 2011 IEEE International Symposium on 230–233 (IEEE, 2011).
Kan, A. Machine learning applications in cell image analysis. Immunol. Cell Biol. 95, 525–530 (2017).
Bakker, E., Swain, P. S. & Crane, M. M. Morphologically constrained and data informed cell segmentation of budding yeast. Bioinformatics 34, 88–96 (2018).
Dimopoulos, S., Mayer, C. E., Rudolf, F. & Stelling, J. Accurate cell segmentation in microscopy images using membrane patterns. Bioinformatics 30, 2644–2651 (2014).
Ronneberger, O., Fischer, P. & Brox, T. U-net: Convolutional networks for biomedical image segmentation. in International Conference on Medical Image Computing and Computer-Assisted Intervention 234–241 (Springer, 2015).
Carpenter, A. E., Kamentsky, L. & Eliceiri, K. W. A call for bioimaging software usability. Nat. Methods 9, 666–670 (2012).
The authors thank Peter Swain, Julian Pietsch, our team members and an anonymous referee for their suggestions and critical reading of this manuscript. This work was supported by the Agence Nationale de la Recherche (ANR-10-BINF-0006; ANR-16-CE12-0025; ANR-16-CE33-0018) and the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation program (grant agreement No 724813).
The authors declare no competing interests.
Publisher's note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Electronic supplementary material
About this article
Cite this article
Lugagne, J., Jain, S., Ivanovitch, P. et al. Identification of individual cells from z-stacks of bright-field microscopy images. Sci Rep 8, 11455 (2018). https://doi.org/10.1038/s41598-018-29647-5