You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ops/doc/WritingYourOwnOpPackage.md
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -278,37 +278,51 @@ class DoubleSizeOp implements Function<double[], Double> {
278
278
279
279
### Defining Op Progress
280
280
281
-
By adding the `scijava-progress` module, your Op can define and update its progress, providing user value for long-running Ops. To add progress to your Op, you must add the following steps to your Op:
281
+
The `scijava-progress` module provides a mechanism for long-running tasks to describe their progress through textual or graphical means. For example, `scijava-progress` enables [Fiji](https://fiji.sc/) users to observe the progress of every Op invoked within the application, as shown below.
282
+
283
+
<figure>
284
+
<imgsrc="https://media.scijava.org/scijava-ops/1.0.0/scijava_progress_example.png"alt="scijava-progress updates within Fiji"/>
285
+
<figcaption><em>scijava-progress provides updates from all Op executions within Fiji's `Tasks` pane. </em></figcaption>
286
+
</figure>
287
+
288
+
While all Ops emit "binary" progress (denoting each Op's beginning and end), your Op can provide richer updates by adding the `scijava-progress` module, providing user value for long-running Ops. To add progress to your Op, you must add the following steps to your Op:
289
+
282
290
* Before any significant computation, add the line `Progress.defineTotal(long elements)` where `elements` is the number of "discrete packets" of computation.
283
291
* At convenient spots within your Op, call `Progress.update()` to denote that one packet of computation has finished.
284
292
***Alternatively**, it may be more convenient or performant to call `Progress.update(long numElements)` to denote `numElements` packets have completed at once.
If your Op defines Op dependencies whose progress you'd like to include in your total progress, you can make the following changes.
306
-
* For each Op dependency that you want to track, pass the Hint `"progress.TRACK"` within the `@OpDependency` annotation.
318
+
If your want to include the progress of Op dependencies within your Op's total progress, you can make the following changes.
319
+
* For each Op dependency that you want to track, pass the Hint `"progress.TRACK"` within the `@OpDependency` annotation. Note that it is **not** necessary for each Op to explicitly define its progress, but if it does so your Op will provide richer progress updates!
307
320
* Replace `Progress.defineTotal(long elements)` with `Progress.defineTotal(long elements, long subTasks)`, where `subTasks` is the **total** number of times you will invoke Op dependencies annotated with `"progress.TRACK"`.
308
321
309
322
310
323
```java
311
-
324
+
importjava.util.function.Function;
325
+
importorg.scijava.progress.Progress;
312
326
importorg.scijava.ops.spi.OpDependency;
313
327
314
328
/**
@@ -336,6 +350,8 @@ class DoubleMeanOp implements Function<double[], Double> {
336
350
}
337
351
```
338
352
353
+
For best results, ensure your Op records Progress updates at a reasonable frequency. If too frequent, progress updates can detract from algorithm performance, and if too infrequent, they will be of little help to the user!
354
+
339
355
### Element-wise Ops
340
356
341
357
Simple pixel-wise operations like addition, inversion, and more can be written on a single pixel (i.e. `RealType`) - therefore, SciJava Ops Image takes care to automagically adapt pixel-wise Ops across a wide variety of image types. If you would like to write a pixel-wise Op, we recommend the following structure.
0 commit comments