Skip to content

Commit

Permalink
Merge pull request #360 from imagej/snt-repl
Browse files Browse the repository at this point in the history
SNT: document REPL and misc corrections
  • Loading branch information
tferr authored Jan 20, 2025
2 parents 462db74 + 9b84b86 commit 17b06a4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion _pages/plugins/snt/analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Similarly to _Sholl Analysis_, there are several entry points to Strahler Analys
{% endcapture %}
{% include notice icon="info" content=strahler %}

{% include img align="right" src="/media/plugins/strahler-classification-example.png" caption="Strahler classification"%}
{% include img align="right" src="/media/plugins/snt/strahler-classification-example.png" caption="Strahler classification"%}
{% include wikipedia title='Strahler number' text='Strahler numbering'%} is a numerical procedure that summarizes the branching complexity of mathematical trees. The {% include wikipedia title='Strahler number' text='Strahler classification'%} occurs as follows:

- If a brach is terminal (has no children), its Strahler number is one
Expand Down
2 changes: 1 addition & 1 deletion _pages/plugins/snt/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ The Legacy 3D Viewer is a functional tracing canvas and allows images to be trac

## Bookmarks Tab

This tab hosts the Bookmark Manager, a utility that stores image locations to be (re)visited during tracing (e.g., a location of an ambiguous branching point or an ambiguous cross-over between two neurites). The basic usage is as follows:
This tab hosts the Bookmark Manager, a utility that stores image locations to be (re)visited during tracing (e.g., a location of an ambiguous branching point or an ambiguous cross-over between two neurites). Bookmarked locations can also be used as [spine/varicosity markers](/plugins/snt/walkthroughs#spinevaricosity-analysis). The basic usage is as follows:

<img align="right" width="300" src="/media/plugins/snt/snt-bookmarks-tab.png" title="Bookmarks tab" />

Expand Down
24 changes: 17 additions & 7 deletions _pages/plugins/snt/scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ Any script saved into Fiji's "scripts" subdirectory containing *SNT* in the file

3. Run {% include bc path='Scripts|Reload...'%}, and your new script should appear in the full list of scripts found at {% include bc path='Scripts|Full List...'%}.

## Script Recorder
# Script Recorder

SNT features a script recorder that similarly to _ImageJ's macro recorder_ converts menu and button clicks into executable code. Note however that while the recorder captures simple commands well, it struggles to capture those that are more complex or particularly interactive.

The goal of the recorder is twofold: 1) simplify prototyping of new scripts and 2) Log your actions during a tracing session. This is particularly useful to assemble reproducible records.

There are two ways to start the recorder: {% include bc path='Scripts|New|Record...'%} or by pressing the _Record_ button in [Command Palette](/plugins/snt/manual#command-palette).
There are two ways to start the recorder: {% include bc path='Scripts|Record...'%} or by pressing the _Record_ button in [Command Palette](/plugins/snt/manual#command-palette).

As a rule-of-thumb, commands that are simple or do not involve prompts record flawlessly. This includes setting filters for visibility of tags, applying Tags, or filtering paths in the Path Manager. Commands for fully automated reconstructions, or generating secondary layers _should_ work well. However, many others remain limited.

Expand All @@ -57,14 +57,24 @@ As a rule-of-thumb, commands that are simple or do not involve prompts record fl
</div>


## Script Interpreter

Some of SNT's functionality is conveniently accessible in the [Script Interpreter](/scripting/interpreter). Here is an example:
# REPL

SNT's Scripting REPL (Read–Eval–Print Loop) is opened using {% include bc path='Scripts|New|REPL'%}. It is a [Script Interpreter](/scripting/interpreter) instance with pre-initialized variables that are entry-points to the API of current SNT session. The REPL serves as a commandline prompt with access to all of SNT classes.
<div align="center">
<img src="/media/plugins/snt/snt-scriptinterpreter.png" title="SNTService being accessed in the Script Interpreter" width="650px" />
<img src="/media/plugins/snt/snt-repl.png" title="SNTService being accessed in SNT's Scripting REPL" width="700px" />
</div>

The REPL has access to _all_ of SNT's API. The prompt does not feature auto-completion but you can use `api(object, 'optional keyword')` to obtain a list of methods associated with an object. Example: To find out all of the 'demo' methods in SNTService, one would use:

{% highlight java %}
>>> api(snt, "demo")
6 method(s) available in sc.fiji.snt.SNTService:
demoImage(String arg0) -> ImagePlus
demoTree(String arg0) -> Tree
demoTree() -> Tree
demoTreeImage() -> ImagePlus
demoTrees() -> List
demoTreesSWC() -> List
{% endhighlight %}

# Python Notebooks

Expand Down
2 changes: 1 addition & 1 deletion _pages/plugins/snt/walkthroughs.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ This type of analysis uses (manually placed) multi-Point ROIs along paths as mar
2. Click over the features to be counted. Point placement may not need to be accurate, but with 3D images points should be placed on the same plane (Z-plane) the feature being counted
3. Once you have placed all the points, select the Path(s) associated with the features (or select none, if all Paths are to be considered) and run Path Manager's {% include bc path='Analyze|Spine/Varicosity Utilities|Extract Counts from Multi-point ROIs...' %}. The dialog allows you to specify:

- **Source of Multi-point ROI(s)** The location of the markers. Particularly useful if the ROIs are being generated programmatically and stored in the ROI Manager
- **Source of Multi-point ROI(s)** The location of the markers. Particularly useful if the ROIs are being generated programmatically and stored in the ROI Manager. It also allows [bookmarked locations](/plugins/snt/manual#bookmarks-tab) to be parsed as markers

- **Max. association distance** The maximum allowed distance between a point and its path in physical units. This option is ignored if set to -1 (the default). This works as follows: for every point ROI, the closest path node is identified. ROI is only considered to be associated with Path if its distance to the closest path node is less than or equal to _Max. association distance_.

Expand Down
Binary file added media/plugins/snt/snt-repl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed media/plugins/snt/snt-scriptinterpreter.png
Binary file not shown.

0 comments on commit 17b06a4

Please sign in to comment.