Define the problem

Brightfield analyses in QuPath

Define the problem - choose a final output measurement first.

For these images I have chosen to be interested in the percentage of heavily eosin stained (will call it fibrotic for this analysis, though I am not a pathologist and am not even sure what tissue type this is) out of the entire tissue slice, and the ratio of cells within the fibrotic and non-fibrotic regions, excluding the heavily hematoxylin stained areas.

The analysis will require several measurements, not all of which will be needed at the end:

  1. Total area of the tissue slice

  2. Area of Background (slide)

  3. Area of heavy hematoxylin staining

  4. Area of fibrosis

  5. Area of other tissue

  6. Cell count in Other tissue

  7. Cell count in fibrotic area

  8. Percentage of elongated tissue in each region with cells

  9. Bonus: Excluded area due to folds or tissue damage?

Rough measurement-based steps could be as follows:

  1. Create a Tissue thresholder to locate the tissue of interest, vs background.

  2. Within the Tissue areas, use a pixel classifier to find fibrotic, “normal,” and hematoxylin heavy areas (*possibly damaged tissue)

  3. Once the Tissue has been subdivided, select the fibrotic and normal tissue regions to run cell detection.

  4. Run a cell classifier within each region. In this case I will choose elongated vs round nuclear shapes.

Regions.PNG
 

With these steps laid out, we should select a test set of images to perform steps like determining thresholds for positivity. I will use Tile 4.ome.tif and Tile 1.ome.tif as I already noticed that tile 4 has a tissue fold on it, which will be useful for the pixel classifier training. Tile 1 will help ensure a minimum size threshold is set so as not to include extra bits of tissue.

It is also important to figure out at this point how detailed of an analysis you want to perform, and what level of error you can accept. In order to make the analysis in this example workable across a variety of computers, I will use moderate resolutions for all of my classifiers. This choice decreases my accuracy, but increases the speed at which the scripts in the demo project will run. If your computer can handle it, I encourage you to go through all of the steps with a higher resolution to try to refine your results.

In the real world, tradeoffs might be slightly different. Turnaround speed might be important in some clinical settings, but the tradeoffs in analysis tend to be things more like losing broad features when zooming in to detect the small features. QuPath only supports up to 8x8 pixel filters based on the Pixel classifier base resolution, meaning you sometimes need to choose between large features and finder details. Alternatively, you might try sequentially higher resolution Pixel classifiers that can be run within lower resolution pixel classifiers, much like we will run a Pixel classifier within a Thresholder.

symbol Rant on image analysis abuse

Please do not run through your whole data set with different settings and algorithms until you find settings that “prove” what you want to find. That is not science, that is the equivalent of p-hacking or other statistical manipulations, and yet many people do not realize it is wrong because “they just want to show the difference they see.” You may be able to come up with very creative and novel correlations via non-hypothesis driven research, but that is not the same as attempting to prove anything.

Both the human mind and machine learning tools are very good at finding patterns, even if none of them are biologically relevant. That is why you need to determine your hypothesis and methods prior to testing on your data, not adjust your settings continuously until you get the answer you wanted. Many failed drugs and unreproducible studies are probably the result of just such a lack of experimental design.
The reasoning is the same as for using Validation sets when training Deep Learning models. DL models can easily overfit the data, and appear to give very good results on certain data sets - but then they do not do well on other data sets or “in the wild” because they did not actually learn what the designer thought that they learned. The fact that a particular model is coming to the answer that you want does not mean that it is doing so correctly! Billions of dollars have probably been wasted on poorly designed experiments, so please be careful!
https://en.wikipedia.org/wiki/Overfitting
As the image analyst, you can just as easily overfit your project with thresholds, sigmas, and carefully picked measurement choices as any deep learning model can overfit its training data.
If you have discovered your hypothesis by iterating through image analysis methods, that is just fine! But you have not proven anything until you test that method or hypothesis on new data, that was not part of the way the method or hypothesis was determined.