Skip to content

Commit bab193d

Browse files
committed
Fiji scripting: add calling from menus section
1 parent f33fa5d commit bab193d

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

‎docs/ops/doc/ScriptingInFiji.md‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
# Scripting in Fiji
22

3-
Using SciJava Ops within scripts unlocks the most powerful aspects of Ops. The following page will explain how you can write a script in Fiji's Script Editor that utilizes Ops for image processing.
3+
Scripts provide a simple, familiar interface for accessing SciJava Ops and allows combination with additional resources for image processing and beyond. The following page will explain how you can write a script in Fiji's [Script Editor](https://imagej.net/scripting/) that utilizes Ops for image processing.
44

55
## Obtaining an OpEnvironment
66

7-
To run Ops, scripts require an `OpEnvironment`. The easiest way to obtain an `OpEnvironment` with all available Ops is to declare an `OpEnvironment` as a script parameter:
7+
To run Ops we always start with an `OpEnvironment`. The easiest way to obtain an `OpEnvironment` with all available Ops is to declare an `OpEnvironment` as a [script parameter](https://imagej.net/scripting/parameters):
88

99
```text
1010
#@ OpEnvironment ops
1111
```
1212

13-
## Obtaining inputs
13+
## Setting inputs and outputs
1414

15-
Scripts using SciJava Ops obtain inputs like any other SciJava script, and the lines below will provide us with an `Img` input parameter and an `Img` output parameter.
15+
A good starting point is to declare script parameters that match your desired Op's parameters. When performing image processing we are modifying an existing image, so we also want to create an output image in the script so our result will be shown. The following lines use SciJava's script parameters to obtain the active image as an input along with a user-defined sigma, while establishing our output.
1616

1717
```text
1818
#@ Img imgInput
19+
#@ Double sigma
1920
#@output Img out
2021
```
2122

22-
For more information on SciJava scripting parameters, please visit [this page](https://imagej.net/scripting/parameters).
23-
2423
## Calling Ops
2524

26-
The OpBuilder syntax should be used to retrieve and execute Ops from the `OpEnvironment`. The following line executes a Gaussian Blur on an input image using a `filter.gauss` Op:
25+
The [OpBuilder syntax](CallingOps) should be used to retrieve and execute Ops from the `OpEnvironment`. The following line executes a Gaussian Blur on an input image using a `filter.gauss` Op:
2726
```text
28-
out = ops.op("filter.gauss").input(imgInput, new Double(3.0)).apply()
27+
out = ops.op("filter.gauss").input(imgInput, sigma).apply()
2928
```
3029

3130
## Putting it all together
@@ -35,10 +34,19 @@ The below script can be pasted into the Script Editor. **Ensure that the Script
3534
```text
3635
#@ OpEnvironment ops
3736
#@ Img imgInput
37+
#@ Double sigma
3838
#@output Img out
3939
40-
// Call some Ops!
41-
out = ops.op("filter.gauss").input(imgInput, new Double(3.0)).apply()
40+
// Call our Op!
41+
out = ops.op("filter.gauss").input(imgInput, sigma).apply()
4242
```
4343

44-
Scripting in Fiji is a convenient gateway to accessing SciJava Ops. To see more, check out some examples, such as [image deconvolution](examples/deconvolution.rst) or [FLIM analysis](examples/flim_analysis.rst)!
44+
## Add your Op to the menu
45+
46+
If you want to re-use an Op outside of the script editor: good news! All SciJava scripts are ImageJ plugins and can be [installed](https://imagej.net/plugins/index#installing-plugins-manually) into your Fiji installation. For example, if we create a new `Ops` folder in our `Fiji.app/plugins/` directory and save our script there as `FilterGauss_.groovy` (or similar - just don't forget the `_`!) then after re-starting Fiji we can run our Op from the `Plugins > Ops` menu, and it will also show up in the [search bar](https://imagej.net/learn/#the-search-bar).
47+
48+
## Next steps
49+
50+
Check out the How-To Guides for important information like how to [explore the available Ops](SearchingForOps).
51+
52+
Check out some examples such as [image deconvolution](examples/deconvolution.rst) or [FLIM analysis](examples/flim_analysis.rst) to see more complete cases of Ops being used in the Script editor!

0 commit comments

Comments
 (0)