Membrane staining in QuPath

I have a series of TMAs of breast tumor tissue stained for a marker (brightfield, H-DAB) that localizes to the cell membrane (E-cadherin). I have created a classifier to separate tumor from stroma, and would like to subsequently use the “Set cell intensity classifications” command. Under “Measurement”, do I select “Cell: DAB OD” for membrane staining?

Thank you for your help!

It would help to have a bit more information and sample images, as requested by the starting text in the forum post. There are many things that can happen with non-nuclear stains and the answer is not always simple.

Sure, here is a sample image. I also have several cytoplasmic and nuclear markers, and have been able to train a classifier and set intensity thresholds to get an H-score for each. I would like to get an H-score for the membrane stain as well.

1 Like

I think I’ll leave this for @petebankhead since none of the ways I would currently approach it would be very accurate or efficient, and there might be something in the works or a new way of using current functions that I am not aware of.

The cytoplasmic DAB should be relatively easy to pick up (using that measurement), but the cells where it is membrane specific would be much harder.

The one thing you could try in the meantime is the Cell+Membrane detection in the Deprecated submenu.

1 Like

Thank you! I look forward to Dr. Bankhead’s input.
I did try the Cell+Membrane detection option, but didn’t see a way to set the threshold for positive cells.

Cell+Membrane detection has worked relatively well for me for such stains. I noticed that it was deprecated in recent versions. I’m not sure why and whether it has been replaced by something else, but I continue using it as I find it useful and have not found another way.

1 Like

You would set that in a second step, and doing it exactly on the membrane might be tricky. If the membrane includes positive pixels, then Subcellular detection might be an option.

StarDist cell detection includes a “membrane” measurement option, so there is a decent chance there is some clever way to calculate the intensity along the cell membrane line. *But it probably involves some scripting.

You can use Set cell intensity classifications to do this – see

In general, detection in images like yours is really difficult because the QuPath needs to be able to see the nuclei… and these aren’t very visible in the screenshot (or are obscured by the brown stain in some cases). There is no ideal way to do this in QuPath currently, but you can try the different cell detection commands to see what works best.

That’s good to know, I wasn’t sure if the command was being used at all. It does need a replacement one day, but that doesn’t exist yet so it will linger in its deprecated state for a bit longer.


Yep, that was what I was leaning towards, except based on the image, without a “membrane” option, it may not work very accurately. Bigger cells would have more clear space and be less positive. I am guessing there is no straightforward script-around to expand the cell membrane one or two pixels and pick up a measurement from that? I couldn’t think of a way to combine the membrane option from either StarDist or the Border option in the Pixel Classifier to detect what is happening in the pixels around the cell border.

Though, this type of cell detection would currently be the only case I can think of where a measurement like that would be terribly useful…

@Research_Associate if you’ve run Cell + membrane detection then the membrane measurements will be available under Set cell intensity classifications.

The usefulness of this really depends upon how well the detection works; if it’s bad enough, then regular cell detection with a carefully-selected cell expansion and cytoplasm measurement is probably as close as QuPath can offer.

1 Like

Ah hah! So… I definitely have not run it much. Nice!

Dear @petebankhead and @Research_Associate,
can you tell me if there is any novelty in QuPath regarding this issue? I was running “positive cell detection” and selecting “cell mean DAB” for membrane staining but was not measuring membrane at all. Indeed, if using the deprecated Cell + membrane detection then the membrane measurements will be available under Set cell intensity classifications it measures way better, but is really time consuming for someone who is using whole slides. Do you have any other suggestions?

Can you provide a sample image?

In some cases, like for macrophages, membrane stains are simply a very difficult problem. A pixel classifier might be a better option rather than cell counting.

There’s nothing new in QuPath for membrane measurements at the moment, but note that any time you run Set cell intensity classifications this will be logged in the workflow.

This means with a simple, automatically-generated one-line script you can apply the command with the same settings – potentially even across many images after the cells have been detected. The script will look something like this:

setCellIntensityClassifications("Membrane: DAB OD mean", 0.3)

See the link above for more information.

Thank you both. Here you can find the image I am currently working on. Besides the membrane staining I am looking to, cells are also stained often in the cytoplast which I want to ignore (but is considered if I select “Cell mean DAB”).
Thank you @petebankhead for the tip regarding the script, that might really help.

1 Like

Thanks for the image, you might find ‘cytoplasm mean DAB’ more effective than ‘cell mean DAB’ if you use the positive cell detection (but accurately segmenting and measuring the cells looks like a really hard problem no matter which option you use).

You can use Measure → Show detection measurements and generate a histogram of each of the available measurements – this allows you to visually compare whether or not your DAB values are quite well separated for any given measurement (i.e. clear peaks for low and high values, so you can set a threshold in between).

1 Like


That makes the standard measurements very difficult, and normal cell detection probably will not be terribly effective either since the cell borders are not defined by the DAB staining.

In addition to @petebankhead’s recommendation using the histogram, I usually start my classifier threshold estimates using the Measurement Maps option.

I inverted the color axis here, but watching for the final color change, and checking what the max value is listed as, usually gives me a good head start for estimating the appropriate threshold (if doing it manually).


Ah, I missed that sentence… in such an image I think it isn’t really possible to truly distinguish between staining in the cytoplasm or membrane (despite what the measurement names might suggest).


indeed segmentation is a nightmare… I am now selecting tumour areas by hand and is incredibly time consuming. i will try the measurement maps now.
could you help me clarify this: positive cell detection command “cell mean DAB” considers all compartments staining (nuclear, cytoplasm and membrane) or just nucleus + cytoplasm? at least in my images it does not seem to recognise membrane staining. do you think it is a matter of threshold or really is the detection itself?

Slightly off topic here, but it seems like most of the cells you are trying to detect are grouped together, and have a similar “feel” to their texture. It might be worth looking into a pixel classifier to identify those regions, and then you can use the pixel classifier to classify the cells (one of the options, you can also create objects, but I think cell classification might help you more here).

Not certain how well this will work, but it might be something to consider if your current methods are not giving you sufficient accuracy.
I am not sure using the pixel classifier this way is covered in the link, but the link has most of the information you will need about setting up the pixel classifier. The pixel classifier can be very stressful on a computer, though, so if you do not have a powerful computer, you may run into problems (I just had issues on a PC with 255GB of RAM).

I’ll leave the specifics of the measurements to Pete, but I imagine regardless of how it is calculated, the mean value would be incredibly diluted by the entire rest of the cell. The membrane (the very edge pixels) is probably less than 5% of the total area… so it won’t have much contribution to the total.

1 Like