Package sc.fiji.snt

Class SNT

All Implemented Interfaces:
HessianGenerationCallback, PaneOwner, SearchProgressCallback

Implements the SNT plugin.
Author:
Tiago Ferreira, Cameron Arshadi
  • Field Details

    • statusService

      protected org.scijava.app.StatusService statusService
    • verbose

      protected static boolean verbose
    • MIN_SNAP_CURSOR_WINDOW_XY

      protected static final int MIN_SNAP_CURSOR_WINDOW_XY
      See Also:
    • MIN_SNAP_CURSOR_WINDOW_Z

      protected static final int MIN_SNAP_CURSOR_WINDOW_Z
      See Also:
    • MAX_SNAP_CURSOR_WINDOW_XY

      protected static final int MAX_SNAP_CURSOR_WINDOW_XY
      See Also:
    • MAX_SNAP_CURSOR_WINDOW_Z

      protected static final int MAX_SNAP_CURSOR_WINDOW_Z
      See Also:
    • startBallName

      protected static final String startBallName
      See Also:
    • targetBallName

      protected static final String targetBallName
      See Also:
    • ballRadiusMultiplier

      protected static final int ballRadiusMultiplier
      See Also:
    • univ

      protected ij3d.Image3DUniverse univ
    • use3DViewer

      protected boolean use3DViewer
    • colorImage

      protected ij.ImagePlus colorImage
    • DISPLAY_PATHS_SURFACE

      protected static final int DISPLAY_PATHS_SURFACE
      See Also:
    • DISPLAY_PATHS_LINES

      protected static final int DISPLAY_PATHS_LINES
      See Also:
    • DISPLAY_PATHS_LINES_AND_DISCS

      protected static final int DISPLAY_PATHS_LINES_AND_DISCS
      See Also:
    • cursorSnapWindowXY

      protected volatile int cursorSnapWindowXY
    • cursorSnapWindowZ

      protected volatile int cursorSnapWindowZ
    • panMode

      protected volatile boolean panMode
    • snapCursor

      protected volatile boolean snapCursor
    • showOnlySelectedPaths

      protected volatile boolean showOnlySelectedPaths
    • showOnlyActiveCTposPaths

      protected volatile boolean showOnlyActiveCTposPaths
    • isolatedTreeID

      protected volatile int isolatedTreeID
      ID of the single tree (arbor) currently isolated for display in PathManagerUI or -1 if no isolation is active Orthogonal to path selection: unlike showOnlySelectedPaths, isolating a tree does not alter which paths are considered "selected", nor their rendered color - it only hides paths belonging to other trees. Set via setIsolatedTreeID(int); consulted by TracerCanvas, the legacy 3D viewer (PathAndFillManager.update3DViewerContents()), and Bdv/Bvv (Bvv.PathOverlay).
    • autoCT

      protected volatile boolean autoCT
    • manualRadius

      protected double manualRadius
    • SCROLL_DIAMETER_DISABLED

      public static final double SCROLL_DIAMETER_DISABLED
      manualRadius sentinel: Ctrl+scroll diameter assignment explicitly disabled (not just unset)
      See Also:
    • width

      protected int width
    • height

      protected int height
    • depth

      protected int depth
    • imageType

      protected int imageType
    • x_spacing

      protected double x_spacing
    • y_spacing

      protected double y_spacing
    • z_spacing

      protected double z_spacing
    • spacing_units

      protected String spacing_units
    • channel

      protected int channel
    • frame

      protected int frame
    • filterType

      protected SNT.FilterType filterType
    • searchImageType

      protected SNT.SearchImageType searchImageType
    • isUseSubVolumeStats

      protected volatile boolean isUseSubVolumeStats
    • oneMinusErfZFudge

      protected volatile double oneMinusErfZFudge
    • doSearchOnSecondaryData

      protected boolean doSearchOnSecondaryData
    • secondaryData

      protected net.imglib2.RandomAccessibleInterval secondaryData
    • secondaryImageFile

      protected File secondaryImageFile
    • tubularGeodesicsTracingEnabled

      protected boolean tubularGeodesicsTracingEnabled
    • tubularGeodesicsThread

      protected TubularGeodesicsTracer tubularGeodesicsThread
    • last_start_point_x

      protected double last_start_point_x
    • last_start_point_y

      protected double last_start_point_y
    • last_start_point_z

      protected double last_start_point_z
    • temporaryPath

      protected Path temporaryPath
    • currentPath

      protected Path currentPath
    • ui

      protected SNTUI ui
    • tracingHalted

      protected volatile boolean tracingHalted
    • rubberBandTracing

      protected volatile boolean rubberBandTracing
    • selectedColor3f

      protected org.jogamp.vecmath.Color3f selectedColor3f
    • deselectedColor3f

      protected org.jogamp.vecmath.Color3f deselectedColor3f
    • confirmedSegmentSizes

      protected final Deque<Integer> confirmedSegmentSizes
    • listeners

      protected List<SNTListener> listeners
  • Constructor Details

    • SNT

      public SNT(ij.ImagePlus sourceImage) throws IllegalArgumentException
      Script-friendly constructor for Instantiating and initializing SNT in 'Tracing Mode' (typically headless operations). The channel/frame to be traced is assumed to be the image's active CT position.

      Note that the image is not displayed. For interactive display of the image call initialize(ImagePlus)/startUI() directly.

      Parameters:
      sourceImage - the source image
      Throws:
      IllegalArgumentException - If sourceImage is of type 'RGB'
    • SNT

      public SNT(net.imagej.ImgPlus<T> sourceImage) throws IllegalArgumentException
      Script-friendly constructor for Instantiating SNT in 'Tracing Mode' (typically headless operations)
      Parameters:
      sourceImage - the source image
      Throws:
      IllegalArgumentException
    • SNT

      public SNT(net.imagej.ImgPlus<T> sourceImage, int channel, int timePoint) throws IllegalArgumentException
      Script-friendly constructor for Instantiating SNT in 'Tracing Mode' (typically headless operations)
      Parameters:
      sourceImage - the source image
      channel - channel index to extract (index 0)
      timePoint - time index to extract (index 0)
      Throws:
      IllegalArgumentException
    • SNT

      public SNT(org.scijava.Context context, ij.ImagePlus sourceImage) throws IllegalArgumentException
      Instantiates SNT in 'Tracing Mode'.
      Parameters:
      context - the SciJava application context providing the services required by the class
      sourceImage - the source image
      Throws:
      IllegalArgumentException - If sourceImage is of type 'RGB'
    • SNT

      public SNT(org.scijava.Context context, PathAndFillManager pathAndFillManager)
      Instantiates SNT in 'Analysis Mode'
      Parameters:
      context - the SciJava application context providing the services required by the class
      pathAndFillManager - The PathAndFillManager instance to be associated with the plugin
  • Method Details

    • undoLastSegment

      protected void undoLastSegment()
    • rebuildDisplayCanvases

      public void rebuildDisplayCanvases() throws IllegalArgumentException
      Rebuilds display canvases, i.e., the placeholder canvases used when no valid image data exists (a single-canvas is rebuilt if only the XY view is active).

      Useful when multiple files are imported and imported paths 'fall off' the dimensions of current canvas(es). If there is not enough memory to accommodate enlarged dimensions, the resulting canvas will be a 2D image.

      Throws:
      IllegalArgumentException - if valid image data exists
    • updateDisplayCanvases

      public void updateDisplayCanvases()
      Rebuilds display canvas(es) to ensure all paths are contained in the image. Does nothing if placeholder canvas(es) are not being used.
      See Also:
    • accessToValidImageData

      public boolean accessToValidImageData()
      Checks whether valid image data exists.
      Returns:
      true if a tracing image exists, or (for headless/API usage) cached pixel data remains in memory.
    • getActiveCanvasPixelOffset

      public PointInCanvas getActiveCanvasPixelOffset()
      Returns:
      the pixel offset (in whatever grid ctSlice3d/getLoadedData() is currently indexed by - the crop-local grid when a materialized crop is active, or the raw streamed source's own voxel grid otherwise) of (0,0,0) in the true/world grid Path node coordinates are stored in
    • getDefaultCanvasPixelOffset

      public PointInCanvas getDefaultCanvasPixelOffset()
      Public wrapper around defaultCanvasPixelOffset(), for callers outside this class that need the crop-independent baseline offset even while a materialized crop is active on the classic 2D canvas - e.g. a BDV/BVV interaction that should behave the same regardless of what the classic canvas currently has materialized, mirroring how createSearch(double, double, double, double, double, double, SearchSettingsSnapshot, boolean)'s useStreamedSource parameter picks between the two.
      Returns:
      the same value as getActiveCanvasPixelOffset() whenever no crop is materialized; the crop-independent baseline otherwise
    • isMaterializedCrop

      public boolean isMaterializedCrop()
      Returns:
      true if this stream session's own XY canvas is currently a materialized crop (see materializeDisplayCanvas(BoundingBox)), i.e. ctSlice3d holds the crop's own (small) pixel data rather than the full Stream-mode source. Checked by AbstractBigViewer's click-tracer to refuse tracing against stale pixel data while its own rendering still shows the full (unaffected) volume, and by pixel-scoped commands to warn that they will run against the crop's bounds only.
    • getMaterializedCropWorldBounds

      public BoundingBox getMaterializedCropWorldBounds()
      Returns:
      the world-space (calibrated) extent of the currently materialized crop (see materializeDisplayCanvas(BoundingBox)), or null if none is active. Useful for callers (e.g. SkeletonizerCmd) that want to restrict an operation to the region actually materialized, since BDV/BVV have no ROI equivalent. Derived from getActiveCanvasPixelOffset() and the live width/height/depth (the crop's own small dimensions while materialized - see getFullImageDimensions()): since voxelIndex = world/spacing + canvasOffset (see defaultCanvasPixelOffset()), the crop's local voxel 0 and voxel width/height/depth map back to world coordinates via world = (voxelIndex - canvasOffset) * spacing - getWorldOriginOffset() cancels out of that algebra, so it does not need to be looked up separately here.
    • getMaterializedCropChannel

      public Integer getMaterializedCropChannel()
      Returns:
      the (1-based) channel the currently materialized crop (see materializeDisplayCanvas(BoundingBox)) was actually read from, or null if no crop is active, or if the crop is genuinely multichannel - in that case every one of its channels is resident, so there is no single "the channel it came from" to report, and callers should instead treat it like any other resident multichannel image with no restriction.
      See Also:
    • getMaterializedCropFrame

      public Integer getMaterializedCropFrame()
      Returns:
      the (1-based) frame the currently materialized crop (see materializeDisplayCanvas(BoundingBox)) as actually read from, or null if no crop is active. A materialized crop is always single-frame regardless of how many channels it captures (see SNT.MaterializedCrop.frame() - a single int, set by installMaterializedCropOnEDT()), so this stays meaningful even for a multichannel crop, where getMaterializedCropChannel() returns null. Callers that only care about frame should use this rather than falling back to getFrame() (reset to 1 by any materialized crop, single- or multichannel, regardless of its true source frame) when getMaterializedCropChannel() is null.
      See Also:
    • getFullImageDimensions

      public int[] getFullImageDimensions()
      Returns the dimensions of the full loaded image/dataset, even while a materialized crop (see materializeDisplayCanvas(BoundingBox)) is installed as this session's own canvas. Unlike width/height/depth, which temporarily reflect the crop's own (small) size for as long as it stays open (see installMaterializedCrop(sc.fiji.snt.SNT.MaterializedCrop)), this always resolves against streamedSourceData (the pristine, pre-crop source) when one is cached, falling back to width/height/depth otherwise (i.e. no crop is open, or this is a classic/non-streamed session where streamedSourceData is never populated).

      Intended for callers that need the true dataset extent regardless of any transient crop, e.g. PathAndFillManager.writeXML(java.lang.String, boolean) when writing the <imagesize> element of a .traces file.

      Returns:
      {width, height, depth} of the full dataset
    • isCachedData

      protected boolean isCachedData(ij.ImagePlus imp)
    • estimateMaterializationBytes

      public long estimateMaterializationBytes(long width, long height, long depth)
      Estimates the number of bytes required to materialize a crop of the given voxel dimensions from this session's streamed source (see materializeDisplayCanvas(BoundingBox)), using the source's actual pixel type.
      Parameters:
      width - the crop's width, in voxels
      height - the crop's height, in voxels
      depth - the crop's depth, in voxels
      Returns:
      the estimated byte count, or -1 if no streamed source is available to estimate from
      See Also:
    • getMaterializationMemoryBudget

      public long getMaterializationMemoryBudget()
      Returns:
      the number of bytes currently available for a materializeDisplayCanvas(BoundingBox) call, i.e. MEM_FRACTION of free heap. Long.MAX_VALUE if the JVM's max memory cannot be determined.
      See Also:
    • getCalibration

      public ij.measure.Calibration getCalibration()
      Returns:
      this session's current spatial calibration (pixel width/height/depth and unit), for converting between pixel and world/calibrated coordinates without affecting world origin: see setWorldOriginOffset(double, double, double) for the separate mechanism that handles a non-zero-anchored source.

      Calibration is trusted from initialized ImagePlus (traditional mode) or from the stream source in Stream mode (isSpacingKnownFromSource()); If the streamed N5/Zarr source whose own getVoxelDimensions() returned null (see BigDataLoaderCmd#applyFallbackCalibration ), this falls back to a representative loaded Path's own calibration.

      That fallback is inherently a guess SNT cannot verify: nothing guarantees a loaded Path (e.g. imported from an SWC/traces file) was actually traced against the currently streamed source, so its calibration could be wrong for this data. Callers driving user-facing operations should warn accordingly, see SNTUI#materializeDisplayCanvas()'s use of isSpacingKnownFromSource().

    • isSpacingKnownFromSource

      public boolean isSpacingKnownFromSource()
      Returns:
      true if getCalibration() can trust this session's own spacing fields outright (the streamed source itself reported real voxel dimensions at some point); false if it instead has to fall back to a loaded Path's own (unverifiable) calibration, or this session's hardwired 1-unit default. Used by SNTUI to warn before an operation that depends on this calibration being correct (e.g. materializing a region), since SNT itself cannot confirm that a loaded Path was actually traced against the currently streamed source.
    • resolveVoxelBounds

      public SNT.VoxelBounds resolveVoxelBounds(BoundingBox worldBox, ij.measure.Calibration cal)
      Resolves a world-space region to voxel-index bounds within this session's streamed source, clamping to the source's own extent - a requested region can partially or fully exceed the loaded volume (e.g. from padding, or a fixed-size/center region placed near or past an edge). Shared by materializeDisplayCanvas(BoundingBox) (which performs the actual read) and MaterializeRegionDialog's live estimate (which needs to preview the REAL, possibly smaller, result before the user commits to it), so the two can never disagree about what a given region will actually produce.
      Parameters:
      worldBox - the requested region, in the same (uncalibrated) coordinate frame as Path node coordinates, i.e., already corrected for getWorldOriginOffset() if that offset is non-zero, matching how Paths reaching pathAndFillManager are now uniformly built (see applyWorldOriginOffsetIfAny(Path)). This method subtracts that offset itself before converting to the source's own raw voxel grid. See materializeDisplayCanvas(BoundingBox)
      cal - the calibration to convert worldBox with - normally getCalibration(), passed in explicitly so a caller that already computed it (e.g. to also build the crop's own output Calibration) does not need to compute it twice
      Returns:
      the resolved, clamped voxel bounds
      Throws:
      IllegalStateException - if this session has no loaded pixel data (not in Stream mode, or the source is unavailable)
      IllegalArgumentException - if worldBox does not overlap the loaded source at all
    • resolveVoxelBounds

      public SNT.VoxelBounds resolveVoxelBounds(BoundingBox worldBox, ij.measure.Calibration cal, boolean useSecondary)
      As resolveVoxelBounds(BoundingBox, Calibration), but resolving against either this session's main streamed source or its secondary (filtered) image - see buildMaterializedCrop(BoundingBox, boolean).
      Parameters:
      useSecondary - if true, resolves against getSecondaryData() instead of the main streamed source
      Throws:
      IllegalStateException - if useSecondary is true but no secondary image is loaded
    • buildMaterializedCrop

      public SNT.MaterializedCrop buildMaterializedCrop(BoundingBox worldBox)
      Reads and builds a bounded pixel region of this Stream-mode session's source into a real, eagerly-copied ImagePlus, without installing it as this session's canvas yet - see installMaterializedCrop(MaterializedCrop) for that half, and materializeDisplayCanvas(BoundingBox) for the combined convenience call most callers want. Split out specifically so the (potentially slow, disk-/network-bound) read can run off the EDT: unlike installMaterializedCrop(MaterializedCrop), this method touches no Swing/AWT state (no ImageWindow, no initialize(ImagePlus)) and is safe to call from a background thread
      Parameters:
      worldBox - the region to materialize, in the same (uncalibrated) coordinate frame as Path node coordinates, i.e., already corrected for getWorldOriginOffset() if that offset is non-zero, matching how Paths reaching pathAndFillManager are built (see resolveVoxelBounds(BoundingBox, Calibration) which subtracts that offset before converting to ctSlice3d's own raw voxel grid). Typically, the (padded) bounding box of a path selection.
      Returns:
      the built crop, ready for installMaterializedCrop(MaterializedCrop)
      Throws:
      IllegalStateException - if this session has no loaded pixel data (not in Stream mode, or the source is unavailable)
      IllegalArgumentException - if worldBox does not overlap the loaded source, or the requested crop exceeds the materialization memory budget
    • buildMaterializedCrop

      public SNT.MaterializedCrop buildMaterializedCrop(BoundingBox worldBox, boolean useSecondary)
      As buildMaterializedCrop(BoundingBox), but reading from either this session's main streamed source or its secondary (filtered) image.
      Parameters:
      useSecondary - if true, crops getSecondaryData() instead of the main streamed source
      Throws:
      IllegalStateException - if useSecondary is true but no secondary image is loaded
    • installMaterializedCrop

      public void installMaterializedCrop(SNT.MaterializedCrop crop)
      Installs a crop built by buildMaterializedCrop(BoundingBox) as this session's own XY canvas, in place, the same mechanism rebuildDisplayCanvases() uses for the blank placeholder, but with real pixel data instead of an empty image. This allows right-click editing (extend/fork/join/delete nodes, wired into InteractiveTracerCanvas) real pixel context in Stream mode, where BDV/BVV have no equivalent context menu.

      Deliberately scoped to editing, not tracing: this reuses the normal initialize(ImagePlus) pipeline, which also replaces ctSlice3d with the crop's own (small) pixel data. A* search/GWDT tracing initiated after materializing is therefore scoped to the crop's own bounds, not the full streamed volume, until a different region is materialized (or the session is reconnected). There is no path for pixel edits to write back into the canonical streamed source: only geometry/paths persist, pixel edits are local to this session.

      Parameters:
      crop - the crop to install, from buildMaterializedCrop(BoundingBox)
      Throws:
      IllegalStateException - if this session is not in Stream mode (see isStreamMode()): classic mode already holds its full image resident, so installing a crop as this session's canvas is untested and not a supported combination
    • materializeDisplayCanvas

      public void materializeDisplayCanvas(BoundingBox worldBox)
      Convenience call combining buildMaterializedCrop(BoundingBox) and installMaterializedCrop(MaterializedCrop) - reads the region and installs it as this session's canvas, in one call. Safe to call from any thread but a UI wanting to keep the interface responsive during a potentially slow read should instead call the two halves directly, backgrounding buildMaterializedCrop(BoundingBox).
      Parameters:
      worldBox - see buildMaterializedCrop(BoundingBox)
      Throws:
      IllegalStateException - see buildMaterializedCrop(BoundingBox)
      IllegalArgumentException - see buildMaterializedCrop(BoundingBox)
    • materializeDisplayCanvas

      public void materializeDisplayCanvas(BoundingBox worldBox, boolean useSecondary)
      As materializeDisplayCanvas(BoundingBox), but reading from either this session's main streamed source or its secondary (filtered) image - see buildMaterializedCrop(BoundingBox, boolean).
    • initialize

      public void initialize(ij.ImagePlus imp)
      Overrides:
      initialize in class MultiDThreePanes
    • initialize

      public void initialize(boolean singlePane, int channel, int frame)
      Initializes the plugin by assembling all the required tracing views
      Parameters:
      singlePane - if true only the XY view will be generated, if false XY, ZY, XZ views are created
      channel - the channel to be traced. Ignored when no valid image data exists.
      frame - the frame to be traced. Ignored when no valid image data exists.
    • initialize

      public void initialize(boolean singlePane, int channel, int frame, boolean computeStackStats)
    • reloadImage

      public void reloadImage(int channel, int frame)
    • rebuildZYXZpanes

      public void rebuildZYXZpanes()
    • startUI

      public void startUI()
    • startUI

      public void startUI(boolean bigDataMode)
    • loadTracings

      public boolean loadTracings(File file)
    • isUnsavedChanges

      protected boolean isUnsavedChanges()
    • setUnsavedChanges

      protected void setUnsavedChanges(boolean b)
    • getPathAndFillManager

      public PathAndFillManager getPathAndFillManager()
    • getSeedOverlay

      public SeedOverlay getSeedOverlay()
      Returns the SeedOverlay associated with this SNT instance. The overlay holds candidate SeedPoints (e.g., output of upstream point detectors) and is rendered on the tracing canvas when non-empty.

      The overlay is transient: it is automatically cleared when the active image changes (see initialize(ImagePlus)) and is not persisted with the .traces file. Importers should use SeedOverlay.addAll(java.util.Collection) for bulk loads.

      Returns:
      the seed overlay (never null)
    • getCanvas

      public TracerCanvas getCanvas(int pane)
    • getDataset

      public net.imagej.Dataset getDataset()
      Gets the Image being traced as Dataset. If the loaded image has been closed, cached pixel data is returned as per getLoadedDataAsImp(). If no resident ImagePlus exists at all (e.g., data streamed from disk/network, backed only by ctSlice3d), a Dataset is instead built directly from getLoadedDataAsImg(boolean), so Dataset-only commands. Null is returned if no image data exists at all.

      NB: in the streamed-data fallback, the returned Dataset only ever contains a single channel/ frame (whichever is currently active): ctSlice3d is a single C/T slice by construction. Commands that need every channel or frame simultaneously will still require a resident ImagePlus.

      NB2: a materialized crop (see isMaterializedCrop()) always has a resident ImagePlus (the crop itself), so it never takes the streamed-data fallback above, returning the crop's own Dataset as-is, matching whatever buildMaterializedCrop(BoundingBox) captured (see getMaterializedCropChannel()/getMaterializedCropFrame()).

    • getImagePlus

      public ij.ImagePlus getImagePlus()
      Gets the Image being traced. If the loaded image has been closed, cached pixel data is returned as per getLoadedDataAsImp(). Null is returned if no image exists.
    • getImpDiagonalLength

      protected double getImpDiagonalLength(boolean scaled, boolean xyOnly)
    • createCanvas

      public sc.fiji.snt.InteractiveTracerCanvas createCanvas(ij.ImagePlus imagePlus, int plane)
      Overrides:
      createCanvas in class MultiDThreePanes
    • dispose

      protected void dispose()
    • cancelSearch

      public void cancelSearch(boolean cancelFillToo)
    • threadStatus

      public void threadStatus(SearchInterface source, int status)
      Specified by:
      threadStatus in interface SearchProgressCallback
    • changeUIState

      public void changeUIState(int newState)
    • getUIState

      protected int getUIState()
    • saveFill

      protected void saveFill()
    • discardFill

      protected void discardFill()
    • stopFilling

      protected void stopFilling(boolean updateUIState)
    • stopFilling

      protected void stopFilling()
    • startFilling

      protected void startFilling()
    • addListener

      public void addListener(SNTListener listener)
    • notifyListeners

      public void notifyListeners(SNTEvent event)
    • anyListeners

      protected boolean anyListeners()
    • finished

      public void finished(SearchInterface source, boolean success)
      Specified by:
      finished in interface SearchProgressCallback
    • pointsInSearch

      public void pointsInSearch(SearchInterface source, long inOpen, long inClosed)
      Specified by:
      pointsInSearch in interface SearchProgressCallback
    • justDisplayNearSlices

      protected void justDisplayNearSlices(boolean value, int eitherSide)
    • uiReadyForModeChange

      protected boolean uiReadyForModeChange()
    • getEditingPath

      protected Path getEditingPath()
    • getPreviousEditingPath

      protected Path getPreviousEditingPath()
    • getEditingNode

      protected int getEditingNode()
    • editModeAllowed

      public boolean editModeAllowed()
      Assesses if activation of 'Edit Mode' is possible.
      Returns:
      true, if possible, false otherwise
    • editModeAllowed

      protected boolean editModeAllowed(boolean warnUserIfNot)
      Checks if edit mode can be enabled.
      Parameters:
      warnUserIfNot - if true, shows error messages when edit mode is not allowed
      Returns:
      true if edit mode is allowed, false otherwise
    • editModeAllowed

      protected boolean editModeAllowed(boolean warnUserIfNot, Path pathToEdit)
      Checks if edit mode can be enabled, optionally using a specific path.
      Parameters:
      warnUserIfNot - if true, shows error messages when edit mode is not allowed
      pathToEdit - the path to edit, or null to auto-detect from selection
      Returns:
      true if edit mode is allowed, false otherwise
    • isEditingFittedPath

      protected boolean isEditingFittedPath()
      Returns whether the path currently being edited is displayed as its fitted version. Callers should use this to guard edit operations that cannot meaningfully propagate between fitted and unfitted representations (e.g., structural edits such as insert/delete, or tree-level operations like split/re-root).
      Returns:
      true if the editing path is in fitted-display mode
    • setEditingPath

      protected void setEditingPath(Path path)
    • detectEditingPath

      protected void detectEditingPath()
    • getSingleSelectedPath

      protected Path getSingleSelectedPath()
    • enableEditMode

      protected void enableEditMode(boolean enable)
    • pause

      protected void pause(boolean pause, boolean hideSideViewsOnPause)
    • pauseTracing

      protected void pauseTracing(boolean pause, boolean validateChange)
    • isEditModeEnabled

      protected boolean isEditModeEnabled()
    • updateCursor

      protected void updateCursor(double new_x, double new_y, double new_z)
    • loadLabelsFile

      public void loadLabelsFile(String path)
    • loadTracesFile

      protected boolean loadTracesFile(File file)
      Assumes UI is available
    • loadSWCFile

      protected boolean loadSWCFile(File file)
    • mouseMovedTo

      public void mouseMovedTo(double x_in_pane, double y_in_pane, int in_plane, boolean sync_panes_modifier_down, boolean join_modifier_down)
    • setTemporaryPath

      public void setTemporaryPath(Path path)
    • setCurrentPath

      public void setCurrentPath(Path path)
    • getCurrentPath

      public Path getCurrentPath()
    • setPathUnfinished

      protected void setPathUnfinished(boolean unfinished)
    • makePathVolume

      public ij.ImagePlus makePathVolume(Collection<Path> paths, boolean labelsImage)
      Rasterizes centerline of paths into an ImagePlus
      Parameters:
      labelsImage - If true, each path has a unique intensity; otherwise all nodes are set to 255 (8-bit Binary)
      Returns:
      the ImagePlus with embedded centerlines
    • startRubberBandSearch

      protected void startRubberBandSearch(double x_in_pane, double y_in_pane, int plane)
    • computeImgStats

      protected <T extends net.imglib2.type.numeric.RealType<T>> ij.process.ImageStatistics computeImgStats(Iterable<T> in, ij.process.ImageStatistics imgStats)
    • computeImgStats

      public <T extends net.imglib2.type.numeric.RealType<T>> ij.process.ImageStatistics computeImgStats(Iterable<T> in, ij.process.ImageStatistics imgStats, SNT.CostType costType)
    • snapshotSearchSettings

      public SNT.SearchSettingsSnapshot snapshotSearchSettings()
      Captures the search settings currently configured on this instance, for use by long-running batch callers that need to stay internally consistent even if these settings are changed (via the UI) partway through the run. See SNT.SearchSettingsSnapshot.
      Returns:
      an immutable snapshot of the current cost function, data structure, and secondary (filtered) image state
    • confirmTemporary

      public void confirmTemporary(boolean updateTracingViewers)
    • cancelTemporary

      public void cancelTemporary()
    • cancelPath

      public void cancelPath()
      Cancels the temporary path.
    • startHessian

      @Deprecated public void startHessian(String image, double sigma, double max, boolean wait)
      Deprecated.
      Constructs and enables a lazy instance of a Tubeness filter. The image is filtered locally during path searches. Filtered data is stored in a disk cache when memory runs full. This method is slated for redesign.
      Parameters:
      image - the image to filter, either "primary" or "secondary".
      sigma - the scale parameter for the Tubeness filter, in physical units.
      max - the maximum pixel intensity in the Tubeness image beyond which the cost function of the A* search is minimized.
      wait - this parameter does nothing.
    • startHessian

      public <T extends net.imglib2.type.numeric.RealType<T>> void startHessian(String image, String filter, double[] scales, String strategy, int nThreads)
      Constructs and enables an instance of a hessian eigenvalue filter. If the strategy is "preprocess", the entire filtered image, including intensity statistics, are pre-computed and stored in memory. If the strategy is "lazy", the image is filtered and measured locally during path searches, and filtered data is stored in a disk cache when memory runs full. If you are tracing over a large image or if you are in a memory-limited environment, you should choose "lazy".
      Type Parameters:
      T -
      Parameters:
      image - the image to filter, either "primary" or "secondary".
      filter - the hessian filter type, either "tubeness" or "frangi"
      scales - the scale parameters for the Hessian filter, in physical units. Computation time increases linearly with the number of scales.
      strategy - either "lazy" or "preprocess"
      nThreads - number of threads to use in the computation
    • startHessian

      public <T extends net.imglib2.type.numeric.RealType<T>> void startHessian(String image, String filter, double[] scales, double min, double max, String strategy, int nThreads)
      Constructs and enables an instance of a hessian eigenvalue filter. If the strategy is "preprocess", the entire filtered image is pre-computed and stored in memory. If the strategy is "lazy", the image is filtered locally during path searches, and filtered data is stored in a disk cache when memory runs full. If you are tracing over a large image or if you are in a memory-limited environment, you should choose "lazy".
      Type Parameters:
      T -
      Parameters:
      image - the image to filter, either "primary" or "secondary".
      filter - the hessian filter type, either "tubeness" or "frangi"
      scales - the scale parameters for the Hessian filter, in physical units. Computation time increases linearly with the number of scales.
      min - the minimum pixel intensity in the filtered image beyond which the cost function of the A* search is maximized.
      max - the maximum pixel intensity in the filtered image beyond which the cost function of the A* search is minimized.
      strategy - either "lazy" or "preprocess"
      nThreads - number of threads to use in the computation
    • autoTrace

      public Path autoTrace(SNTPoint start, SNTPoint end, PointInImage forkPoint)
      Automatically traces a path from a point A to a point B. See autoTrace(List, PointInImage) for details.
      Parameters:
      start - the PointInImage the starting point of the path
      end - the PointInImage the terminal point of the path
      forkPoint - the PointInImage fork point of the parent Path from which the searched path should branch off, or null if the path should not have any parent.
      Returns:
      the path a reference to the computed path.
      See Also:
    • autoTrace

      public Path autoTrace(SNTPoint start, SNTPoint end, PointInImage forkPoint, boolean headless)
      Automatically traces a path from a point A to a point B. See autoTrace(List, PointInImage) for details.
      Parameters:
      start - the PointInImage the starting point of the path
      end - the PointInImage the terminal point of the path
      forkPoint - the PointInImage fork point of the parent Path from which the searched path should branch off, or null if the path should not have any parent.
      headless - whether search should occur headless
      Returns:
      the path a reference to the computed path.
      See Also:
    • manualTrace

      public Path manualTrace(SNTPoint start, SNTPoint end, PointInImage forkPoint)
      Manually traces a straight path from a point A to a point B, bypassing A* (or any other configured SearchInterface) entirely: the two points are simply connected via ManualTracerThread. Unlike autoTrace(SNTPoint, SNTPoint, PointInImage, boolean), this method does not depend on, or alter, isAstarEnabled(). Runs headless (no SNTUI state changes) and, since it does not search the image, is cheap enough to be safely called off the EDT.

      The returned path is not added to the Path Manager: callers are responsible for that (see PathAndFillManager.addPath(Path, boolean, boolean)).

      Parameters:
      start - the SNTPoint start of the path
      end - the SNTPoint end of the path
      forkPoint - the PointInImage fork point of the parent Path from which the path should branch off, or null if the path should not have any parent.
      Returns:
      the path a reference to the computed path.
    • autoTrace

      public Path autoTrace(SNTPoint start, SNTPoint end, PointInImage forkPoint, SearchProgressCallback progressCallback, Consumer<Future<?>> onSubmit)
      Headless auto-trace variant that additionally reports progress and exposes the underlying Future for cancellation. Always runs headless (regardless of GraphicsEnvironment.isHeadless()); intended for callers (e.g., BVV's tracing toggle) that need live feedback and/or the ability to cancel a slow search, e.g., over a lazily-loaded, network-backed image where a single segment can take a long time to converge (or never converge, if the goal is unreachable).
      Parameters:
      start - the start point
      end - the end point
      forkPoint - the fork point of the parent Path from which the path should branch off, or null if the path should not have any parent
      progressCallback - receives periodic pointsInSearch/finished/ threadStatus updates (roughly once a second; see reportEveryMilliseconds), or null to skip progress reporting
      onSubmit - called with the search's Future immediately after it is submitted to the tracer thread pool, so the caller can cancel it later (e.g. future.cancel(true)); the search loop already checks for interruption, so this actually stops the search rather than merely abandoning it. May be null.
      Returns:
      the path, or null if the search failed or was cancelled
    • autoTrace

      public Path autoTrace(List<SNTPoint> pointList, PointInImage forkPoint)
      Automatically traces a path from a list of points and adds it to the active PathAndFillManager instance. Note that this method still requires SNT's UI. For headless auto-tracing have a look at TracerThread.

      SNT's UI will remain blocked in "search mode" until the Path computation completes. Tracing occurs through the active SearchInterface selected in the UI, i.e., TracerThread (the default A* search), TubularGeodesicsTracer, etc.

      All input PointInImage must be specified in real world coordinates.

      Parameters:
      pointList - the list of PointInImage containing the nodes to be used as target goals during the search. If the search cannot converge into a target point, such point is omitted from path, if Successful, target point will be included in the final path. The final path. The first point in the list is the start of the path, the last its terminus. Null objects not allowed.
      forkPoint - the PointInImage fork point of the parent Path from which the searched path should branch off, or null if the path should not have any parent.
      Returns:
      the path a reference to the computed path. It is added to the Path Manager list. If a path cannot be fully computed from the specified list of points, a single-point path is generated.
    • autoTrace

      public Path autoTrace(List<SNTPoint> pointList, PointInImage forkPoint, boolean headless)
      Automatically traces a path from a point A to a point B. See autoTrace(List, PointInImage) for details.
      Parameters:
      pointList - the list of PointInImage containing the nodes to be used as target goals during the search. If the search cannot converge into a target point, such point is omitted from path, if Successful, target point will be included in the final path. The final path. The first point in the list is the start of the path, the last its terminus. Null objects not allowed.
      forkPoint - the PointInImage fork point of the parent Path from which the searched path should branch off, or null if the path should not have any parent.
      headless - whether search should occur headless
      Returns:
      the path a reference to the computed path.
      See Also:
    • autoTraceSync

      public Path autoTraceSync(List<SNTPoint> pointList, PointInImage forkPoint)
      Synchronous, thread-agnostic counterpart to autoTrace(List, PointInImage, boolean): traces each consecutive pair of waypoints using the currently configured A* search parameters (cost function, hessian, image data) entirely on the calling thread, without submitting to tracerThreadPool.

      Intended for background/batch callers that already run on their own dedicated worker threads (e.g. AStarRefiner) and want genuine cross-path parallelism

      Parameters:
      pointList - the waypoints to connect, start to end
      forkPoint - optional fork point of the parent Path, or null
      Returns:
      the stitched path, or null if any segment failed to produce a result
    • autoTraceSync

      public Path autoTraceSync(List<SNTPoint> pointList, PointInImage forkPoint, SNT.SearchSettingsSnapshot settings)
      Variant of autoTraceSync(List, PointInImage) that uses a frozen SNT.SearchSettingsSnapshot instead of the live cost function/data structure/secondary-image settings, so every segment of every path in a long-running batch (e.g. AStarRefiner) is traced with identical settings, immune to changes made mid-run via the (deliberately still enabled) A* controls.
      Parameters:
      pointList - the waypoints to connect, start to end
      forkPoint - optional fork point of the parent Path, or null
      settings - a snapshot from snapshotSearchSettings(), or null to read the live settings (equivalent to autoTraceSync(List, PointInImage))
      Returns:
      the stitched path, or null if any segment failed to produce a result
    • replaceCurrentPath

      protected void replaceCurrentPath(Path path)
    • finishedPath

      protected void finishedPath()
    • clickForTrace

      protected void clickForTrace(org.jogamp.vecmath.Point3d p, boolean join)
    • clickForTrace

      protected void clickForTrace(double world_x, double world_y, double world_z, boolean join)
    • clickForTrace

      protected void clickForTrace(double x_in_pane_precise, double y_in_pane_precise, int plane, boolean join)
    • setFillThresholdFrom

      public void setFillThresholdFrom(double world_x, double world_y, double world_z)
    • setFillThreshold

      public void setFillThreshold(double distance) throws IllegalArgumentException
      Sets the fill threshold distance. Typically, this value is set before a filling operation as a starting value for the FillerThread.
      Parameters:
      distance - the new threshold distance. Set it to -1 to use SNT's default.
      Throws:
      IllegalArgumentException - If distance is not a valid positive value
    • getFillThreshold

      public double getFillThreshold()
    • setStoreExtraFillNodes

      public void setStoreExtraFillNodes(boolean storeExtraFillNodes)
    • setStopFillAtThreshold

      public void setStopFillAtThreshold(boolean stopFillAtThreshold)
    • addSphere

      protected void addSphere(String name, double x, double y, double z, Color color, double radius)
    • removeSphere

      protected void removeSphere(String name)
    • startSholl

      protected void startSholl(PointInImage centerScaled)
    • getFilledBinaryImp

      public ij.ImagePlus getFilledBinaryImp()
    • getFilledImp

      public <T extends net.imglib2.type.numeric.RealType<T>> ij.ImagePlus getFilledImp()
    • getFilledDistanceImp

      public ij.ImagePlus getFilledDistanceImp()
    • getFilledLabelImp

      public <T extends net.imglib2.type.numeric.IntegerType<T>> ij.ImagePlus getFilledLabelImp()
    • guessResamplingFactor

      protected int guessResamplingFactor()
    • isUIready

      protected boolean isUIready()
    • addFillerThread

      public void addFillerThread(FillerThread filler)
    • initPathsToFill

      public void initPathsToFill(Set<Path> fromPaths, boolean splitFillerThreads)
    • invalidStatsError

      protected <T extends net.imglib2.type.numeric.RealType<T>> boolean invalidStatsError(boolean isSecondary)
    • setFillTransparent

      protected void setFillTransparent(boolean transparent)
    • getMinimumSeparation

      public double getMinimumSeparation()
    • getAverageSeparation

      public double getAverageSeparation()
    • getLoadedDataAsImp

      public <T extends net.imglib2.type.numeric.RealType<T>> ij.ImagePlus getLoadedDataAsImp()
      Retrieves the pixel data of the main image currently loaded in memory as an ImagePlus object. Returned image is always a single channel image.
      Returns:
      the loaded data corresponding to the C,T position currently being traced, or null if no image data has been loaded into memory.
    • getLoadedData

      public <T extends net.imglib2.type.numeric.RealType<T>> net.imglib2.RandomAccessibleInterval<T> getLoadedData()
    • getBdvTracingData

      public net.imglib2.RandomAccessibleInterval<?> getBdvTracingData()
      Non-generic wrapper around getStreamedOrLoadedData(), for callers outside this class that need BDV/BVV's own crop-independent view of the pixel data currently being traced - e.g. the Sigma preview palette (see AbstractBigViewer#pickSigmaPointAction()), which must show data around the point actually clicked in BDV/BVV, not clamped to whatever (possibly smaller) crop happens to be materialized on the classic canvas at the same time. Pair with getDefaultCanvasPixelOffset() for converting a click into a pixel index into this data.
      Returns:
      the same data as getStreamedOrLoadedData()
    • getLoadedDataAsImg

      public net.imagej.ImgPlus<?> getLoadedDataAsImg(boolean secondaryLayer)
    • getLoadedIterable

      public <T> net.imglib2.IterableInterval getLoadedIterable()
    • getFilteredImageFile

      protected File getFilteredImageFile()
      Returns the file of the 'secondary image', if any.
      Returns:
      the secondary image file, or null if no file has been set
    • isSecondaryDataAvailable

      public boolean isSecondaryDataAvailable()
      Assesses if the 'secondary image' has been loaded into memory. Note that while some tracer Threads will load the image into memory, others may waive the loading to third party libraries
      Returns:
      true, if image has been loaded into memory.
    • isSecondaryImageFileLoaded

      protected boolean isSecondaryImageFileLoaded()
    • isTracingOnSecondaryImageAvailable

      protected boolean isTracingOnSecondaryImageAvailable()
    • setSecondaryImage

      public void setSecondaryImage(File file)
      Specifies the 'secondary image' to be used during a tracing session.
      Parameters:
      file - The file containing the 'secondary image'
    • loadSecondaryImage

      public void loadSecondaryImage(File file) throws IOException, IllegalArgumentException
      Loads the 'secondary image' specified by setSecondaryImage(File) into memory as 32-bit data.
      Parameters:
      file - The file to be loaded
      Throws:
      IOException - If image could not be loaded
      IllegalArgumentException - if dimensions are unexpected, or image type is not supported
      See Also:
    • loadSecondaryImage

      public void loadSecondaryImage(ij.ImagePlus imp) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • loadSecondaryImage

      public <T extends net.imglib2.type.numeric.RealType<T>> void loadSecondaryImage(net.imglib2.RandomAccessibleInterval<T> img, boolean computeStatistics)
    • setSecondaryImageMinMax

      public void setSecondaryImageMinMax(double min, double max)
    • getSecondaryImageMinMax

      public double[] getSecondaryImageMinMax()
    • loadSecondaryImage

      protected void loadSecondaryImage(ij.ImagePlus imp, boolean changeUIState)
    • loadSecondaryImage

      protected <T extends net.imglib2.type.numeric.RealType<T>> void loadSecondaryImage(net.imglib2.RandomAccessibleInterval<T> img, boolean changeUIState, boolean computeStatistics)
    • enableSecondaryLayerTracing

      public void enableSecondaryLayerTracing(boolean enable)
    • flushSecondaryData

      public void flushSecondaryData()
    • sameXYZDimensionsAsTracingData

      public boolean sameXYZDimensionsAsTracingData(ij.ImagePlus imp)
      Checks if imp shares the same XYZ voxel dimensions as the image currently being traced. Compares against the classic tracing ImagePlus (MultiDThreePanes.xy) when one exists; in Stream mode compares against the streamed primary volume's own dimensions (getLoadedData()) instead. Used to validate a candidate secondary layer before loading it.
      Parameters:
      imp - the candidate image
      Returns:
      true if dimensions match; false if they don't, or if no tracing data is loaded to compare against
    • sameXYZDimensionsAsTracingData

      public boolean sameXYZDimensionsAsTracingData(net.imglib2.RandomAccessibleInterval<?> data)
      RAI-based overload of sameXYZDimensionsAsTracingData(ImagePlus), for candidate sources that never go through an ImagePlus at all (e.g. a big-data secondary layer resolved via SpimDataUtils.resolvePathToSource(String)). Compares XYZ dimensions directly against getLoadedData(), so unlike the ImagePlus overload this works the same regardless of whether MultiDThreePanes.xy exists.
      Parameters:
      data - the candidate image data
      Returns:
      true if dimensions match; false if they don't, or if no tracing data is loaded to compare against
    • getSecondaryDataAsImp

      public <T extends net.imglib2.type.numeric.NumericType<T>> ij.ImagePlus getSecondaryDataAsImp()
      Retrieves the 'secondary image' data currently loaded in memory as an ImagePlus object. Returned image is always of 32-bit type.
      Returns:
      the loaded data or null if no image has been loaded.
      See Also:
    • getSecondaryData

      public <T extends net.imglib2.type.numeric.RealType<T>> net.imglib2.RandomAccessibleInterval<T> getSecondaryData()
    • getPrefs

      public SNTPrefs getPrefs()
    • proportionDone

      public void proportionDone(double proportion)
      Specified by:
      proportionDone in interface HessianGenerationCallback
    • showCorrespondencesTo

      @Deprecated public void showCorrespondencesTo(File tracesFile, Color c, double maxDistance)
      Deprecated.
    • setShowOnlySelectedPaths

      protected void setShowOnlySelectedPaths(boolean showOnlySelectedPaths, boolean updateGUI)
    • setShowOnlyActiveCTposPaths

      protected void setShowOnlyActiveCTposPaths(boolean showOnlyActiveCTposPaths, boolean updateGUI)
    • isShowOnlyActiveCTposPaths

      public boolean isShowOnlyActiveCTposPaths()
      Returns:
      whether only paths matching the current channel/frame position are being displayed (classic canvas), or, for Bvv/Bdv, only paths matching the current timepoint
    • setShowOnlySelectedPaths

      public void setShowOnlySelectedPaths(boolean showOnlySelectedPaths)
    • setIsolatedTreeID

      public void setIsolatedTreeID(int treeID)
      Isolates a single tree (arbor) for display across every tracing viewer, hiding paths belonging to any other tree. Orthogonal to setShowOnlySelectedPaths(boolean): does not touch path selection or rendered colors, it only restricts which trees are candidates for display at all. Pass -1 (or call clearIsolatedTreeID()) to lift the restriction.
      Parameters:
      treeID - the ID of the tree to isolate (see Tree.getTreeID()), or -1 to show all
      See Also:
    • clearIsolatedTreeID

      public void clearIsolatedTreeID()
      Convenience for setIsolatedTreeID(-1): lifts any active tree isolation.
    • getIsolatedTreeID

      public int getIsolatedTreeID()
      Returns:
      the ID of the currently isolated tree, or -1 if no isolation is active
    • isTreeIsolationActive

      public boolean isTreeIsolationActive()
      Returns:
      whether a single tree is currently isolated for display (see setIsolatedTreeID(int))
    • getImagePlus

      public ij.ImagePlus getImagePlus(int pane)
      Gets the Image associated with a view pane.
      Parameters:
      pane - the flag specifying the view either MultiDThreePanes.XY_PLANE, MultiDThreePanes.XZ_PLANE or MultiDThreePanes.ZY_PLANE.
      Returns:
      the image associate with the specified view, or null if the view is not available. If the view is XY_PLANE, and the image has been closed, cached pixel data is returned as per getLoadedDataAsImp()
    • error

      protected void error(String msg)
    • showMessage

      protected void showMessage(String msg, String title)
    • getTracingCanvas

      protected sc.fiji.snt.InteractiveTracerCanvas getTracingCanvas()
    • getActiveWindow

      protected Component getActiveWindow()
    • isOnlySelectedPathsVisible

      public boolean isOnlySelectedPathsVisible()
    • updateTracingViewers

      protected void updateTracingViewers(boolean includeLegacy3Dviewer)
    • updateTracingViewers

      protected void updateTracingViewers(boolean includeLegacy3Dviewer, boolean selectionOnly)
      Parameters:
      includeLegacy3Dviewer - whether to also refresh the legacy 3D viewer
      selectionOnly - if true, this update is known to be a pure Path Manager selection change (no paths added/removed/edited): BVV is refreshed via the cheaper Bvv#updateSelection() (patches color/thickness in place) instead of a full Bvv#syncPathManagerList() rebuild.
    • updateNonTracingViewers

      protected void updateNonTracingViewers()
    • updateAllViewers

      public void updateAllViewers()
    • get3DUniverse

      @Deprecated protected ij3d.Image3DUniverse get3DUniverse()
      Deprecated.
      Gets the instance of the legacy 3D viewer universe. Note that the legacy 3D viewer is now deprecated.
      Returns:
      a reference to the 3DUniverse or null if no universe has been set
    • set3DUniverse

      protected void set3DUniverse(ij3d.Image3DUniverse universe)
    • updateImageContent

      @Deprecated protected void updateImageContent(int resamplingFactor)
      Deprecated.
    • setSelectedAndDeselectedColors

      protected void setSelectedAndDeselectedColors(Color newSelectedColor, Color newDeselectedColor)
      Sets default path colors.
      Parameters:
      newSelectedColor - new default color for selected paths
      newDeselectedColor - new default color for deselected paths
    • setColorImage

      @Deprecated protected void setColorImage(ij.ImagePlus newColorImage)
      Deprecated.
    • setPaths3DDisplay

      @Deprecated protected void setPaths3DDisplay(int paths3DDisplay)
      Deprecated.
    • getPaths3DDisplay

      @Deprecated protected int getPaths3DDisplay()
      Deprecated.
    • selectPath

      public void selectPath(Path p, boolean addToExistingSelection)
    • getSelectedPaths

      public Collection<Path> getSelectedPaths()
    • setPathList

      public void setPathList(List<Path> pathList, Path justAdded, boolean expandAll)
    • setFillList

      public void setFillList(List<Fill> fillList)
    • setSelectedPaths

      public void setSelectedPaths(Collection<Path> selectedPathsSet, Object source)
    • findSnappingPointInXView

      protected void findSnappingPointInXView(double x_in_pane, double y_in_pane, double[] point)
    • clickAtMaxPoint

      protected void clickAtMaxPoint(int x_in_pane, int y_in_pane, int plane, boolean join)
    • showMIPOverlays

      public void showMIPOverlays(double opacity)
      Overlays a semi-transparent MIP (8-bit scaled) of the data being traced over the tracing canvas(es). Does nothing if image is 2D. Note that with multidimensional images, only the C,T position being traced is projected.
      Parameters:
      opacity - (alpha), in the range 0.0-1.0, where 0.0 is none (fully transparent) and 1.0 is fully opaque. Setting opacity to zero clears previous MIPs.
    • showMIPOverlays

      protected void showMIPOverlays(boolean filteredData, double opacity)
    • discreteMsg

      protected void discreteMsg(String msg)
    • showCanvasWarning

      protected void showCanvasWarning(String msg, int durationMs)
      Displays a timed warning (amber background) on the canvas banner.
      Parameters:
      msg - the warning text, or null to clear immediately
      durationMs - how long the label stays visible (milliseconds)
    • showCanvasWarning

      protected void showCanvasWarning(String msg)
      See Also:
    • showCanvasInfo

      protected void showCanvasInfo(String msg, int durationMs)
      Displays a timed informational message (blue background) on the canvas banner. Use for confirmations, status updates, and non-critical feedback.
      Parameters:
      msg - the info text, or null to clear immediately
      durationMs - how long the label stays visible (milliseconds)
    • showCanvasInfo

      protected void showCanvasInfo(String msg)
      See Also:
    • getConfirmation

      protected boolean getConfirmation(String msg, String title)
    • toggleSnapCursor

      protected void toggleSnapCursor()
    • setAnnotationsVisible

      public void setAnnotationsVisible(boolean visible)
      Enables/Disables SNT overlays over tracing views. Note that disabling overlays will also suppress most GUI-related operations.
      Parameters:
      visible - whether overlays should be rendered
    • enableSnapCursor

      public void enableSnapCursor(boolean enable)
      Enables SNT's XYZ snap cursor feature. Does nothing if no image data is available or currently loaded image is binary
      Parameters:
      enable - whether cursor snapping should be enabled
    • isTracingOnSecondaryImageActive

      public boolean isTracingOnSecondaryImageActive()
    • enableAstar

      public void enableAstar(boolean enable)
      Toggles the A* search algorithm (enabled by default)
      Parameters:
      enable - true to enable A* search, false otherwise
    • isAstarEnabled

      public boolean isAstarEnabled()
      Checks if A* search is enabled
      Returns:
      true, if A* search is enabled, otherwise false
    • is2D

      public boolean is2D()
      Returns:
      true if the image currently loaded does not have a depth (Z) dimension
    • setDrawDiameters

      public void setDrawDiameters(boolean draw)
    • getDrawDiameters

      public boolean getDrawDiameters()
    • closeAndResetAllPanes

      public void closeAndResetAllPanes()
      Overrides:
      closeAndResetAllPanes in class MultiDThreePanes
    • getContext

      public org.scijava.Context getContext()
    • getUI

      public SNTUI getUI()
      Gets the main UI.
      Returns:
      the main dialog of SNT's UI
    • isStreamMode

      public boolean isStreamMode()
      Returns whether this session is running in stream mode ("SNT Stream"), i.e., without access to a full in-core materialized image but rather a lazily-loaded BDV/BVV-backed source (typically an OME-Zarr/N5 dataset; see BigDataLoaderCmd).
      Returns:
      true if in stream mode
    • getImageFilenamePrefix

      public String getImageFilenamePrefix()
      Returns a filesystem-safe basename identifying the image currently being traced, for use as a prefix when generating output filenames (backups, exported bookmarks, notes, etc). Handles both standard mode (title of getImagePlus()) and stream mode (title of the source loaded in the active big viewer, if any).
      Returns:
      the sanitized, extension-stripped image basename, or a fallback placeholder ("streamed_data"/"snt_data") if unavailable
    • showStatus

      public void showStatus(int progress, int maximum, String status)
      Description copied from interface: PaneOwner
      Shows a status message with progress information.
      Specified by:
      showStatus in interface PaneOwner
      Overrides:
      showStatus in class MultiDThreePanes
      Parameters:
      progress - the current progress value
      maximum - the maximum progress value
      status - the status message to display
    • getOneMinusErfZFudge

      protected double getOneMinusErfZFudge()
    • getStats

      public ij.process.ImageStatistics getStats()
    • getStatsSecondary

      public ij.process.ImageStatistics getStatsSecondary()
    • setUseSubVolumeStats

      public void setUseSubVolumeStats(boolean useSubVolumeStatistics)
    • getUseSubVolumeStats

      public boolean getUseSubVolumeStats()
    • getSearchType

      public SNT.SearchType getSearchType()
    • setSearchType

      public void setSearchType(SNT.SearchType searchType)
    • getCostType

      public SNT.CostType getCostType()
    • setCostType

      public void setCostType(SNT.CostType costType)
    • getHeuristicType

      public SNT.HeuristicType getHeuristicType()
    • setHeuristicType

      public void setHeuristicType(SNT.HeuristicType heuristicType)
    • getSearchImageType

      public SNT.SearchImageType getSearchImageType()
    • setSearchImageType

      public void setSearchImageType(SNT.SearchImageType searchImageType)
    • getFilterType

      public SNT.FilterType getFilterType()
    • setFilterType

      public void setFilterType(SNT.FilterType filterType)
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getDepth

      public int getDepth()
    • setImageMetadata

      public void setImageMetadata(int width, int height, int depth, double xSpacing, double ySpacing, double zSpacing, String units)
      Sets image dimensions and calibration without providing actual pixel data. Useful when the source image is not directly accessible as random-access data (e.g., a BigDataViewer AbstractSpimData/IMS source, or an ambiguous N5/Zarr layout) but its metadata (size, voxel spacing) is still known. This allows features that only need bounds/scale (e.g., manual tracing, bounds/distance checks) to work correctly with the image's real dimensions, even though accessToValidImageData() keeps reporting no data is available (this does NOT set ctSlice3d, so A* search remains unavailable).
      Parameters:
      width - width in pixels (ignored if ≤0)
      height - height in pixels (ignored if ≤0)
      depth - depth (number of slices) in pixels (ignored if ≤0)
      xSpacing - pixel width (ignored if ≤0)
      ySpacing - pixel height (ignored if ≤0)
      zSpacing - pixel depth (ignored if ≤0)
      units - spatial calibration units (ignored if null/blank)
    • setWorldOriginOffset

      public void setWorldOriginOffset(double xOffset, double yOffset, double zOffset)
      Sets a rigid world-space origin offset (in calibrated units) to be applied on top of the usual voxelIndex * spacing coordinate mapping. Not needed for a normally-loaded ImgPlus (its calibration/origin is assumed anchored at world (0,0,0)), but required when pixel data was wired in via setImageData(net.imglib2.RandomAccessibleInterval<?>)/setImageMetadata(int, int, int, double, double, double, java.lang.String) from a source whose own coordinate frame is not anchored at (0,0,0) - e.g. a BigDataViewer/N5 Source whose sourceTransform carries a translation (see BigDataLoaderCmd#applyFallbackCalibration).

      This offset is not applied automatically to coordinates read elsewhere in this class (e.g. manual tracing, A* search); callers that produce Tree/Path results from such a source are responsible for applying it themselves, e.g. via Tree.translate(double, double, double).

      Not the same thing as ij.measure.Calibration#xOrigin/yOrigin/zOrigin (nor a drop-in replacement for it), despite the similar name/purpose. The two use different conventions and are not numerically interchangeable:

      • This offset is applied in world space, after scaling: world = voxelIndex * spacing + offset.
      • Calibration's origin is applied in pixel space, before scaling (see Calibration#getRawX/Y/Z, and ShollPoint#rawZ for the equivalent hand-written formula): world = (voxelIndex - origin) * spacing, i.e. voxelIndex = world / spacing + origin.
      Converting between the two requires the spacing too (offset = -origin * spacing); they are not the same number and must not be assigned to/read from each other directly. getCalibration() always returns spacing-only calibration objects with xOrigin/yOrigin/zOrigin left at their default of 0, regardless of this offset; callers needing pixel<->world conversions that account for this offset must use getWorldOriginOffset() directly (see BookmarkManager#pixelToWorld/ #worldToPixel for a worked example), not getCalibration() alone.
      Parameters:
      xOffset - x offset, in calibrated units
      yOffset - y offset, in calibrated units
      zOffset - z offset, in calibrated units
      See Also:
    • getWorldOriginOffset

      public double[] getWorldOriginOffset()
      Returns:
      the world-space origin offset (calibrated units) previously set via setWorldOriginOffset(double, double, double), as {xOffset, yOffset, zOffset}. All-zero (the default) unless explicitly set. See setWorldOriginOffset(double, double, double) for why this is distinct from ij.measure.Calibration's own xOrigin/yOrigin/zOrigin fields.
    • setImageData

      public void setImageData(net.imglib2.RandomAccessibleInterval<?> data)
      Directly sets the image data backing A* search, without requiring an ImgPlus wrapper. Useful when pixel data comes from a source whose RandomAccessibleInterval is already resolved elsewhere (e.g., a BigDataViewer/SpimData ImgLoader, or a BDV/BVV Source), and building/discarding a full ImgPlus just to satisfy SNT(ImgPlus) would be wasteful, or would not preserve lazy/chunked access the way the original object does.

      Callers remain responsible for also calling setImageMetadata(int, int, int, double, double, double, java.lang.String) (or equivalent) with matching dimensions/calibration; this method does not attempt to infer them from data.

      data's pixel type must be a RealType; other types (e.g. ARGBType) will throw a ClassCastException later, e.g., the first time A* search accesses a pixel.

      Parameters:
      data - the (possibly lazily-backed) image data, in the same pixel/voxel grid implied by the dimensions/calibration set via setImageMetadata(int, int, int, double, double, double, java.lang.String)
    • setChannelAndFrame

      public void setChannelAndFrame(int channel, int frame)
      Sets the channel/frame (1-based, IJ hyperstack convention) to be associated with subsequently traced paths (via Path.setCTposition(int, int)), and, for manualTrace(sc.fiji.snt.util.SNTPoint, sc.fiji.snt.util.SNTPoint, sc.fiji.snt.util.PointInImage), with the pixel data A* search reads (see setImageData(net.imglib2.RandomAccessibleInterval<?>)).

      Useful alongside setImageData(net.imglib2.RandomAccessibleInterval<?>)/setImageMetadata(int, int, int, double, double, double, java.lang.String) when pixel data comes from a source with no single, already-loaded multichannel/multi-timepoint array to index into (e.g. each channel of a BigDataViewer/SpimData or N5/Zarr source is its own separate object): callers are responsible for keeping the three in sync when the active channel/timepoint changes.

      Parameters:
      channel - the channel (1-based index; coerced to 1 if ≤0)
      frame - the frame/timepoint (1-based index; coerced to 1 if ≤0)
    • getPixelWidth

      public double getPixelWidth()
    • getPixelHeight

      public double getPixelHeight()
    • getPixelDepth

      public double getPixelDepth()
    • getSpacingUnits

      public String getSpacingUnits()
    • getChannel

      public int getChannel()
    • getFrame

      public int getFrame()
    • setBatchRetraceChannelFrame

      public void setBatchRetraceChannelFrame(Integer channel, Integer frame)
      Sets or clears the channel/frame lock described in getBatchRetraceChannelFrame().
      Parameters:
      channel - 1-based channel, or null to clear the lock
      frame - 1-based frame, or null to clear the lock
    • getBatchRetraceChannelFrame

      public int[] getBatchRetraceChannelFrame()
      Returns:
      {channel, frame} (1-based) the active batch re-trace is running against, or null if none is active. See setBatchRetraceChannelFrame(java.lang.Integer, java.lang.Integer).
    • captureView

      public ij.ImagePlus captureView(String view, boolean project)
      Retrieves a WYSIWYG 'snapshot' of a tracing canvas.
      Parameters:
      view - A case-insensitive string specifying the canvas to be captured. Either "xy" (or "main"), "xz", "zy" or "3d" (for legacy's 3D Viewer).
      project - whether the snapshot of 3D image stacks should include its projection (MIP), or just the current plane
      Returns:
      the snapshot capture of the canvas as an RGB image
      Throws:
      UnsupportedOperationException - if SNT is not running
      IllegalArgumentException - if view is not a recognized option
    • captureView

      public ij.ImagePlus captureView(String view, org.scijava.util.ColorRGB backgroundColor) throws IllegalArgumentException
      Retrieves a WYSIWYG 'snapshot' of a tracing canvas without voxel data.
      Parameters:
      view - A case-insensitive string specifying the canvas to be captured. Either "xy" (or "main"), "xz", "zy" or "3d" (for legacy's 3D Viewer).
      backgroundColor - the background color of the canvas (string, hex, or html)
      Returns:
      the snapshot capture of the canvas as an RGB image
      Throws:
      UnsupportedOperationException - if SNT is not running
      IllegalArgumentException - if view or backgroundColor are not recognized