Qupath quantification of cardiomyocyte size

Sample image and/or code

I’m trying to count cardiomyocytes within a field, and then quantify their size. I only want to count cells that have a nucleus in this plane. I am really struggling because the cell sizes are very inconsistent and there is no clear border. In addition, the fibrosis between cells is irregular and getting picked up as nuclei. The cells are stained with PAS (not H&E)- does anyone have any tips as to how to improve the accuracy? This is what I have accomplished so far, the parameters being changed just based on visual accuracy.
Thanks in advance!


Should I instead be using object classifiers to mark + and - cells and then make an algorithm that trains on that?

If you want cell size, you pretty much would need a pixel classifier that identified cell borders, and then associate those with nuclei downstream with some coding, or manually annotate the cell borders.

Looking at your image, I do not even see strong cell borders, so like several other people who have come up with muscle cell segmentation, I would recommend not using H&E or PAS, but some sort of IHC marker that delineates the cell borders.

Even then, you cannot use cell detection for accurate “cell size”, that, at least currently (0.2.3) does not make any attempt at getting accurate cell shapes/sizes. It is a simple expansion/watershed on the shape of the nucleus.

Designing the experiment such that it can be analyzed is one of the most important steps! I am not sure even a well trained deep learning model could correctly handle this =/

Happy to be proved wrong though, if anyone else has suggestions.

Completely different topic, due to the DAB staining being mentioned in your image, your color vectors/analysis could probably be improved by setting the stain vectors and using only Hematoxylin as your nuclei detection channel. That does not solve your larger problem, but it would improve your nuclear detection.

1 Like

Thanks for your reply! That makes sense… it is feeling a bit hopeless :frowning:

You could give the pixel classifier a try, but my assumption is that it would not be accurate often enough.

1 Like

Hmm, this could potentially be solved using a mix of pixel classification and cell (nucleus) detection.

First, create the appropriate stain vectors for the PAS staining via Preprocessing > Estimate stain vectors. This will be useful in improving the classification accuracy of the subsequent pixel classifier.

Next, we need to identify cell borders. Either train a pixel classifier based on manually annotating regions of cytoplasm, nucleus, and cell membrane areas, and include the deconvolved stains as some of the channels to train on. Alternatively, if your deconvolution looks crisp enough to delineate the structures using the individual dyes making up PAS, create a pixel thresholder based on the stain corresponding to cell membrane. Whichever method, the end result should be a single annotation corresponding to membrane staining.

As previously mentioned, not all membranes are clearly visible in the image, rather most appear to be fragmented. Find the distance of the largest gap, and dilate the annotation by that amount via Annotations > Expand Annotations. This should bridge any gaps. Perform an erosion of the annnotation by the same amount, by repeating the previous step but supplying the negative value of the aforementioned distance. You should now have an annotation corresponding to all cell membranes, with most gaps patched.

Perform nucleus detection via Cell Detection > Cell Detection. Set the cell size growth to 0, so that we only have nuclei detected. Now, to identify the cell area, we’ll need to calculate the distance of each detected nuclei to the nearest cell membrane annotated area. I’m not sure if this needs to be done via scripting, but if that’s the case, you may have to adapt this script originally meant for calculating annotation-to-annotation distances, into nucleus-to-annotation distances Making Measurements in QuPath · GitHub. Could potentially achieve this by transforming nucleus detections into annotations, but it’s up to you.

Once we have the distances of each nucleus to the nearest cell membrane area, that’ll serve as our radius for calculating cell area. We’ll have to make a very bold assumption that the cells can be loosely modeled as a circle, and square and multiply by pi (i.e. pi*r^2 formula for determining area of a circle given a radius). It’s not ideal, but the closest I can think of given the high degree of variability in membrane staining.

Or, have a gaggle of summer students painstakingly annotate the thousands of cardiomyocytes in this image, outlining every cell membrane and nucleus in the image. And hey, maybe you could train a cell segmenter with those annotations in Ilastik/Cell Profiler, who knows!

1 Like

Yeah, this was the section that I did not think would work based on the sizes of the gaps in the images, but if you can get that part to work, there are a nice variety of options.

I would probably create a giant whole image detection (as a starting Geometry), subtract the “cell border” annotation from that in “Geometry land,” and get a large number of “cell” geometries. Filter as needed. Convert each of those into an object and check it for a nucleus (intersection), and if you find one, merge the ROIs for the cell and the nucleus into a cell object and add area measurements.