Correctly Identifying and Quantifying Membrane Stained Cells in High Density

585 views
Skip to first unread message

James Hurst

unread,
Feb 8, 2018, 9:48:39 AM2/8/18
to QuPath users
Hi Everyone,

This isn't a scripting or workflow question, more a question on how best to get an accurate count of densely packed cells which frequently have their nuclei obscured by the DAB staining on the cell membrane.

I have previously been working with the Fast Cell Counts feature of QuPath, but found this to be overestimating absolute numbers when using this marker. I've changed to using Positive Cell Detection in the hope of outlining the large infiltrating immune cells and reducing the overestimation of these cells. I've found that this has not worked, and instead I still have problems whereby the nuclei of cells surrounding the stained cells have the DAB staining attributed to them (instead of the macrophage its self being identified), resulting in instances of 4 or 5 surrounding cells being mis-labelled as positive. 

Image 1 shows the kind of density of macrophages I am working with, whilst Image 2 shows an area of interest (randomly chosen for illustrative purposes), whilst image 3 shows this same area, with the cell identification overlay. As you can see, in the yellow 'circle' I've managed to annotate expertly, there is what looks like a single stained cell being ignored, and instead the 4 unstained cells around it are being identified as positive. 

Image 4 shows the current Setup Parameters I'm using, if there is something I'm doing wrong, or another method of cell counting which may be more suited to my application, I'd love to hear it.

I've mainly been trying to change the Sigma (to get more irregular boundaries), Cell Expansion (to limit the number of cells 'affected') and ticking and un-ticking the Split By Shape and Exclude DAB (membrane staining) boxes, with little success. I suspect I am hampered by the lack of visible nuclei in many of the stained cells.

Thanks for your time and for a fantastic program!

James
Macrophage Staining 1.PNG
Macrophage Staining 2.PNG
Macrophage Staining 3.PNG
Macrophage Staining 4.PNG

Pete

unread,
Feb 8, 2018, 10:08:32 AM2/8/18
to QuPath users
Hi James,

Apologies if you've already done this, but the two things I'd try first are:
  • Setting 'Optical density sum' as the detection image
  • Setting the score compartment to be the nucleus (even though it isn't...)
Even if this is not conceptually very satisfying, it might result in positive cells being detected as nuclei (wrong) but counted as one object (right!).  Otherwise I share your view that the density of the brown staining is really thwarting the attempt at stain separation.  If you use the Brightness/Contrast tool (or press the numbers 2 or 5...) you should see the two different 'detection images' and judge which do you think has got the best chance of producing better counts.

Apart from that, do you need to detect the 'negative' cells at all - or is your final result going to be a count or density of the positive cells only?

If you are only interested in the positive cells, you could remove the negative ones with this script

negative = getCellObjects().findAll {it.getPathClass()?.getName() == 'Negative'}
removeObjects(negative, true)

This might make it a bit easier to see how well (or badly) it is doing.  Alternatively, if you don't want to delete them entirely, here's a small hack to just hide the negative cells:
  1. In the list of classifications, add a new classification with the (exact) name ‘Negative’
  2. Right-click on the ’Negative’ classification and choose ‘Toggle display class’
Then they will no longer be shown, but the cells will still be available if needed.

If all else fails it might require something customized for your detection, e.g. an ImageJ macro.  In that case it would be good to know the simplest acceptable measurement you're looking for.

micros...@gmail.com

unread,
Feb 8, 2018, 1:13:03 PM2/8/18
to QuPath users
If the OD sum doesn't work well enough, one thing to try in tricky situations like this with really dark stain is duplicating the project.  Then you can generate positive cells (with a high OD threshold) in one project while generating only the negative cells in a second (Htx OD only).  This is probably only useful if you can get very high accuracy in each case (since without extra work you aren't looking for overlapping X-Y coordinates), but since you can copy the .qpdata files between projects, you can use the exact same annotation areas.

James Hurst

unread,
Feb 9, 2018, 11:31:15 AM2/9/18
to QuPath users
Hello Both,

Thanks for the swift replies, Pete's first suggestion appears to have done the trick. I'm interested in the positive cells as a percentage of total cells in the sample, so really I need to estimate both to the best accuracy I can manage. This seems to have made most aspects of the identification of these cells vastly improved, I just need to play with the parameters and I reckon this will do the job. 

James Hurst

unread,
Feb 23, 2018, 10:53:46 AM2/23/18
to QuPath users
Hello again,

Recently got some time to spend on this and have found that unclicking the 'split by shape' box allows me to pick up the macrophage staining almost perfectly, with barely any double counting. This would be the ideal setting, but (as I'm sure you're aware) this means a lot less accuracy in the overall count of regular nuclei. I see some groups of 4 or 5 nuclei are grouped as one, but more regularly there are pairs of nuclei identified as one. 

Do you think there might be a way of mitigating this? I think perhaps the resolution of my images might be letting me down at this point. 

I could think about using M's suggestion of duplicating my project, but I'm ultimately aiming for a degree of automation on this project, so it would add quite a bit more work. 

Many thanks,

James

micros...@gmail.com

unread,
Feb 23, 2018, 11:44:43 AM2/23/18
to QuPath users
Depending on how regular the sizes of the nuclei are, you could use something similar to subcellular detection where you count by area.  For example, if a cell is positive, Nuclear Area/macrophage area = new measurement Macrophage Count.  Then use the Macrophage count total versus the negative cell count to get a percent positive.

Pete

unread,
Feb 25, 2018, 11:28:47 AM2/25/18
to QuPath users
If I understand correctly...
  • There are settings that make it possible to detect the macrophages well
  • There are different settings that make it possible to detect all the other ('negative') nuclei well
Is that right?

If this is reliably the case, I imagine the following should be scriptable (although I haven't done it yet):
  • Run cell detection with the first settings to identify macrophages
    • Delete all the negative cells
    • Stash the positive cells/macrophages 'somewhere' (either in memory or a temporary .qpdata file)
    • Delete macrophages
  • Run cell detection with the second settings to identify the 'negative' cells
    • Delete all cells classified as positive
  • Retrieve the macrophages and add them to the result
This might take a bit of work to get right, and I'm not sure how good the final results would be; it would miss some normal sanity-checks (e.g. to make sure cells aren't overlapping/detected twice), but might be accurate enough.

You could get a first look at the results across a project by doing the following:
  • Creating all your annotations within which cells should be detected
  • Duplicating the project
  • Running the cell detection once, deleting all the negative cells, and exporting the results
  • Running the cell detection with the other settings, deleting all the positive cells, and exporting the result
There would be a bit of manual effort in bringing together the results, but this would at least give you positive and negative cell counts across the same regions - even if they are not (yet) in the same data files.  This could show whether or not it's worthwhile to try to create the more complicated script to automate the process without a need to duplicate the project.

But before committing to either of those, I would (optimistically) ask whether it is possible that normalizing by area would be more / similarly meaningful, i.e. taking the number of macrophages per mm^2 as the final output.  As far as I can tell, normalizing by area rather than total cell numbers seems to be the 'standard' measurement to make in many kinds of study, but of course I don't know if it is suitable in your case.  It should certainly be easier to get here...

James Hurst

unread,
Apr 11, 2018, 9:47:48 AM4/11/18
to QuPath users
Hi Pete,

Spending more time on this now. I've decided that I'll probably switch the reporting of my results to mm^2, I was reticent to do this as I've made previous reports using the percentages rather than mm^2. 

One question before I decide to do this; is the value calculated by the size of the annotation, rather than the area covered by detections? I only ask because I have some large spaces of lumen which contain no cells. This will distort the mm^2 value in slides with larger spaces. Of course, unless I remove these spaces from the annotation area. 

Cheers,

James

Pete

unread,
Apr 12, 2018, 10:01:25 AM4/12/18
to QuPath users
Hi James,

I'm afraid it's the entire annotation area.  If you're drawing the regions manually, then using the Wand tool (or Brush) with the Alt key pressed should help quickly remove regions that should be excluded.

Pete
Reply all
Reply to author
Forward
0 new messages