Skip to content

Commit efc7f72

Browse files
committed
snt: update integration w/ machine learning tools
update curation
1 parent d067306 commit efc7f72

4 files changed

Lines changed: 111 additions & 4 deletions

File tree

_pages/plugins/snt/comp-tools.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ forum-tag: snt
88
update-site: Neuroanatomy
99
---
1010

11+
### AI Tools
12+
Described in [Seeded Tracing](./seeds).
13+
14+
1115
### ImageJ Ecosystem
1216

1317
| Tool | Description | Comments |

_pages/plugins/snt/curation.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,24 @@ The table displays warnings sorted by severity (Errors first, then Warnings, the
171171
**Right-click** the table for additional options: clearing all warnings, setting the visiting zoom level, resetting zoom to the current image magnification, and detaching/docking the table into a separate floating window.
172172

173173

174+
## Seed Review
175+
The Curation Assistant also accepts warnings contributed by external programs: Warnings produced outside SNT can be imported as [Warning seeds](./seeds), and loaded into the assistant. These entries:
176+
177+
- Carry the check name "Seed Review" so they're easier to spot (and filter) among the algorithmically-generated warnings
178+
- Use the seed's 3D position as the warning location, so the standard double-click-to-navigate behavior flies the canvas to the seed.
179+
- Their severity level (Info / Warning / Error) is manually chosen: Use whichever level matches the review intent
180+
- Encode the seed's confidence, type, and source in the message
181+
182+
A typical workflow:
183+
184+
1. Import seeds into the [Seeded Tracing Assistant](./seeds#importing-seeds) (e.g., a CSV file of predicted problematic locations generated by a deep-learning pipeline)
185+
2. Adjust the [confidence range](./seeds#confidence-filtering) and sort the table so the candidates of interest are at the top
186+
3. Select the rows to be reviewed, right-click, and choose _Send Selected Seeds to Curation Assistant...__As Warning_ (or _As Info Message_ / _As Error_, as appropriate)
187+
4. The action will import the selected seeds and activate to the Assistant tab so that you can step through the new entries via double-click navigation
188+
189+
**NB**: Imported seeds are not de-duplicated: sending the same selection twice produces two rows
190+
191+
174192
# Detecting Crossovers
175193

176194
A crossover is a spot where at least two neurites pass very close to each other in space (so they may look like they intersect in the image) but they are not connected in the reconstructed graph (i.e., there is no shared node / true topological join). Identification of crossover sites is thus useful to disambiguate overlaps between neurites and spot possible tracing mistakes, such as missed branch-points or false merges.

_pages/plugins/snt/faq.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ Yes. You can trace using the the XY,ZY,XZ [views](/plugins/snt/walkthroughs#accu
8080
### Can I undo tracing mistakes?
8181
Yes. With version 5 and later, temporary segments can be reverted before finishing a path simply by pressing {% include key key='Z' %}. In Edit Mode, editing operations can also be reverted using the same shortcut. By default, the last 20 operations can be undone.
8282

83+
### Does SNT use AI?
84+
See [machine learning](./machine-learning).
85+
8386
### Having to confirm individual segments is too cumbersome. Is it possible to trace without interruption, by clicking in succession?
8487
Yes. Uncheck the *Confirm temporary segments* in the *Options* tab (*Temporary Paths* section): When this option is disabled. Segments are confirmed automatically. Note that double-click finishes a path directly, and the last confirmed segment can always be undone with the {% include key key='Z' %} key.
8588

@@ -136,3 +139,6 @@ See [Spine/Varicosity/Label Analysis](./spines-varicosities). In-depth quantific
136139

137140
### Can SNT reconstruct somata?
138141
Yes, see [Autotracing › Soma/Root Detection](./auto-tracing#somaroot-detection). Note, however, that most SNT tutorials favor the [single-point soma representation](https://neuromorpho.org/SomaFormat.html).
142+
143+
### Can I use cellpose segmentations?
144+
Yes, see [Machine learning](./machine-learning).

_pages/plugins/snt/machine-learning.md

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,95 @@ doi:
1212
---
1313

1414
{% capture version%}
15-
**This page was last revised for [version 5.0.0](https://github.com/morphonets/SNT/releases)**.
15+
**This page was last revised for [version 5.1.0](https://github.com/morphonets/SNT/releases)**.
1616
{% endcapture %}
1717
{% include notice content=version %}
1818

19-
SNT interacts with [Labkit](../labkit) and [Trainable Weka Segmentation (TWS)](../tws), both leveraging machine learning algorithms for semantic segmentation of images (namely, random forest classifiers). The bridge between these tools makes it possible to:
19+
SNT integrates with deep-learning (DL) segmentation tools (e.g., [cellpose](https://www.cellpose.org), [CSBDeep](/plugins/csbdeep), [DeepImageJ](https://deepimagej.github.io/), [nnU-Net](https://github.com/MIC-DKFZ/nnUNet), [StarDist](https://stardist.net/), and others) in both directions: their outputs — segmentations, probability maps, detected coordinates — become inputs to SNT's tracing and analysis workflows, while SNT's reconstructions, after [curation](./curation) and [refinement](./manual#refinefit-), can be exported as ground-truth labels to train the next round of models. For simpler, classical-ML alternatives, SNT also embeds ensemble (random-forest) classifiers via [Labkit/TWS](#embedded-tools-labkit--tws). The sections below provide an overview of how model predictions can be consumed in SNT, and how SNT can be used to generate training data for either family of models.
20+
21+
# Consuming DL Predictions
22+
23+
## Probability Maps
24+
25+
A segmentation network's per-voxel probability output can be loaded as a [secondary tracing layer](./manual#tracing-on-secondary-image-layer) alongside the raw image.
26+
SNT's [autotracers](./auto-tracing) can then use the probability map either as the primary signal (tracing directly on the network's prediction) or as a **score map** that guides pruning and tip extension during autotracing (see [Branch Filtering and Scoring](./auto-tracing#branch-filtering-and-scoring)).
27+
With semi-automated tracing, the secondary layer is opened using the [Interactive Tracing](./manual#interactive-tracing) widget in the Main tab. With [auto-tracing](./auto-tracing), the score map is loaded/chosen as a [parameter](./auto-tracing#branch-filtering-and-scoring).
28+
29+
Note that any tool that can save a probability map ([Labkit/TWS](#embedded-tools-labkit--tws), custom PyTorch/TensorFlow scripts) is supported: SNT only sees the resulting image.
30+
31+
## Seed Points
32+
33+
Many DL detectors output masks, or _candidate locations_: lists of soma centres, axon-terminal candidates, branch points, etc.
34+
SNT consumes these through the [Seeded Tracing Assistant](./seeds#seeded-tracing-assistant), where each candidate location/masked object lives as a 3D point with an associated confidence, optional radius, and free-form "type" and "source" fields.
35+
Once loaded, seeds can be:
36+
37+
- [Filtered](./seeds#confidence-filtering) and curated interactively
38+
- Used to root automated traces: E.g., cellpose masks can be used to specify the soma locations when autotracing [multiple cells](./auto-tracing#multiple-cells)
39+
- Used as endpoint targets for a single-cell trace
40+
- Used as soft attractors that bias the routing of an automated trace through the predicted locations
41+
42+
See [Seeded Tracing](./seeds) for full workflows. Note that the detector itself can be anything that produces a CSV list, or a labels image (from which centroids are extracted automatically).
43+
44+
## Quality Control Locations
45+
46+
The [Curation Assistant](./curation) accepts DL-flagged "suspect" locations (e.g., from a model trained on previously-reviewed reconstructions) as warnings: each predicted location is shown in the Assistant's [warnings table](./curation#warnings-table) for human review, mirroring how the Assistant's own [live monitors](./curation#live-monitoring-parameters) report issues from rule-based checks.
47+
48+
Programmatic entry is via `CurationManager#addWarnings(List<Warning>)`. Each `Warning` is a record carrying a short check name, a severity (`INFO`, `WARNING`, `ERROR`), a human-readable message, an optional spatial location, the list of affected paths, and the measured value and threshold that triggered the entry. Once injected, predictions live alongside the Assistant's own findings: they can be [filtered by severity](./curation#filter-by-severity), navigated to on the canvas, tagged as accept / reject / unsure for [downstream training](./curation#seed-review), and visited in batch from the warnings table.
49+
50+
```groovy
51+
import sc.fiji.snt.analysis.curation.PlausibilityCheck.Warning
52+
import sc.fiji.snt.analysis.curation.PlausibilityCheck.Severity
53+
import sc.fiji.snt.util.PointInImage
54+
55+
// `predictions` is whatever a detector emits per suspect location
56+
def warnings = predictions.collect { p ->
57+
new Warning("DL-QC", Severity.WARNING,
58+
"Predicted error (score=${p.score})",
59+
new PointInImage(p.x, p.y, p.z), // location
60+
p.nearbyPaths, // List<Path> list of affected paths
61+
p.score, 0.5) // measured value, threshold
62+
}
63+
ui.getCurationManager().addWarnings(warnings)
64+
```
65+
66+
This turns the Curation Assistant into a generic target for any QC model that returns spatial predictions on a finished reconstruction, including models trained on the [Seed Review](./curation#seed-review) export produced by an earlier curation pass, closing the feedback loop between review and retraining.
67+
68+
69+
# Generating Training Data
70+
71+
SNT's reconstruction, segmentation, and annotation tooling is also useful for _producing_ training data for downstream models. The data SNT generates is well-suited as ground truth: it's stored in calibrated coordinates, records provenance metadata, supports [post-hoc refinements](./manual#refinefit-), and can be reviewed in the [Curation Assistant](./curation) before being used to train downstream models.
72+
73+
These aspects are covered elsewhere in the documentation:
74+
75+
- **Pixel-level labels for segmentation networks**: Path Manager's {% include bc path='Process' %} menu exports selected paths as classifier labels into [Labkit/TWS](#embedded-tools-labkit--tws). See [Training Models](#training-models) below for the Weka-based workflow; the same exported labels can be repurposed for any U-Net-style trainer that consumes binary or multiclass images
76+
77+
- **Path fitting for automated refinement**: The [Refine/Fit](./manual#refinefit-) command snaps each node onto the signal centerline and recomputes per-node radii from cross-sectional intensity profiles. The result is a geometry that hugs the actual neurite rather than the tracer's first guess, lifting label quality before export
78+
79+
- **Editing tools for manual refinement**: SNT's [Edit Mode](./manual#edit-mode-8679-shifte) ({% include key keys='Shift|E' %}) supports per-node manipulation: insert, delete, redirect, or [paint](./manual#paint-mode-p) stretches of a path directly on the image. Auto-traced or imported paths can be corrected to match the underlying signal precisely, producing higher-fidelity ground truth than a raw automatic trace would offer
80+
81+
- **Cross-over detections**: The [crossover detector](./curation#detecting-crossovers) flags places where neurites pass close together in 3D but aren't topologically joined. Reviewing and resolving these before export prevents ambiguities from leaking into the training datasets
82+
83+
- **Curated reconstructions**: Paths reviewed in the [Curation Assistant](./curation) can be exported (with their accept/reject status preserved in path tags) as either positive examples for training models that learn correct topology, or negative examples for QC-classifier training. A scriptable bridge between the Assistant and a training pipeline facilitates this, e.g.,:
84+
85+
```groovy
86+
import sc.fiji.snt.Tree
87+
import sc.fiji.snt.analysis.curation.CurationTags
88+
def tree = Tree.fromFile("/path/to/annotated/file.traces")
89+
def p = CurationTags.partitionByReviewStatus(tree)
90+
println "${p.positive().size()} +, ${p.negative().size()} -, ${p.unsure().size()} ?, ${p.unreviewed().size()}"
91+
```
92+
93+
- **Coordinate-only labels for detectors**: the [Seeded Tracing Assistant](./seeds#seeded-tracing-assistant)'s export commands write CSV files that any soma- or endpoint-detection model can ingest as positive examples. Manual annotations, ROI-derived seeds, and label-image-derived seeds can all be stored in the same exportable format
94+
95+
96+
# Embedded Tools: Labkit & TWS
97+
98+
SNT interacts with [Labkit](../labkit) and [Trainable Weka Segmentation (TWS)](../tws), both leveraging machine learning algorithms for semantic segmentation of images (namely, random forest classifiers). The bridge between these tools makes it possible to:
2099

21100
- Import a pre-trained model into SNT and directly load the probability maps of the semantic segmentation as secondary tracing layer
22101
- Train a model with SNT paths
23102

24-
The table below summarizes key differences between Labkit and TWS (as of SNT v4.3.0). Note that both tools classify images using the [Weka framework](https://ml.cms.waikato.ac.nz/weka/).
103+
The table below summarizes key differences between Labkit and TWS (as of SNT v5). Note that both tools classify images using the [Weka framework](https://ml.cms.waikato.ac.nz/weka/).
25104

26105
| | **[Labkit](../labkit)** | **[TWS](../tws)** |
27106
|------------------------------------------------------|------------------------------------------------------|------------------------------|
@@ -73,7 +152,7 @@ There are a couple of examples in SNT's neuroanatomy [template collection](scrip
73152
- *Apply Weka Model To Tracing Image*: Demonstrates how to apply a pre-existing Weka model to the image being traced
74153
- *Train Weka Classifier*: Exemplifies how to train a Weka model using traced paths and ROIs
75154

76-
## References
155+
# References
77156

78157
{% include citation %}
79158

0 commit comments

Comments
 (0)