How to merge images

My name is Carla Fuster and I am a pahologist in Hospital Clínic of Barcelona. I am doing a chromogen multiplexing IHC and I want to analyse the images with Qupath. Is it possible with qupath to merge the images of the mIHQ? If not, how can I merge the images of the same histology section to analyse with Qupath afterwards? Should I better use another software? Thank you!!

Hi @CFUSTER welcome to the forum. Perhaps I can give you some initial advice.

In QuPath brightfield images are treated in a specific way. The RGB information of the pixels is automatically processed and some additional channels are ‘added’ to the image - the color deconvolved stain channels.

Therefore, it is not quite trivial to mix several brightfield color images. But it is possible.

One way which probably gives you a solution is the ImageCombiner.
Have a look here

In any case, you should familiarize yourself with the concept of stain channels:

1 Like

If you have multiple stainings of the same exact tissue section, you should be able to get pretty close - you might even build a “fluorescent” image out of the DAB channels, for example. If you have sequential slices, your options are a bit more limited and depend on the experimental question. Sequential slices cannot be used for multiplexing in the sense of generating double/triple etc positive cells.

Thank you! I’ll try it

1 Like

I have the same exact tissue section. But the question was how can I merge them, is it with the image combiner option?

The image combiner is a much more user friendly option, but might be frustrating for something like 8+stains in a row? The other option is using an automatic alignment script and then writing out the image channels using those affine matrices. That might require combining two scripts or manipulating someone else’s script for your particular use case.
On the upside you could end up with a single multichannel image per sample. Depends on the size of the project and the number of channels, whether the development time is worth it.

This might be an option - I have not tried it.

1 Like

Writing out image in 8bit is also considerably better in terms of space saving - especially across a whole slide image.

I’ve been able to align serial brightfield images (One H&E reference, 4 adjacent DAB-IHC sections for individual markers) and merge them into one. There’s an option perform deconvolution while appending, such that instead of writing out the red, green, and blue channels for each section, it’ll write hematoxylin, DAB, and residual. That way you can compare the deconvolved DAB from each IHC marker

Right, I normally would only include the HTX from the fixed image and the DAB from all images. The file sizes get rather unwieldy if HTX and residuals are included for each image - though they can be useful in initial testing phases.

*for restains - I can see the HTX being important for serial sections

Hi @Research_Associate , if you describe the reason for the potential frustration I maybe can improve it.
Currently, the ImageCombiner combines all channels of all selected image entries.
Since the viewer channel settings (Min/Max settings and channel selection) are supported for the overlay, I can use this during image creation too.
Would that be helpful?

1 Like

Sorry, that was my mistake then - As long as it includes all of the channels (or better yet a subset of the channels) that should be all they need! I had thought it was only 1:1, but I had not tried it.

Does it auto-align for all images as well? That was the main benefit to the scripts for me.

1 Like

If RGB brightfield images are combined the R,G,B channels are separate channels in the combined image. In addition to the R,G,B channels the combined image also contains the stain channels 1,2,3 from each of the images.
If you combined n images the combined image contains n*6 channels. This can be potentially confusing.

Combining only a subset of the channels is currently not implemented, but could be possible.

What is 1:1 ?

Alignment is done per image entry, either manually or automatic.

1 Like

One to one, like Pete’s base alignment interface.

Well, if you ever dig into that code again, I suspect quite a few labs that do MICSSS would be interested in being able to see only the HTX+DAB channels, and aligning all images to one chosen fixed image. Being the same tissue slice, the affine alignment works reasonably well (assuming good color vectors, no damage to the tissue, not trying for exact cell measurements).

Currently this is done by a couple of labs using the automated alignment script above, then export to 8bit OME-TIF. Not needing the export step would save quite a bit of time and space.

1 Like

I used the ImageCombiner today and it worked great, thanks a lot! My only gripe was that due to aligning 4 images, I then had 24 channels and due to the names of the images being quite similar, it was quite confusing. A way to select channels that got carried over would be amazing if possible.


Just to add, it was actually 20 channels rather than 24 as the “residual” colour deconvolution channel doesn’t get pulled over. Here’s a snapshot showing the original image names and the resultant channels in the combine image. Some even have the same name now (e.g. C5 and C10) which adds to the confusion.


The residual color would be a nice option in the case where the third channel is not called “Residual”, much like how it works for Subcellular detections and meaurements when the image type is Brightfield(Other). The recent ACD RNAscope presentation might be encouraging more people to use Brightfield(Other) and that third “channel” in the future.

1 Like

Yes, I can confirm that.

There seems to be an issue. Thanks for testing and pointing to it. I will have a look.

1 Like

Currently, stain channels will be added based on the property isResidual().
If the third channel is not isResidual() it will be added.

1 Like

I am not sure about reading the .jar, but I remember having to deal with this for writing out the DAB channels of multiple aligned images.

        if (stains != null) {
            for (int i = 1; i <= 3; i++)
                if ( i==2){channels << ImageChannel.getInstance(name + "-" + stains.getStain(i).getName(), ImageChannel.getDefaultChannelColor(c++))}
        } else {
            channels.addAll(updateChannelNames(name, currentServer.getMetadata().getChannels()))

I ended up editing that part of @petebankhead’s script a bit to shorten the channel names for my use. I adjusted some things at some point (I know, not very specific), and ended coming back to that section to fix them.

@lmurphy This issue should be fixed in the new version of the ImageCombiner.

@Research_Associate Thanks for this idea.

Have a look at