# How to generate Similarity Index

We are trying to assess the similarities between lesions (dark-ish blobs in the center) of two eyes of a single patient. Sometimes - they are exact mirrors of one another (the first example) and sometimes they differ a bit more in size/shape (the second example). We are seeking any idea or suggestion to generate a "similarity index" based on the shape and size of the lesions between the two eyes: 0 being totally different and 1 being the same. Any help would be great - thank you! Jeong

Hi @jwpak,

Welcome to the forum!

As is often the case, thereâ€™s not an â€śeasy answer.â€ť You will likely want to perform some variation of the following steps:

1. Image registration to remove differences in spatial location / orientation.
2. Image segmentation to determine the part of the image over which you want
3. Compute similarity over the segmented regions, e.g. (Sum of squared differences, Normalized Cross Correlation, or Mutual Information)
4. Some other analysis to get â€śshapeâ€ť differences

You may even be able to skip step (2), but that means that you wonâ€™t just be comparing differences between lesions, but between everything (blood vessels, fovea, etcâ€¦).

Below are assorted thoughts on some tradeoffs youâ€™ll need to consider:

For step (1), you can do a rigid, (or flip + rigid) transform to align things, but then when you do step (3), your image intensity is mixed up with â€śshape.â€ť To get â€śshapeâ€ť variation you may need to do some analysis on your segmentation. (Analysing â€śshapeâ€ť is hard, btw)

Alternatively, you can do a warping alignment for step (1). This is â€śbetterâ€ť in that you donâ€™t have â€śshapeâ€ť confounding your intensity comparison. But warping alignment is harder to do, and that means you could be introducing variability that represents your in-ability to warp repeatably. It also means that to get â€śshapeâ€ť differences, youâ€™ll need to analyze the properties of the transformation not the properties of the *image.

Thereâ€™s no one answer, and in the end, you will have to decide what differences you care about most, what variables you need to control for, and what variables you are willing to tolerate as â€śconfoundsâ€ť.

Good luck!
John

2 Likes

Thanks John for your insights and suggestions. It is a lot to digest!

The shape is more interesting and important variable than size to consider. The mirror image is what makes this subgroup stands out and we want to find a way to â€śquantifyâ€ť. We will try out based on your suggestions and see what questions we have. Thanks! Jeong

Hi,

Iâ€™m wondering if there is a plug-in or script available in IJ/Fiji that computes SSD (or RMSE) between two images? Also, is there some kind of Mutual Information Score that can be estimated?

I found this thread (Measure mutual information in a video stack) in the forum, but nothing else.

Thanks,
Mauro Morais

1 Like

Hi @mauroccm,

Welcome to the forum,

Itâ€™s easy to make a script that computes ssd.

Mutual information is tricker of course. Hereâ€™s some code that does it, but to use this script (which uses that code) in Fiji, it takes a little extra work at the moment to install the code.

John

2 Likes

@bogovicj

Just a question from a very naive individual regarding such analysesâ€¦ but if things like shape/size of these lesions is the main criteria (as opposed to spatial location, intensity, etc.) - wouldnâ€™t it be ideal to then solely base the analysis on segmented, binarized images? Just found the Shape Filter plugin in ImageJ â€¦ perhaps such a tool could be used as a starting point to get shape features for each image?

These are colleagues of mine that Iâ€™m trying to assist in building a workflowâ€¦ so thank you all for responding with insight on this!

eta

2 Likes

Youâ€™re right, it would be a good idea to use the segmentation and only the segmentation, in this case.

Nice find! That looks like a great place to start, and may be good enough to do the whole job!

John

2 Likes