Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algorithms: add fraction (or %) colocalization by pixels (volxels, area) and intensity #17

Open
chalkie666 opened this issue Jul 31, 2015 · 0 comments
Assignees
Milestone

Comments

@chalkie666
Copy link
Collaborator

add fraction (or %) colocalization by pixels (volxels, area) and intensity,
as per the old colocalization threshold plugin.... but this time with unit tests and clearer code and variable names that are informative.

Might make it fractions (range 0-1) instead of %, to make it consistent eoth Mansers' coefficients.
(but folks do insist on reporting coloc as %.... no idea why)

I thought we would need a new Algorithm implementation class.... but on closer inspection it looks like these measures are really very similar to the split Manders' coefficients. All that's needed are a few more variables to hold and accumulate different values as the TwinCursor traverses the image pixels...

Below is the MandersAccumulator class. I think the required maths is a few lines more code in there, plus some more resultsd handler calls and a few divisions:
Accumulate numbers from different quadrants of the scatterplot according to if above which ever threshold(s) or not. Its just different combinations of which channel's pixel value and which channel's threshold, then a division by the right total at the end. Just like Manders.
see text below from http://www.uhnresearch.ca/facilities/wcif/imagej/colour_analysis.htm

Number of colocalised voxels – Ncoloc
This is the number of voxels which have both channel1 and channel 2 intensities above threshold (i.e., the number of pixels in the yellow area of the scatterplot).

%Image volume colocalised – %Volume
This is the percentage of voxels which have both channel 1 and channel 2 intensities above threshold, expressed as a percentage of the total number of pixels in the image (including zero-zero pixels); in other words, the number of pixels in the scatterplot’s yellow area ÷ total number of pixels in the scatter plot (the Red + Green + Blue + Yellow areas).

%Voxels Colocalised – %Ch1 Vol; %Ch2 Vol
This generates a value for each channel. This is the number of voxels for each channel which have both channel 1 and channel 2 intensities above threshold, expressed as a percentage of the total number of voxels for each channel above their respective thresholds; in other words, for channel 1 (along the x-axis), this equals the (the number of pixels in the Yellow area) ÷ (the number of pixels in the Blue + Yellow areas). For channel 2 this is calculated as follows: (the number of pixels in the Yellow area) ÷ (the number of pixels in the Red + Yellow areas).

%Intensity Colocalised – %Ch1 Int; %Ch2 Int
This generates a value for each channel. For channel 1, this value is equal to the sum of the pixel intensities, with intensities above both channel 1 and channel 2 thresholds expressed as a percentage of the sum of all channel 1 intensities; in other words, it is calculated as follows: (the sum of channel 1 pixel intensities in the Yellow area) ÷ (the sum of channel 1 pixels intensities in the Red + Green + Blue + Yellow areas).

%Intensities above threshold colocalised – %Ch1 Int > thresh; %Ch2 Int > thresh
This generates a value for each channel. For channel 1, this value is equal to the sum of the pixel intensities with intensities above both channel 1 and channel 2 thresholds expressed as a percentage of the sum of all channel 1 intensities above the threshold for channel 1. In other words, it is calculated as follows: (the sum of channel 1 pixel intensities in the Yellow area) ÷ (sum of channel 1 pixels intensities in the Blue + Yellow area)

/**
 * A class similar to the Accumulator class, but more specific
 * to the Manders calculations.
 */
protected abstract class MandersAccumulator {
    double sumCh1, sumCh2, condSumCh1, condSumCh2;
    public MandersAccumulator(TwinCursor<T> cursor) {
        while (cursor.hasNext()) {
            cursor.fwd();
            T type1 = cursor.getFirst();
            T type2 = cursor.getSecond();
            double ch1 = type1.getRealDouble();
            double ch2 = type2.getRealDouble();
            if (accecptCh1(type1, type2))
                condSumCh1 += ch1;
            if (accecptCh2(type1, type2))
                condSumCh2 += ch2;
            sumCh1 += ch1;
            sumCh2 += ch2;
        }
    }
    abstract boolean accecptCh1(T type1, T type2);
    abstract boolean accecptCh2(T type1, T type2);
}
@chalkie666 chalkie666 self-assigned this Jul 31, 2015
@chalkie666 chalkie666 added this to the m1 milestone Aug 4, 2015
@chalkie666 chalkie666 changed the title add fraction (or %) colocalization by pixels (volxels, area) and intensity Algorithms: add fraction (or %) colocalization by pixels (volxels, area) and intensity Aug 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants