fiji / Colocalisation_Analysis

Fiji's plugin for colocalization analysis
http://imagej.net/Coloc_2
GNU General Public License v3.0
24 stars 18 forks source link

Need to add input data check for non physical negative values #48

Closed haesleinhuepf closed 7 years ago

haesleinhuepf commented 7 years ago

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

ctrueden commented 7 years ago

Thanks for the report, and for looking into the fix, @haesleinhuepf. I think that unfortunately, the people involved in maintaining this component (@tomka, @chalkie666, @etarena) might be too busy to help much, but I mention them here in case they have any time or insight to help.

I will also try to help review any PR you file, in a quasi-timely manner.

chalkie666 commented 7 years ago

@haesleinhuepf. Negative values make no sense to the maths here: basic assumption is that pixel claims are proportional to detected photons. Negative photons don't exist. So you need to think why you have negative values ... Likely these are artifacts and might need to be clamped to zero. It if not artifacts, you should add a constant to all the pixels to shift them up to zero or above.

Does it make sense? I can cone see you when silke and I get back from holiday.

haesleinhuepf commented 7 years ago

@chalkie666 thanks for pointing me to that. I could imagine, the user did some background removal. That may have led to negative values. What do you think: wouldn't it make sense to build in a negative-values check at the very beginning to warn users in case they do colocalisation analysis with images with negative values? Enjoy your holiday! :-)

chalkie666 commented 7 years ago

@haesleinhuepf I agree a check for negative values is a good idea because it forces a major assumption check. There are a bunch of input data suitability checks in one of the code files. It should be added there. If you don't want to do it yourself, we can leave this issue open and tag it appropriately. Of course a pull request with a fix would be awesomest! Can we change the name if the issue to something like. Need to add input data check for non physical negative values. ?

haesleinhuepf commented 7 years ago

Yes, we can. I'll file the pull request asap. As said: Enjoy your free time! :-)