Skip to content

Commit f808ad1

Browse files
committed
Add check for NaN results and set to 0
Shulei's original SACA code also sets NaN's to 0.
1 parent b01bb1a commit f808ad1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scijava-ops-image/src/main/java/org/scijava/ops/image/coloc/saca/WtKendallTau.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
package org.scijava.ops.image.coloc.saca;
3131

32+
import java.lang.Double;
3233
import java.util.Arrays;
3334
import java.util.Comparator;
3435
import java.util.Random;
@@ -67,7 +68,14 @@ public static double calculate(final double[] X, final double[] Y,
6768
final double swap = sort(rankedindex, rankedw, Integer::compare, index1,
6869
index2, w1, w2, cumw);
6970
final double tw = totw(W) / 2;
70-
final double tau = (tw - 2 * swap) / tw;
71+
72+
// compute tau and check for NaN results
73+
double tauTemp = (tw - 2 * swap) / tw;
74+
if (Double.isNaN(tauTemp)) {
75+
tauTemp = 0.0;
76+
}
77+
78+
final double tau = tauTemp;
7179

7280
return tau;
7381
}

0 commit comments

Comments
 (0)