R-squared and slope between channels, per channel

Quick bit of code that does mostly what the title says, though I want to emphasize that this is purely PIXEL based, not measurement based. It is checking all of the pixels within the annotations for how highly correlated the different channels are.
Draw an annotation (probably not the whole image, that will kill the script) over a small area.
Run the script.
Depending on the “cutoff” value in the script, measurements will be added for all combinations of channels with an R^2 above that cutoff.
For example, here at the edge of this tissue, I can see what is most likely a fixation artifact.

Running the script shows which channels (by number) have an R^2 over 0.5, and provides their slope so that I can see if the correlation is positive or negative.

Quick way to detect bleedthrough or surprising amounts of correlation in highly multiplexed projects. Script could be fairly easily adjusted to run for detections instead, or to include actual channel names. I went with channel numbers because some channel names can be long and make reading the measurement table a pain.

Not intended as medical advice.