Class GWDTTracerCommonCmd

java.lang.Object
org.scijava.module.AbstractModule
org.scijava.module.DefaultMutableModule
org.scijava.command.DynamicCommand
sc.fiji.snt.gui.cmds.CommonDynamicCmd
sc.fiji.snt.plugin.GWDTTracerCommonCmd
All Implemented Interfaces:
Runnable, org.scijava.Cancelable, org.scijava.command.Command, org.scijava.Contextual, org.scijava.module.Module, org.scijava.module.MutableModule, org.scijava.plugin.SciJavaPlugin
Direct Known Subclasses:
AutotraceFromSeedsCmd, AutotraceFromTipsCmd, AutotraceFromWaypointsCmd, GWDTMultiSomaCommonCmd, GWDTTracerCmd, GWDTTracerFileCmd

public abstract class GWDTTracerCommonCmd extends CommonDynamicCmd
Base command providing shared parameters and logic for GWDT autotracing. Subclassed by GWDTTracerCmd (interactive, image already loaded) and GWDTTracerFileCmd (non-interactive, file-based).
Author:
Tiago Ferreira
See Also:
  • Field Details

    • SOMA_AUTO

      protected static final String SOMA_AUTO
      See Also:
    • SOMA_ROI_AUTO_EDGE

      protected static final String SOMA_ROI_AUTO_EDGE
      See Also:
    • SOMA_BOOKMARK

      protected static final String SOMA_BOOKMARK
      Stream-mode-only strategy: seeds detection from BDV/BVV marker(s) (M key), since Stream mode has no Roi support. Only offered when snt.isStreamMode(); see initForImage()
      See Also:
    • prefService

      protected org.scijava.prefs.PrefService prefService
    • imgChoice

      protected String imgChoice
    • imgFileChoice

      protected File imgFileChoice
    • somaStrategyChoice

      protected String somaStrategyChoice
    • backgroundThreshold

      protected double backgroundThreshold
    • scoreMapFilter

      protected String scoreMapFilter
    • lengthThreshold

      protected double lengthThreshold
    • branchTuneMaxAngle

      protected double branchTuneMaxAngle
    • debugMode

      protected boolean debugMode
    • abortRun

      protected boolean abortRun
    • chosenImp

      protected net.imagej.ImgPlus<?> chosenImp
  • Constructor Details

    • GWDTTracerCommonCmd

      public GWDTTracerCommonCmd()
  • Method Details

    • scoreMapFilterCallback

      protected void scoreMapFilterCallback()
      Toggles visibility of secondary-image inputs that are only relevant when scoreMapFilter == SCORE_MAP_OTHER. The base implementation handles any secondaryImageSuffix input declared by subclasses; subclasses may override to control additional related inputs. Safe to call when the input is not declared (no-op in that case).
    • initForImage

      protected void initForImage()
    • initForFile

      protected void initForFile()
    • readPreferences

      protected void readPreferences()
    • savePreferences

      protected void savePreferences()
    • applyDefaults

      protected void applyDefaults()
    • createAndConfigureTracer

      protected AbstractGWDTTracer<?> createAndConfigureTracer(net.imagej.ImgPlus<?> img)
      Creates and configures a tracer from the shared GUI parameters. Returns null if configuration failed (e.g., missing secondary image for score map).
      Parameters:
      img - the image to trace
      Returns:
      configured tracer, or null on error
    • configureSecondaryScoreMap

      protected boolean configureSecondaryScoreMap(AbstractGWDTTracer<?> tracer)
      Hook for configuring the tracer's score map from a user-supplied secondary image. Invoked only when scoreMapFilter == SCORE_MAP_OTHER.

      Default implementation pulls from SNT.getSecondaryData() (the secondary layer currently loaded in the GUI) and aborts the command via error(String) if none is available.

      Subclasses may override to source the secondary from disk (or elsewhere) and may choose to handle missing/incompatible inputs gracefully by disabling score mapping (tracer.setScoreMapEnabled(false)) and returning true so tracing proceeds without it.

      Parameters:
      tracer - the tracer being configured
      Returns:
      true to continue (score map configured, or gracefully disabled); false to abort the command
    • runCommand

      protected void runCommand()
    • applyWorldOriginOffsetIfAny

      protected void applyWorldOriginOffsetIfAny(List<Tree> trees)
      Shifts each tree by snt's current world origin offset, if any (a no-op when that offset is all-zero, which is the common case). Called once, right after tracing produces valid trees and before handleTracedTrees(java.util.List<sc.fiji.snt.Tree>), so that every subclass/override of handleTracedTrees (whether it loads trees into PathAndFillManager, exports them to disk, or both - see GWDTTracerFileCmd) sees already-corrected coordinates.

      The offset is only non-zero when chosenImp's pixel data was wired in from a source whose own coordinate frame is not anchored at world (0,0,0) (see BigDataLoaderCmd#applyFallbackCalibration); leaving it uncorrected would produce shape-correct but uniformly mispositioned trees.

      Translating the node coordinates alone is only half of the correction interactive tracing applies (see SNT#syncActivePathCanvasState): every Path's own canvasOffset must be stamped with the matching (negative, pixel-space) counterpart too, or Path#getXUnscaledDouble() and friends resolve to the wrong voxel index against whatever RAI chosenImp was read from, even though the Path's own world coordinates display and measure correctly. SNT.getActiveCanvasPixelOffset() (not the crop-independent SNT.getDefaultCanvasPixelOffset()) is used because chosenImp itself comes from SNT.getLoadedDataAsImg(boolean) - the crop-local grid whenever a crop happens to be materialized, the raw streamed source's grid otherwise (see initForImage()).

      Parameters:
      trees - the traced trees to correct in place
    • handleTracedTrees

      protected void handleTracedTrees(List<Tree> trees)
      Called after tracing completes with valid trees (already corrected for any world origin offset - see applyWorldOriginOffsetIfAny(java.util.List<sc.fiji.snt.Tree>)). The default implementation loads trees into PathAndFillManager and optionally triggers proofreading. Subclasses (e.g., GWDTTracerFileCmd) may override to export trees to disk instead.
      Parameters:
      trees - the traced trees (guaranteed non-empty)
    • isFileMode

      protected abstract boolean isFileMode()
    • getImgFromImgChoice

      protected net.imagej.ImgPlus<?> getImgFromImgChoice()
    • noValidImgError

      protected void noValidImgError()
    • cancel

      public void cancel(String reason)
      Specified by:
      cancel in interface org.scijava.Cancelable
      Overrides:
      cancel in class CommonDynamicCmd
    • error

      protected void error(String msg)
      Overrides:
      error in class CommonDynamicCmd