Skip to content

Commit 2ce8279

Browse files
committed
DefaultPValue: type Op on RAIs, not Iterables
1 parent 024f6ff commit 2ce8279

1 file changed

Lines changed: 17 additions & 21 deletions

File tree

‎src/main/java/net/imagej/ops/coloc/pValue/DefaultPValue.java‎

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import net.imagej.ops.coloc.ShuffledView;
4040
import net.imglib2.Cursor;
4141
import net.imglib2.Dimensions;
42-
import net.imglib2.IterableInterval;
4342
import net.imglib2.RandomAccess;
4443
import net.imglib2.RandomAccessibleInterval;
4544
import net.imglib2.img.Img;
@@ -51,8 +50,6 @@
5150
import org.scijava.ops.OpDependency;
5251
import org.scijava.ops.core.Op;
5352
import org.scijava.ops.function.Computers;
54-
import org.scijava.ops.function.Computers;
55-
import org.scijava.ops.function.Computers;
5653
import org.scijava.param.Mutable;
5754
import org.scijava.param.Parameter;
5855
import org.scijava.plugin.Plugin;
@@ -75,23 +72,22 @@
7572
@Parameter(key = "executorService")
7673
@Parameter(key = "output", itemIO = ItemIO.BOTH)
7774
public class DefaultPValue<T extends RealType<T>, U extends RealType<U>> implements
78-
Computers.Arity7<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<Iterable<T>, Iterable<U>, Double>, Integer, Dimensions, Long, ExecutorService, PValueResult> {
75+
Computers.Arity7<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, Double>, Integer, Dimensions, Long, ExecutorService, PValueResult> {
7976

8077
@Override
8178
public void compute(final RandomAccessibleInterval<T> image1, final RandomAccessibleInterval<U> image2,
82-
final BiFunction<Iterable<T>, Iterable<U>, Double> op, final Integer nrRandomizations,
83-
final Dimensions psfSize, final Long seed, final ExecutorService es, final PValueResult output) {
79+
final BiFunction<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, Double> op,
80+
final Integer nrRandomizations, final Dimensions psfSize, final Long seed, final ExecutorService es,
81+
final PValueResult output) {
8482
final int[] blockSize = blockSize(image1, psfSize);
8583
final RandomAccessibleInterval<T> trimmedImage1 = trim(image1, blockSize);
8684
final RandomAccessibleInterval<U> trimmedImage2 = trim(image2, blockSize);
8785
final T type1 = Util.getTypeFromInterval(image1);
8886

8987
final double[] sampleDistribution = new double[nrRandomizations];
90-
final IterableInterval<T> iterableImage1 = Views.iterable(trimmedImage1);
91-
final IterableInterval<U> iterableImage2 = Views.iterable(trimmedImage2);
9288

9389
// compute actual coloc value
94-
final double value = op.apply(iterableImage1, iterableImage2);
90+
final double value = op.apply(trimmedImage1, trimmedImage2);
9591

9692
// compute shuffled coloc values in parallel
9793
int threadCount = Runtime.getRuntime().availableProcessors(); // FIXME: conform to Ops threading strategy...
@@ -123,7 +119,7 @@ public void compute(final RandomAccessibleInterval<T> image1, final RandomAccess
123119
if (i > 0)
124120
shuffled.shuffleBlocks(seeds[index]);
125121
copy(shuffled, buffer);
126-
sampleDistribution[index] = op.apply(buffer, iterableImage2);
122+
sampleDistribution[index] = op.apply(buffer, trimmedImage2);
127123
}
128124
}));
129125
}
@@ -203,17 +199,17 @@ private static <V> RandomAccessibleInterval<V> trim(final RandomAccessibleInterv
203199
@Parameter(key = "executorService")
204200
@Parameter(key = "output", itemIO = ItemIO.BOTH)
205201
class PValueSimpleWithRandomizations<T extends RealType<T>, U extends RealType<U>> implements
206-
Computers.Arity5<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<Iterable<T>, Iterable<U>, Double>, Integer, ExecutorService, PValueResult> {
207-
202+
Computers.Arity5<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, Double>, Integer, ExecutorService, PValueResult> {
203+
208204
@OpDependency(name = "coloc.pValue")
209-
private Computers.Arity7<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<Iterable<T>, Iterable<U>, Double>, Integer, Dimensions, Long, ExecutorService, PValueResult> pValueOp;
205+
private Computers.Arity7<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, Double>, Integer, Dimensions, Long, ExecutorService, PValueResult> pValueOp;
210206

211207
@Override
212208
public void compute(RandomAccessibleInterval<T> in1, RandomAccessibleInterval<U> in2,
213-
BiFunction<Iterable<T>, Iterable<U>, Double> in3, Integer in4, ExecutorService in5,
214-
@Mutable PValueResult out) {
209+
BiFunction<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, Double> in3, Integer in4,
210+
ExecutorService in5, @Mutable PValueResult out) {
215211
Long defaultSeed = 0x27372034l;
216-
pValueOp.compute(in1, in2, in3, in4, null, defaultSeed,in5, out);
212+
pValueOp.compute(in1, in2, in3, in4, null, defaultSeed, in5, out);
217213
}
218214

219215
}
@@ -225,17 +221,17 @@ public void compute(RandomAccessibleInterval<T> in1, RandomAccessibleInterval<U>
225221
@Parameter(key = "executorService")
226222
@Parameter(key = "output", itemIO = ItemIO.BOTH)
227223
class PValueSimple<T extends RealType<T>, U extends RealType<U>> implements
228-
Computers.Arity4<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<Iterable<T>, Iterable<U>, Double>, ExecutorService, PValueResult> {
229-
224+
Computers.Arity4<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, Double>, ExecutorService, PValueResult> {
225+
230226
@OpDependency(name = "coloc.pValue")
231-
private Computers.Arity5<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<Iterable<T>, Iterable<U>, Double>, Integer, ExecutorService, PValueResult> pValueOp;
227+
private Computers.Arity5<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, BiFunction<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, Double>, Integer, ExecutorService, PValueResult> pValueOp;
232228

233229
@Override
234230
public void compute(RandomAccessibleInterval<T> in1, RandomAccessibleInterval<U> in2,
235-
BiFunction<Iterable<T>, Iterable<U>, Double> in3, ExecutorService in4, @Mutable PValueResult out) {
231+
BiFunction<RandomAccessibleInterval<T>, RandomAccessibleInterval<U>, Double> in3, ExecutorService in4,
232+
@Mutable PValueResult out) {
236233
Integer defaultNumberRandomizations = 100;
237234
pValueOp.compute(in1, in2, in3, defaultNumberRandomizations, in4, out);
238235
}
239236

240237
}
241-

0 commit comments

Comments
 (0)