Filtering out carbon from DAB staining

Following up on https://github.com/qupath/qupath/issues/172.
This is seeking help on how to detect the carbon vs DAB staining for digital analysis without having to manually delete the carbon regions that are positive.

I have quite a few images (TMA cores) to sort through and cannot afford to do this manually as dougzy did, so I need some more details on setting up a proper classifier for black vs. DAB.

I have attached a couple of files with examples of one of the stainings + carbon artifact. It is easily detected by eye, but harder (for me) to get the software to tell them apart.

Thank you for your help!

This looks very similar to How to exclude Hematoxylin crystal staining (black dots)? in terms of staining type, if not the cause of the staining.
What exactly are the problems you are having? Can you similarly exclude cells based on subcellular detections? Or do you want to try to avoid those regions entirely when performing cell detection?

This is pretty far away from the hematoxylin crystals - this is generated soot in smoker’s lungs - it only appears in lung cancer samples, not in other tissues stained.

I am curious that if some black spots are larger than cellular size, will the subcellular detection work of the area is bigger than the cells? I guess since we would be filtering out all cells with carbon, ie, just not counting them, we couldn’t include any cells with DAB and black in the analysis at all (?). Is this correct?

Black spots like that can appear in a few different types of samples, but yes, I’ve most frequently seen them in lung.

As far as the detection, it depends on how you handle it. If you do two different sets of subcellular detections one for DAB above a low threshold, and one above a high threshold, you can subtract the two to see how much area within a cell was DAB stained vs “black.”

If you really wanted to get into scripting, you might be able to generate objects for the black areas, and subtract them from the tissue detection so that they would be ignored during cell detection. That might be tricky though, and require tiling plus submitting areas to ImageJ. It really depends on what percentage of your area/cells are stained black though, and how much simply discarding cells with too much subcellular black area will affect the science.

Thanks, I would prefer to do the least scripting possible, but want to come up with the most accurate analysis that I can (hopefully not mutually excusive). I am relatively new to writing scripts outside of formulas in excel. The two different subcellular detections sounds like it would probably be best, but I may run into a problem, as one of the stains in my set of TMAs is fairly saturated (DAB is very dark). I will try this and report back, though it is getting late here, so it will probably be tomorrow.

All of my files are from a Leica Aperio scanner - .SVS files. Is there any consideration in terms of pixel size, like in the previous thread, or is that set automatically?

In the future, I am going to have a similar problem with fast red separating from melanin in some melanoma samples, so hopefully this can help inform a solution for that.

Most whole slide images will have metadata showing pixel sizes, but it is always best to check the Image tab on the left to be sure they are accurate.

Once things get too dark, you really lose the ability to distinguish between them. Black is pretty much equally all colors. That said, you can often find a color vector set that distinguishes black from very dark brown… sort of. It isn’t something I would bet on, and how well it works might vary across different samples. Once the pixel classifier is scriptable, it might be another way of excluding areas like that.

Plenty of scripts pertaining to measurements here to use as a guide.

1 Like

I have figured out how to use the subcellular spot detection to ID the cells with carbon and can tell the DAB stained cells. It is working on this weaker staining, but I am going to try it with a stronger stain to see how it works.

1 Like

And you can get as complicated as you want with that sort of thing. If you save the carbon spots measurement to the cell, you can do a second spot detection for the lower threshold. You could then classify based on both values, the difference between the two values, or anything else. You can also create intensity measurements within the subcellular population and classify those as well.

The main problem with using cellular DAB OD is that the cytoplasm expanded from the nucleus doesn’t use information in the surroundings to define it’s shape. So tightly packed cells with DAB are more likely to show up as positive, since they will have less “white space” included in their cytoplasms. That white space can severely decrease the mean cell and mean cytoplasmic OD. It really depends on your tissue whether that is necessary, though.

1 Like