GithubHelp home page GithubHelp logo

fiji / colocalisation_analysis Goto Github PK

View Code? Open in Web Editor NEW
24.0 19.0 18.0 1.58 MB

Fiji's plugin for colocalization analysis

Home Page: http://imagej.net/Coloc_2

License: GNU General Public License v3.0

Java 98.90% Groovy 0.33% ImageJ Macro 0.77%

colocalisation_analysis's Introduction

developer chat

Colocalisation Analysis

Coloc 2 is Fiji's plugin for colocalization analysis. It implements and performs the pixel intensity correlation over space methods of Pearson, Manders, Costes, Li and more, for scatterplots, analysis, automatic thresholding and statistical significance testing.

Also included here are the old no longer supported plugins: Colocalization Threshold and Colocalization Test We only use these for comparison with Coloc_2, and don't suggest you actually use them for real work.

For more details, see http://imagej.net/Coloc_2

colocalisation_analysis's People

Contributors

chalkie666 avatar ctrueden avatar dscho avatar etadobson avatar gitter-badger avatar hinerm avatar imagejan avatar lguizzetti avatar nafisahis avatar tinevez avatar tomka avatar willgiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colocalisation_analysis's Issues

Input GUI v2: general idea

make a new input GUI, that is all imageJ2, replacing IJ1 gerneric dialog stuff with however imageJ2 should do, it... swing. Some general inspiration from JACoP would be good.

The Inpu tGUI should deal with settnig all the input parameters, and not bother with eg. images display,

But could display image parameters that are under 1 sec to calculate, eg mean, max, min, and perform the input data sanity checks and show red flags for stuff that is missing or easy/fast to detect as bad.

Results: break up potentially very long text of 1st line of results, label field

its easy to get for instance
Colocalization_of_colocsample1b-green.tif_versus_colocsample1b-red.tif_1827000661
-1

which then doesn't wrap in the HTML table field of the SingleWindowDisplay implementation of ResultsHandler. In the PDF and log window it doesn't matter... but hard to see in the log window perhaps without making it big. It could be so big that it runs off the edge of the screen....

But we want a single string, for further data processing... and spaces would be hard to handle downstream..... so is there a way to make the text in an HTML table field wrap after a certain number of characters?

Perhaps this will do the job?

<style> table {border-collapse:collapse; table-layout:fixed; width:310px;} table td {border:solid 1px #fab; width:100px; word-wrap:break-word;} </style>

Results: warnings are not listed in the log window

but they should be, like for all other results output methods.

Perhaps need to make the log window output a real ResultsHandler implementation that is always run (or user selectable), rather than a hacked on set of IJ.log statements in loops.?

Results: Bug: Large images don't fit in results display gui, and there are no scroll bars, or z slider

if the input images are large, they don't fit on the 256x256? viewport of SingleWindowDisplay.
There are no scroll bars or zoom possibility, so the only way to see the whole image is to make the SingleWindowDisplay window itself larger.

Minimal fix here is to implement a zoom slider... and/or resize the window to try to fit the input images in,

and while we are at it, the z slider is also missing.

Adding a Manual Threshold Mode

Hi
I am forking the repo and am aiming to implement the possibility to add a manual threshold to the images.
The Autothreshold method is not useful in a lot of coloc experiments and fails in the case of negative controls or conditions where colocalization is not expected.
Makes sense, as it looks for correlation until there is none left to the left of the thresholds, but when there is either constant correlation or no correlation at all, the thresholds can be either too high or too low.

Also, Manders Coefficients, and other metrics not related to correlation still yield very useful information when looking at co-occurrence and not co-localization, but can be hard to interpret due to potentially very different thresholds being found.

Another thing we have tested is the use of independent auto-thresholds for each image (from ImageJ's auto-threshold list)

For example, suppose we want to check the association between some vesicule marker and a protein of interest. Not all vesicles might contain the protein, only some, so correlation is not very interesting nor warranted for this, but Manders can be helpful (barring other conditions beyond the scope of this example are met). Due to expression changes/microscope component stability, sample age or timepoint, a fixed threshold would not yield acceptable results, but we found a threshold that adjusts itself helps narrow the error margins.

That being said, I'm looking at how to get this to work.

Seeing the current implementation, all Algorithms that use a threshold call the
AutoThresholdRegression<T> autoThreshold = container.getAutoThreshold();
https://github.com/fiji/Colocalisation_Analysis/blob/master/src/main/java/sc/fiji/coloc/algorithms/MandersColocalization.java#L157

So I'd need a way to store the threshold values somewhere, which would mean making a static function, but that is not the Ops way...

So I am thinking of setting a threshold on the images (whatever it may be) externally from Coloc2 and have Coloc2 just apply that threshold if it is present. Does that make sense?

So in order to do that, I should threshold the image, create a 'mask', which when fed into coloc 2, should give me the desired result?

Results Dashboard v2: General plan

The SingleWindowDisplay implementation of Results handler is the current default way to see results - it was only supposed to be a get working prototype.

This issue is to figure out the replacement (hence "v2")

What it should do / be

  1. one large resizable window containing several views of images and results
  2. could integrate a 3D viewer windows
  3. could have tricks like select a part of the 2d histogram and render that in the 2D or 3d viewer

Closing windows created by Coloc2 in macro

Hello,

I have a simple question regarding the "Coloc 2" plugin in FIJI.

Assume I have two images named "tmp0" and "tmp1", when I use the Coloc2, even though I don't check any box on the dialog window, there are two result windows show up. one is the text "Log" window which I use to retrieve the R value. the other is titled "Colocalization tmp1 vs tmp0" which contained similar information as in the "Log" window, this one can also be saved as a pdf file.

My question is how to avoid the "Colocalisation tmp1 vs tmp0" window showing up. When I wrote a macro to batch process, I only need the "Log" window to retrieve information. And in the macro, selectWindow("Coloclisation tmp1 vs tmp0") function can select the window, but neither close() or run("Close") function can close it. This causes a pile-up of such "Colocalization ..." windows at the end of the macro.

Thanks for the help.

Access Log Window Statistics Output by API

As discussed with @ctrueden I'm opening this issue,
thanks for looking into this.

Synopsis:
It would be useful to be able to access all the statistics outputted in the Log Window of ImageJ
by some API functions from Coloc2, then one does not need to try to parse/decipher the Log Window output manually.

It is currently developed on the branch:
https://github.com/fiji/Colocalisation_Analysis/compare/results-api

Algorithms: turn the type interface into a SciJava plugin type

Suggestion from Dscho:
"Turn the analysis type interface into a proper SciJava plugin type. Use that, and eat our own dog food. Nothing in Coloc2 should know about the particular analysis types that are shipped by default."

another issue here that is related to the proposed transfer of from algorithms from coloc2 into ops. see issue #12

Algorithms: ArrayIndex out of bounds: 512x512x46 px, 32 bit images input (184 MB)

@ctrueden an opinion would be great here... then i will do as needed.

two input images - quite large:
512x512x46 px, 32 bit (184 MB)

Looks like a long isnt big enough to count all the pixels?????
Should we use BigInteger?

run coloc_2, in 2D Histograms step get:

(Fiji Is Just) ImageJ 2.0.0-rc-34/1.50a; Java 1.7.0_79 [64-bit]; Linux 3.19.0-21-generic; 2132MB of 2421MB (88%)

java.lang.ArrayIndexOutOfBoundsException: 65538
at net.imglib2.img.basictypeaccess.array.LongArray.getValue(LongArray.java:63)
at net.imglib2.type.numeric.integer.LongType.get(LongType.java:116)
at net.imglib2.type.numeric.integer.LongType.getIntegerLong(LongType.java:133)
at algorithms.Histogram2D.generateHistogramData(Histogram2D.java:207)
at algorithms.LiHistogram2D.execute(LiHistogram2D.java:95)
at Coloc_2.colocalise(Coloc_2.java:447)
at Coloc_2.run(Coloc_2.java:160)
at ij.IJ.runUserPlugIn(IJ.java:212)
at ij.IJ.runPlugIn(IJ.java:176)
at ij.Executer.runCommand(Executer.java:132)
at ij.Executer.run(Executer.java:65)
at java.lang.Thread.run(Thread.java:745)

Results: Missing Features: on 2D histograms in all results handlers, show xy axis labels (ch1, ch2), and the autothreshold level lines

On the 2D histograms in all implementations of ResultsHandler label each channel, so we know which of channel1 and channel 2 is x and which y just by looking at the plot.
Also, auto threshold results lines are missing in all results handlers.
The same annotated final 2D histogram plot should be used in all results handlers, so same output is made. Might need a log and non log version to toggle between.

Results: change 1st line of results, result from -1 to Done or Complete

@tomka added ability to have string resilts , so can now have a string result here: instead of
Colocalization_of_colocsample1b-green.tif_versus_colocsample1b-red.tif_1827000661
-1

to

Colocalization_of_colocsample1b-green.tif_versus_colocsample1b-red.tif_1827000661 Done
or
Colocalization_of_colocsample1b-green.tif_versus_colocsample1b-red.tif_1827000661 Complete
or
Colocalization_of_colocsample1b-green.tif_versus_colocsample1b-red.tif_1827000661 Finished Computing results.

container.getMaskBBSize().length can be larger than 3 in CostesSignificanceTest

(Fiji Is Just) ImageJ 2.0.0-rc-29/1.49s; Java 1.6.0_24 [64-bit]; Linux 3.13.0-49-generic; 1501MB of 2257MB (66%)

java.lang.ArrayIndexOutOfBoundsException: 3
at algorithms.CostesSignificanceTest.execute(CostesSignificanceTest.java:99)
at Coloc_2.colocalise(Coloc_2.java:447)
at Coloc_2.run(Coloc_2.java:160)
at ij.IJ.runUserPlugIn(IJ.java:199)
at ij.IJ.runPlugIn(IJ.java:163)
at ij.Executer.runCommand(Executer.java:131)
at ij.Executer.run(Executer.java:64)
at java.lang.Thread.run(Thread.java:662)

Improve menu functionality

From Ann Wheeler:

menu functionality e.g. selecting what to colocalise and which coefficients are needed. This is implemented in colocalisation threshold (set options checkbox), though this is mathematically weaker than Coloc2 and colocalisation threshold can't colocalise ROIs from the ROI manager.

Migrated-From: http://fiji.sc/bugzilla/show_bug.cgi?id=1100

Results: simplify the Interface : ResultHandler

An idea from Dscho:
"Continue the (good!) idea of ResultHandler, but simplify it first.
eg: Why does every method in ResultHandler repeat that it handles something?"

I see what he means:
void handleWarning(Warning warning);
could just be
void warning(Warning warning);
but maybe that's too little information as method names should be verbs...

so maybe this one is just a matter of taste...
processWarning
dealWithWarning
showWarning
useWarning

or maybe I miss the point...?

Gadgets: Simplify by Factoring out the DataContainer???

Why? Because it is complex and opaque making dev harder, especially for developers who are new to this plugin?

idea from Dscho - run through the de-Torvalds filter:

The DataContainer is cute, if perhaps rather over-engineered.
The makes it hard to sit a new developer (or Dan White) in front of the Coloc2 source code and figure out how its working.
Example: its hard to figure out where the color map is set.
Example: Due to the many indirections in the container, it is pretty tricky debug into it.
(Dan wonders what "indirection" is, and has to check on Wikipedia...)

A solution might be to:
First, make everything explicit (again).
Remove the DataContainer and replace it with direct data flows that are easier to follow and understand, building on the nice ResultHandler idea.
The SingleWindowDisplayand pdf outputter implementations of ResultsHandler are two completely separate things... and should do their own thing, but use the same data.

Turn algorithms into Ops

We want to expose colocalisation functionality in ImageJ Ops. This way individual algorithms can be reused in other contexts (e.g. KNIME), and traditional ImageJ/Fiji functionality will benefit from Ops extensibility.

Algorithms: Change algorithms class into an Interface

Suggestion from Dscho:

"Rethink Algorithm, and perhaps rename it into something that is actually useful. Make it interface-driven. Make sure that the interface is minimal. It is okay to have an abstract base class implementing that interface, but it is not okay to require every analysis type to extend it, that is just a recipe for trouble because it encourages callers to use features that happen to be implementation details, rather than only what the interface defines.

Split the functionality of the Algorithm interface into several aspects:
display is separate from calculating the data,
PDF display is separate from screen output."

This kind of thing is also related to the proposed migration of some general calculations such as Pearsons r from coloc_2 into ops. see issue #12

Input GUI v2: and Results: Improve scriptability

From Ann Wheeler:

This all needs to be scriptable so if one has 100 - 200 images Fiji can munch through them and generate an results file exportable to Excel with:

Columns corresponding to:

Slice, ROI, Threshold, 'My favourite colocalisation coefficient', 'Other colocalisation coefficient', 'AN OTHER parameter as desired'

Rows corresponding to:
Slice 1, ROI1
Slice 1, ROI2
Slice 2, ROI1
Slice 2, ROI2 etc

Not dissimilar to the output of multimeasure for analysing particles. Manders Coefficient and ICQ in IJ1 can do all of this and are scriptable easily.

Migrated-From: http://fiji.sc/bugzilla/show_bug.cgi?id=1100

Need to add input data check for non physical negative values

Hey guys,

I'm getting an error message, when I try to use the Coloc 2 plugin on 32-bit images. Very probably, the issue is related to negative pixel values. This is the error message:

java.lang.ArrayIndexOutOfBoundsException: 71276
   at net.imglib2.img.basictypeaccess.array.LongArray.getValue(LongArray.java:62)
   at net.imglib2.type.numeric.integer.LongType.get(LongType.java:100)
   at net.imglib2.type.numeric.integer.LongType.getIntegerLong(LongType.java:117)
   at algorithms.Histogram2D.generateHistogramData(Histogram2D.java:208)
   at algorithms.LiHistogram2D.execute(LiHistogram2D.java:96)
   at Coloc_2.colocalise(Coloc_2.java:475)
   at Coloc_2.run(Coloc_2.java:172)
   at ij.IJ.runUserPlugIn(IJ.java:217)
   at ij.IJ.runPlugIn(IJ.java:181)
   at ij.Executer.runCommand(Executer.java:137)
   at ij.Executer.run(Executer.java:66)
   at ij.IJ.run(IJ.java:297)
...

and this is a minimal IJ-macro that allows to reproduce the error:

newImage("Untitled", "32-bit random", 50, 50, 1);
newImage("Untitled2", "32-bit random", 50, 50, 1);
run("Subtract...", "value=10000");

run("Coloc 2", "channel_1=Untitled channel_2=Untitled2 roi_or_mask=<None> threshold_regression=Costes li_histogram_channel_1 li_histogram_channel_2 li_icq spearman's_rank_correlation manders'_correlation kendall's_tau_rank_correlation 2d_instensity_histogram costes'_significance_test psf=3 costes_randomisations=10");

I would like to support the bugfix actively, but any hint is welcome. I will in the meantime try to find ouf if helps to change the function Histogram2D.getXValue to take the minimum grey value into account.

Cheers,
Robert

Results: relabel Manders' split coefficient results text to make more informative

current labels are eg.
Manders' M1 (no threshold), 0.995
Manders' M2 (no threshold), 0.996
Manders' M1 (threshold), 0.899
Manders' M2 (threshold), 0.850

suggest

Manders' M1 (Above zero intensity of Ch2), 0.995
Manders' M2 (Above zero intensity of Ch1), 0.996
Manders' M1 (Above autothreshold of Ch2), 0.899
Manders' M2 (Above autothreshold of Ch1), 0.850

Input GUI v2: input image handling

This list is just a start - this issue can hold a discussion about what the future looks like for a fully imageJ2 implementation of the Coloc_2 Input user input interface "Input GUI v2" and what it should be able to do.

  1. allow selection of images that are already opened by imageJ2 via eg bioformats or scifio an in memory as imglib2 objects
  2. allow selection of image files on disk with out necessarily displaying them (perhaps displaying them anyway not a big problem). Drag and drop support?
  3. Allow 2 data channel selection from a multi channel image
  4. Allow a mask image channel selection from a different image file or the same image file as the 2 image data channels.
  5. Set optional analysis methods/displays on or off.

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

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);
}

Exception while trying to use Coloc2

Hi,

Could anybody please help me solve this exception. I am trying to use this in two images with one red channel and another green channel image. I have set both the image type to be RGB colour. I have updated my installation of the software. But still, I get the below error. I am sure there is a simple solution but I am not sure I understand this exception.

Thanks a lot

(Fiji Is Just) ImageJ 2.0.0-rc-61/1.51n; Java 1.8.0_66 [64-bit]; Windows 10 10.0; 70MB of 6032MB (1%)
 
java.lang.ClassCastException: net.imglib2.type.numeric.ARGBType cannot be cast to net.imglib2.type.numeric.RealType
	at net.imglib2.algorithm.math.ImageStatistics.getImageMean(ImageStatistics.java:105)
	at sc.fiji.coloc.gadgets.DataContainer.calculateStatistics(DataContainer.java:230)
	at sc.fiji.coloc.gadgets.DataContainer.<init>(DataContainer.java:127)
	at sc.fiji.coloc.Coloc_2.colocalise(Coloc_2.java:486)
	at sc.fiji.coloc.Coloc_2.colocalise(Coloc_2.java:452)
	at sc.fiji.coloc.Coloc_2.run(Coloc_2.java:176)
	at ij.IJ.runUserPlugIn(IJ.java:217)
	at ij.IJ.runPlugIn(IJ.java:181)
	at ij.Executer.runCommand(Executer.java:137)
	at ij.Executer.run(Executer.java:66)
	at java.lang.Thread.run(Thread.java:745)

Ops: AutoThresholdRegression

Add AutoThresholdRegression (a class implementing the automatice finding of a threshold used for Pearson colocalization calculation) to Ops...

see issue #12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.