Skip to content

Commit ce01ff0

Browse files
gselzerctrueden
authored andcommitted
WIP: LiICQ: Fix OpDependencies, test
TODO: finish fixing test
1 parent 1e9c57b commit ce01ff0

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/main/java/net/imagej/ops/coloc/icq/LiICQ.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public class LiICQ<T extends RealType<T>, U extends RealType<U>, V extends RealT
6262
implements Function4<Iterable<T>, Iterable<U>, DoubleType, DoubleType, Double> {
6363

6464
@OpDependency(name = "stats.mean")
65-
private Computer<Iterable<? extends RealType<?>>, DoubleType> meanOp;
65+
private Computer<Iterable<T>, DoubleType> meanTOp;
66+
@OpDependency(name = "stats.mean")
67+
private Computer<Iterable<U>, DoubleType> meanUOp;
6668

6769
@Override
6870
public Double apply(final Iterable<T> image1, final Iterable<U> image2, final DoubleType mean1, final DoubleType mean2) {
@@ -73,8 +75,8 @@ public Double apply(final Iterable<T> image1, final Iterable<U> image2, final Do
7375

7476
final Iterable<Pair<T, U>> samples = new IterablePair<>(image1, image2);
7577

76-
final double m1 = mean1 == null ? computeMeanOf(image1) : mean1.get();
77-
final double m2 = mean2 == null ? computeMeanOf(image2) : mean2.get();
78+
final double m1 = mean1 == null ? computeMeanTOf(image1) : mean1.get();
79+
final double m2 = mean2 == null ? computeMeanUOf(image2) : mean2.get();
7880

7981
// variables to count the positive and negative results
8082
// of Li's product of the difference of means.
@@ -104,9 +106,14 @@ public Double apply(final Iterable<T> image1, final Iterable<U> image2, final Do
104106
return icqValue;
105107
}
106108

107-
private double computeMeanOf(final Iterable<? extends RealType<?>> in) {
109+
private double computeMeanTOf(final Iterable<T> in) {
110+
DoubleType mean = new DoubleType();
111+
meanTOp.compute(in, mean);
112+
return mean.get();
113+
}
114+
private double computeMeanUOf(final Iterable<U> in) {
108115
DoubleType mean = new DoubleType();
109-
meanOp.compute(in, mean);
116+
meanUOp.compute(in, mean);
110117
return mean.get();
111118
}
112119

src/test/java/net/imagej/ops/coloc/icq/LiICQTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import static org.junit.Assert.assertEquals;
3333
import static org.junit.Assert.assertTrue;
3434

35+
import java.util.concurrent.ExecutorService;
3536
import java.util.function.BiFunction;
3637

3738
import net.imagej.ops.coloc.ColocalisationTest;
@@ -43,6 +44,7 @@
4344
import org.junit.Test;
4445
import org.scijava.ops.types.Nil;
4546
import org.scijava.ops.util.Functions;
47+
import org.scijava.thread.ThreadService;
4648

4749
/**
4850
* Tests {@link net.imagej.ops.Ops.Coloc.ICQ}.
@@ -67,7 +69,7 @@ public void testICQ() {
6769
*/
6870
@Test
6971
public void liPositiveCorrTest() {
70-
final Object icqValue = ops.run("color.icq", positiveCorrelationImageCh1, positiveCorrelationImageCh2);
72+
final Object icqValue = ops.run("coloc.icq", positiveCorrelationImageCh1, positiveCorrelationImageCh2);
7173

7274
assertTrue(icqValue instanceof Double);
7375
final double icq = (Double) icqValue;
@@ -92,6 +94,7 @@ public void liZeroCorrTest() {
9294
*/
9395
@Test
9496
public void testPValue() {
97+
ExecutorService es = context.getService(ThreadService.class).getExecutorService();
9598
final double mean = 0.2;
9699
final double spread = 0.1;
97100
final double[] sigma = new double[] { 3.0, 3.0 };
@@ -102,7 +105,7 @@ public void testPValue() {
102105
BiFunction<Iterable<FloatType>, Iterable<FloatType>, Double> op = Functions.binary(ops, "coloc.icq",
103106
new Nil<Iterable<FloatType>>() {}, new Nil<Iterable<FloatType>>() {}, new Nil<Double>() {});
104107
PValueResult value = new PValueResult();
105-
ops.run("coloc.pValue", ch1, ch2, op, value);
108+
ops.run("coloc.pValue", ch1, ch2, op, es, value);
106109
assertEquals(0.72, value.getPValue(), 0.0);
107110
}
108111

0 commit comments

Comments
 (0)