Very briefly, it takes two measurements that exist in your population of detections (selected by drop-down menus), all classes or one as a subset of those detections, and then calculates a best fit line and R-squared value for the resulting data point pairs. The script also provides a plot of those data points (plot axis values are determined by min/max values and cannot be changed at this time), along with the option to save to csv all of the calculations you have made since starting the script. The calculations will be saved to the project folder within a subfolder called “R-squared results.”
Always do be careful with R-squared values as not all relationships in your data will be linear, and this is based off of a best fit line. A plot is always generated, so do take a moment to look at it!
The interface is in the upper left hand corner in the picture and consists of the two drop down menus for selecting measurements, the class dropdown and all classes checkbox (which overrides any selected class), and the calculate button that makes it all go. Any time you click Calculate, a new plot will be created, and a line will be added to an array that keeps track of every result you have calculated. If you decide you want a list of those results, you can click Export all calculations to CSV when you are done, and go and collect the results!
In this example, I just picked some fairly random values to see if anything was strongly correlated (I didn’t expect anything to be), and then threw in a comparison of the nuclear area and perimeter to prove that everything was actually working.
Please do let me know if you run into any issues with the code, but so far it seems to work for both main versions of QuPath, though the file name for the export changes slightly. Suggestions welcome for ways to improve the code, or take it and run with it
If you want the data points to plot in something more configurable, I recommend using something like:
saveDetectionMeasurements("C://Path//To//nowhere.txt", "Nucleus: Area", "Nucleus: Circularity")