|
12 | 12 | --- |
13 | 13 |
|
14 | 14 | {% 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)**. |
16 | 16 | {% endcapture %} |
17 | 17 | {% include notice content=version %} |
18 | 18 |
|
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: |
20 | 99 |
|
21 | 100 | - Import a pre-trained model into SNT and directly load the probability maps of the semantic segmentation as secondary tracing layer |
22 | 101 | - Train a model with SNT paths |
23 | 102 |
|
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/). |
25 | 104 |
|
26 | 105 | | | **[Labkit](../labkit)** | **[TWS](../tws)** | |
27 | 106 | |------------------------------------------------------|------------------------------------------------------|------------------------------| |
@@ -73,7 +152,7 @@ There are a couple of examples in SNT's neuroanatomy [template collection](scrip |
73 | 152 | - *Apply Weka Model To Tracing Image*: Demonstrates how to apply a pre-existing Weka model to the image being traced |
74 | 153 | - *Train Weka Classifier*: Exemplifies how to train a Weka model using traced paths and ROIs |
75 | 154 |
|
76 | | -## References |
| 155 | +# References |
77 | 156 |
|
78 | 157 | {% include citation %} |
79 | 158 |
|
|
0 commit comments