Package sc.fiji.snt.analysis.curation
Class PlausibilityMonitor
java.lang.Object
sc.fiji.snt.analysis.curation.PlausibilityMonitor
Monitors tracing and editing operations for morphological plausibility.
The monitor maintains two tiers of checks:
PlausibilityCheck.LiveCheck: lightweight checks run inline during interactive tracing at four hook points (fork initiation, segment completion, path finalization, node editing).PlausibilityCheck.DeepCheck: heavier checks that scan the full reconstruction on demand viarunDeepScan(Collection).
Listeners are notified whenever the warning list changes so that UI components (status bar, canvas overlays, assistant panel) can react.
- Author:
- Tiago Ferreira
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceListener interface for warning list changes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidClears the cached fork context.<T extends PlausibilityCheck.DeepCheck>
TgetDeepCheck(Class<T> type) Convenience method to get a specific deep check by type.<T extends PlausibilityCheck.LiveCheck>
TgetLiveCheck(Class<T> type) Convenience method to get a specific live check by type.booleanbooleanReturns whether the most recent warning update originated from a live check (inline during tracing) as opposed to an on-demand or full scan.voidonForkInitiated(Path parent, int branchIndex) Hook 1: Fork initiation. Called fromSNT.startPath()when the user Alt-clicks to start a branch.onNodeEdited(Path editedPath, int nodeIndex) Hook 4: Node editing. Called after a node is moved, inserted, or deleted during edit mode.onPathFinalized(Path completedChild) Hook 3: Path finalization. Called when the user completes an entire path (SNT.finishPath()).onSegmentCompleted(Path candidateChild) Hook 2: Segment completion. Called fromSNT.searchFinished()when A* returns a candidate segment, before the user sees the keep/junk dialog.voidrunDeepScan(Collection<Path> paths) Runs all enabledPlausibilityCheck.DeepChecks against the given paths.runFullScan(Collection<Path> paths) Runs all enabled checks (both live and deep) against the given paths.voidsetEnabled(boolean enabled) voidsetImageData(net.imglib2.RandomAccessibleInterval<? extends net.imglib2.type.numeric.RealType<?>> image) Sets the image data used by checks that require it (e.g.,PlausibilityCheck.SignalQuality).voidsetImageStats(double min, double max) Sets image-level statistics for auto-threshold computation.
-
Constructor Details
-
PlausibilityMonitor
public PlausibilityMonitor()
-
-
Method Details
-
onForkInitiated
Hook 1: Fork initiation. Called fromSNT.startPath()when the user Alt-clicks to start a branch. Caches the parent path and branch point index for later comparison.- Parameters:
parent- the parent path being forked frombranchIndex- the node index in the parent at the fork point
-
onSegmentCompleted
Hook 2: Segment completion. Called fromSNT.searchFinished()when A* returns a candidate segment, before the user sees the keep/junk dialog.- Parameters:
candidateChild- the candidate child path segment- Returns:
- the list of warnings (empty if plausible)
-
onPathFinalized
Hook 3: Path finalization. Called when the user completes an entire path (SNT.finishPath()). Runs a holistic check on the full child path against its parent.- Parameters:
completedChild- the finished child path- Returns:
- the list of warnings (empty if plausible)
-
onNodeEdited
Hook 4: Node editing. Called after a node is moved, inserted, or deleted during edit mode. Re-checks the local neighborhood.- Parameters:
editedPath- the path being editednodeIndex- the index of the affected node- Returns:
- the list of warnings (empty if plausible)
-
clearForkContext
public void clearForkContext()Clears the cached fork context. Should be called when tracing is canceled or a non-forking path is started. -
runDeepScan
Runs all enabledPlausibilityCheck.DeepChecks against the given paths.- Parameters:
paths- the paths to scan (e.g., all paths in the current Tree)- Returns:
- the list of warnings (empty if no issues found)
-
runFullScan
Runs all enabled checks (both live and deep) against the given paths. Live checks are applied to every parent–child fork in the collection; deep checks scan the collection as a whole.This is the method behind "Run Full Scan" in the Curation Assistant panel.
- Parameters:
paths- the paths to scan (e.g., all paths in the current Tree)- Returns:
- the combined list of warnings (empty if no issues found)
-
addWarningListener
-
removeWarningListener
-
isLastUpdateFromLiveCheck
public boolean isLastUpdateFromLiveCheck()Returns whether the most recent warning update originated from a live check (inline during tracing) as opposed to an on-demand or full scan. UI code can use this to decide whether to show canvas animations.- Returns:
trueif the last update was from a live check
-
isEnabled
public boolean isEnabled() -
setEnabled
public void setEnabled(boolean enabled) -
setImageData
public void setImageData(net.imglib2.RandomAccessibleInterval<? extends net.imglib2.type.numeric.RealType<?>> image) Sets the image data used by checks that require it (e.g.,PlausibilityCheck.SignalQuality). Should be called beforerunDeepScan(Collection)orrunFullScan(Collection).- Parameters:
image- the image (imglib2 RAI);nullto clear
-
setImageStats
public void setImageStats(double min, double max) Sets image-level statistics for auto-threshold computation.- Parameters:
min- image minimum intensitymax- image maximum intensity
-
getLiveChecks
- Returns:
- the (modifiable) list of registered live checks
-
getDeepChecks
- Returns:
- the (modifiable) list of registered deep checks
-
getCurrentWarnings
- Returns:
- the current (immutable) list of active warnings
-
getLiveCheck
Convenience method to get a specific live check by type.- Parameters:
type- the check class- Returns:
- the check instance, or
nullif not registered
-
getDeepCheck
Convenience method to get a specific deep check by type.- Parameters:
type- the check class- Returns:
- the check instance, or
nullif not registered
-