Applying a segmentation mask to other images

Hi Everyone,

I have a tissue image that I have segmented via QuPath. I was wondering if it was possible to apply the exact same segmentation coordinates to another tissue image I have. Basically I have scanned over a 500x500um FOV multiple times. I am using a DNA marker as my detection channel for watershed cell detection/segmentation. After each scan, my DNA marker gets weaker and weaker to the point where I can’t use it to segment. Because of this, I would like to use my initial scan that has very nice DNA staining and is well segmented and apply that same segmentation mask to the other depths.

If anyone has any suggestions, it would be much appreciated.


Would it be feasible to concatenate a ‘good’ channel for segmentation to each image (eg using Fiji) then use the cell segmentation in QuPath using that channel as normal?

Otherwise, transferring cells from one image to another would be possible (currently with scripting), but a complication is that all the existing measurements for the cell objects would relate to the original image. Calculating new measurements on the new image would be difficult, since they are generated at the end of the cell detection step.

There is ‘Add intensity features’ but it doesn’t do quite the same thing (eg restricted by cell compartment) - I’m not sure if that matters for your application or not.


A quick and hopefully non-dangerous addendum to this:
Since you can now use Add Intensity Features for both the whole cell and the Nucleus alone, you can create cytoplasmic mean measurements as well with a little scripting.
[(Total cell intensity mean * total cell area) - (nuclear intensity mean * nuclear area)]/(Total cell area - nuclear area)

You would need to run Add intensity features twice, once to get the whole cell and once to get the nuclear measurements. It can also be impacted by things like your chosen pixel size, so it might not mean exactly the same thing as the original cell detection measurements.

One last note, I guess, is that you may want to make sure you overwrite the exact names of the measurements so that scripts/classifiers run smoothly across your images.


In response to both Pete and Research_Associate, the concatenation of the “good” channel is a nice idea. The only issue is I also want to analyze that “good” (DNA) channel across every depth as well, and I can’t do so if I I’m concatenating the initial good one to every image. Unless there was a way to concatenate it using a different name?

RA’s suggestion worked well (by copying the .qpdata files from one image to another and re-generating measurements using Add Intensity Features). However, it’s strange because I’m just realizing now that there is no sum measurement. I even tried creating a new project, re-segmenting on just one image and I’m not seeing any sum measurement in my detection results. Also, of course, when I’m re-computing measurements using Add Intensity Features, there is no sum option.

To generate a psudo sum measurement I was thinking of taking the calculated intensity feature mean and multiplying by the pixel size and multiplying by the area of the segmented cell
(mean * pixel size * area of cell) to calculate the sum of that channel in each segmented cell. I’m not sure if this a very kosher way of calculating sum or if I’m just missing something. This question could probably also be a separate topic, but I figured I would post it here for now.

I’m not totally sure I understand (‘depth’ means channels here, right? not z-stack…?), but if it’s not possible to rename the channel elsewhere do it within QuPath (albeit only in recent milestones): see QuPath multiple channel in separate files - how to merge them?

You could check out ‘Integrated density’ in ImageJ to see how it’s done there:

Assuming your pixel size remains the same across images, I guess whether you factor it into the calculation or not probably doesn’t change the overall conclusions - it really just impacts how to name the measurement to avoid confusion.

That’s true, but as long as you’re aware of that I think it could work. Add intensity features uses different naming from cell detection, so it should be clear where the measurements came from originally.

Only comments I would have is that if you want to compare cell to cell, there is no need to multiply by the pixel size, as that will be the same for every cell. If you are looking for greater accuracy across varying conditions (lighting, microscopes), you might also need to be more careful about subtracting out background levels, so there would be an extra term in the above equation to remove background levels of intensity. That is usually more necessary for widefield imaging, and is covered in Pete’s link on integrated density, I think.

It might be useful to see one or two of your images to make a better determination, but I’d be a bit nervous about essentially treating a column as a cell. The greater Z distance you include, the more likely you are to start including overlapping cells as part of the same cell.

If you want to dig into some examples of calculating your measurements, I keep some here. Note that they won’t all be written for your version of QuPath, whichever one you happen to be using at the time. It isn’t amazingly well curated.

I suppose it would be easier to only use the Add intensity feature measurements, for consistency.