Skip to content

Commit edf39ab

Browse files
committed
Remove multi-stage tasks
It's simpler and faster this way
1 parent 0d5c5f9 commit edf39ab

File tree

19 files changed

+226
-286
lines changed

19 files changed

+226
-286
lines changed

scijava-ops-api/src/main/java/org/scijava/ops/api/OpEnvironment.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
public interface OpEnvironment extends Prioritized<OpEnvironment> {
6565

6666
/**
67-
* Generates an <b>empty</b> {@link OpEnvironment}, which can be populated with the Ops of the caller's choice.
67+
* Generates an <b>empty</b> {@link OpEnvironment}, which can be populated
68+
* with the Ops of the caller's choice.
69+
*
6870
* @return an empty {@link OpEnvironment}
6971
* @see #build() for an {@link OpEnvironment} that is fully populated
7072
*/
@@ -79,6 +81,7 @@ static OpEnvironment buildEmpty() {
7981

8082
/**
8183
* Generates an {@link OpEnvironment} with all available Ops.
84+
*
8285
* @return an {@link OpEnvironment} with all available Ops.
8386
* @see #buildEmpty() for an {@link OpEnvironment} that is empty
8487
*/
@@ -99,7 +102,8 @@ default SortedSet<OpInfo> infos() {
99102
}
100103

101104
/**
102-
* Obtains all Ops in the {@link OpEnvironment} that are named {@code name}, sorted by priority.
105+
* Obtains all Ops in the {@link OpEnvironment} that are named {@code name},
106+
* sorted by priority.
103107
*
104108
* @param name the {@link String} of all Ops to be returned.
105109
* @return a {@link SortedSet} containing all Ops in the {@link OpEnvironment}
@@ -108,7 +112,8 @@ default SortedSet<OpInfo> infos() {
108112
SortedSet<OpInfo> infos(String name);
109113

110114
/**
111-
* Obtains all Ops in the {@link OpEnvironment} that match {@code hints}, sorted by priority
115+
* Obtains all Ops in the {@link OpEnvironment} that match {@code hints},
116+
* sorted by priority
112117
*
113118
* @param hints the {@link Hints} used to filter available Ops.
114119
* @return a {@link SortedSet} containing all Ops in the {@link OpEnvironment}

scijava-ops-engine/pom.xml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,36 +107,36 @@
107107

108108
<build>
109109
<plugins>
110-
<!-- <plugin>-->
111-
<!-- <artifactId>maven-invoker-plugin</artifactId>-->
112-
<!-- <version>${maven-invoker-plugin.version}</version>-->
113-
<!-- <configuration>-->
114-
<!-- &lt;!&ndash; <debug>true</debug> &ndash;&gt;-->
115-
<!-- <showErrors>true</showErrors>-->
116-
<!-- <properties>-->
117-
<!-- <scijava-maven.version>${project.version}</scijava-maven.version>-->
118-
<!-- </properties>-->
119-
<!-- <projectsDirectory>src/it</projectsDirectory>-->
120-
<!-- <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>-->
121-
<!-- <pomIncludes>-->
122-
<!-- <pomInclude>*/pom.xml</pomInclude>-->
123-
<!-- </pomIncludes>-->
124-
<!-- <settingsFile>src/it/settings.xml</settingsFile>-->
125-
<!-- <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>-->
126-
<!-- <goals>-->
127-
<!-- <goal>install</goal>-->
128-
<!-- </goals>-->
129-
<!-- </configuration>-->
130-
<!-- <executions>-->
131-
<!-- <execution>-->
132-
<!-- <id>integration-test</id>-->
133-
<!-- <goals>-->
134-
<!-- <goal>install</goal>-->
135-
<!-- <goal>run</goal>-->
136-
<!-- </goals>-->
137-
<!-- </execution>-->
138-
<!-- </executions>-->
139-
<!-- </plugin>-->
110+
<plugin>
111+
<artifactId>maven-invoker-plugin</artifactId>
112+
<version>${maven-invoker-plugin.version}</version>
113+
<configuration>
114+
<!-- <debug>true</debug> -->
115+
<showErrors>true</showErrors>
116+
<properties>
117+
<scijava-maven.version>${project.version}</scijava-maven.version>
118+
</properties>
119+
<projectsDirectory>src/it</projectsDirectory>
120+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
121+
<pomIncludes>
122+
<pomInclude>*/pom.xml</pomInclude>
123+
</pomIncludes>
124+
<settingsFile>src/it/settings.xml</settingsFile>
125+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
126+
<goals>
127+
<goal>install</goal>
128+
</goals>
129+
</configuration>
130+
<executions>
131+
<execution>
132+
<id>integration-test</id>
133+
<goals>
134+
<goal>install</goal>
135+
<goal>run</goal>
136+
</goals>
137+
</execution>
138+
</executions>
139+
</plugin>
140140
</plugins>
141141
</build>
142142

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static <I extends RealType<I>> void execute(
9595

9696
LoopBuilder.setImages(oldsqrtN).multiThreaded().forEachPixel(t -> t
9797
.setOne());
98-
Progress.setStageMax(TU);
98+
Progress.defineTotal(TU);
9999
for (int s = 0; s < TU; s++) {
100100
intSize = (int) Math.floor(size);
101101
singleiteration(image1, image2, thres1, thres2, stop, oldtau, oldsqrtN,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public void compute(final RandomAccessibleInterval<I> image1,
102102
}
103103

104104
// set seed, compute thresholds and create empty result if necessary
105-
Progress.defineTotalProgress(1);
106105
if (seed == null) seed = 0xdeadbeefL;
107106
if (thres1 == null) thres1 = otsuOp.apply(histOp.apply(Views.iterable(
108107
image1)));

scijava-ops-image/src/main/java/org/scijava/ops/image/copy/Copiers.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ public static <T> void copyRAI( //
8989
final RandomAccessibleInterval<T> copy //
9090
) {
9191
ensureEqualDimensions(input, copy);
92-
LoopBuilder.setImages(input, copy).multiThreaded().forEachPixel(copier::compute);
92+
LoopBuilder.setImages(input, copy).multiThreaded().forEachPixel(
93+
copier::compute);
9394
}
9495

9596
/**

scijava-ops-image/src/main/java/org/scijava/ops/image/deconvolve/PadAndRichardsonLucy.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public class PadAndRichardsonLucy<I extends RealType<I> & NativeType<I>, O exten
9393
@OpDependency(name = "filter.createFFTOutput")
9494
private Functions.Arity3<Dimensions, C, Boolean, RandomAccessibleInterval<C>> createOp;
9595

96-
@OpDependency(name = "deconvolve.richardsonLucy")
96+
@OpDependency(name = "deconvolve.richardsonLucy", hints = {
97+
"progress.TRACK" })
9798
private Computers.Arity12<RandomAccessibleInterval<I>, RandomAccessibleInterval<K>, //
9899
RandomAccessibleInterval<C>, RandomAccessibleInterval<C>, Boolean, //
99100
Boolean, C, Integer, Boolean, //
@@ -121,10 +122,10 @@ public class PadAndRichardsonLucy<I extends RealType<I> & NativeType<I>, O exten
121122
*/
122123
@Override
123124
public RandomAccessibleInterval<O> apply(RandomAccessibleInterval<I> input,
124-
RandomAccessibleInterval<K> kernel, O outType, C complexType,
125-
Integer maxIterations, @Nullable Boolean nonCirculant,
126-
@Nullable Boolean accelerate, @Nullable long[] borderSize,
127-
@Nullable OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput)
125+
RandomAccessibleInterval<K> kernel, O outType, C complexType,
126+
Integer maxIterations, @Nullable Boolean nonCirculant,
127+
@Nullable Boolean accelerate, @Nullable long[] borderSize,
128+
@Nullable OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput)
128129
{
129130
// default to circulant
130131
if (nonCirculant == null) {
@@ -140,11 +141,11 @@ public RandomAccessibleInterval<O> apply(RandomAccessibleInterval<I> input,
140141
if (obfInput == null) {
141142
if (nonCirculant) {
142143
obfInput = new OutOfBoundsConstantValueFactory<>(Util
143-
.getTypeFromInterval(input).createVariable());
144+
.getTypeFromInterval(input).createVariable());
144145
}
145146
else {
146147
obfInput = new OutOfBoundsMirrorFactory<>(
147-
OutOfBoundsMirrorFactory.Boundary.SINGLE);
148+
OutOfBoundsMirrorFactory.Boundary.SINGLE);
148149
}
149150
}
150151

@@ -165,7 +166,7 @@ public RandomAccessibleInterval<O> apply(RandomAccessibleInterval<I> input,
165166
// if no border size was passed in, then extend based on kernel size
166167
for (int d = 0; d < numDimensions; ++d) {
167168
paddedSize[d] = (int) input.dimension(d) + (int) kernel.dimension(d) -
168-
1;
169+
1;
169170
}
170171

171172
}
@@ -174,24 +175,23 @@ public RandomAccessibleInterval<O> apply(RandomAccessibleInterval<I> input,
174175
for (int d = 0; d < numDimensions; ++d) {
175176

176177
paddedSize[d] = Math.max(kernel.dimension(d) + 2 * borderSize[d], input
177-
.dimension(d) + 2 * borderSize[d]);
178+
.dimension(d) + 2 * borderSize[d]);
178179
}
179180
}
180181

181-
Progress.defineTotalProgress(0, 3);
182+
Progress.defineTotal(0, 1);
182183
RandomAccessibleInterval<I> paddedInput = padOp.apply(input,
183-
new FinalDimensions(paddedSize), true, obfInput);
184+
new FinalDimensions(paddedSize), true, obfInput);
184185

185186
RandomAccessibleInterval<K> paddedKernel = padKernelOp.apply(kernel,
186-
new FinalDimensions(paddedSize));
187+
new FinalDimensions(paddedSize));
187188

188189
computeFilter(input, kernel, paddedInput, paddedKernel, output, paddedSize,
189-
complexType, accelerate);
190+
complexType, accelerate);
190191

191192
return output;
192193
}
193194

194-
195195
/**
196196
* create a richardson lucy filter
197197
*/

scijava-ops-image/src/main/java/org/scijava/ops/image/deconvolve/PadAndRichardsonLucyTV.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.scijava.function.Inplaces;
5151
import org.scijava.ops.spi.Nullable;
5252
import org.scijava.ops.spi.OpDependency;
53+
import org.scijava.progress.Progress;
5354

5455
/**
5556
* Richardson Lucy with total variation function op that operates on (@link
@@ -96,7 +97,8 @@ public class PadAndRichardsonLucyTV<I extends RealType<I> & NativeType<I>, O ext
9697
@OpDependency(name = "filter.createFFTOutput")
9798
private Functions.Arity3<Dimensions, C, Boolean, RandomAccessibleInterval<C>> createOp;
9899

99-
@OpDependency(name = "deconvolve.richardsonLucy", hints = {"progress.TRACK"})
100+
@OpDependency(name = "deconvolve.richardsonLucy", hints = {
101+
"progress.TRACK" })
100102
private Computers.Arity12<RandomAccessibleInterval<I>, RandomAccessibleInterval<K>, //
101103
RandomAccessibleInterval<C>, RandomAccessibleInterval<C>, Boolean, //
102104
Boolean, C, Integer, Boolean, //
@@ -216,6 +218,8 @@ public RandomAccessibleInterval<O> apply(RandomAccessibleInterval<I> input,
216218
this.nonCirculant = nonCirculant;
217219
}
218220

221+
Progress.defineTotal(0, 1);
222+
219223
// out of bounds factory will be different depending on if circulant or
220224
// non-circulant is used
221225
if (obfInput == null) {

scijava-ops-image/src/main/java/org/scijava/ops/image/deconvolve/RichardsonLucyC.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ public void compute(RandomAccessibleInterval<I> in, //
166166
AccelerationState<O> state = new AccelerationState<>(raiExtendedEstimate);
167167

168168
// -- perform iterations --
169-
Progress.defineTotalProgress(1);
170-
Progress.setStageMax(maxIterations);
169+
Progress.defineTotal(maxIterations);
171170
for (int i = 0; i < maxIterations; i++) {
172171
// create reblurred by convolving kernel with estimate
173172
// NOTE: the FFT of the PSF of the kernel has been passed in as a

scijava-ops-image/src/main/java/org/scijava/ops/image/deconvolve/RichardsonLucyCorrection.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,19 @@ public class RichardsonLucyCorrection<I extends RealType<I>, O extends RealType<
7575
// @OpDependency(name = "math.divide") TODO: match an Op here?
7676
private BiConsumer<RandomAccessibleInterval<O>, RandomAccessibleInterval<I>> divide =
7777
(denomResult, numer) -> {
78-
LoopBuilder.setImages(denomResult, numer).multiThreaded().forEachChunk(chunk -> {
79-
final O tmp = Util.getTypeFromInterval(denomResult).createVariable();
80-
chunk.forEachPixel((d, n) -> {
81-
if (d.getRealFloat() > 0) {
82-
tmp.setReal(n.getRealFloat());
83-
tmp.div(d);
84-
d.set(tmp);
85-
}
86-
else d.setZero();
78+
LoopBuilder.setImages(denomResult, numer).multiThreaded().forEachChunk(
79+
chunk -> {
80+
final O tmp = Util.getTypeFromInterval(denomResult).createVariable();
81+
chunk.forEachPixel((d, n) -> {
82+
if (d.getRealFloat() > 0) {
83+
tmp.setReal(n.getRealFloat());
84+
tmp.div(d);
85+
d.set(tmp);
86+
}
87+
else d.setZero();
88+
});
89+
return null;
8790
});
88-
return null;
89-
});
9091
};
9192

9293
@OpDependency(name = "filter.correlate")

scijava-ops-image/src/test/java/org/scijava/ops/image/AbstractOpTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
import java.net.URL;
3333
import java.util.stream.StreamSupport;
3434

35+
import org.scijava.ops.api.Hints;
3536
import org.scijava.ops.api.OpEnvironment;
37+
import org.scijava.ops.engine.BaseOpHints;
3638
import org.scijava.ops.spi.Op;
3739

3840
import io.scif.img.IO;
@@ -64,6 +66,10 @@ public abstract class AbstractOpTest {
6466

6567
protected static final OpEnvironment ops = OpEnvironment.build();
6668

69+
static {
70+
ops.setDefaultHints(new Hints(BaseOpHints.Progress.TRACK));
71+
}
72+
6773
private int seed;
6874

6975
private int pseudoRandom() {

0 commit comments

Comments
 (0)