Class Bdv


public class Bdv extends AbstractBigViewer
SNT's BigDataViewer-based 2D slice viewer.

Complements Bvv for images where orthographic 2D slice navigation is preferable over GPU volume rendering. Because BDV uses orthographic projection, cursor coordinates returned by AbstractViewerPanel.getGlobalMouseCoordinates(net.imglib2.RealPositionable) are unambiguous at the current slice depth, making marker placement more accurate than in BVV.

This class extends AbstractBigViewer and shares tree management, calibration, and bookmark infrastructure with Bvv.

Path and annotation overlays reuse Bvv.PathOverlay and Bvv.AnnotationOverlay via the BigViewerPanel adapter, with dCam = Double.MAX_VALUE so the perspective factor evaluates to 1.0 (orthographic rendering, no foreshortening).

Usage (scripting)

 bdv = new Bdv()
 bdv.show(imp)
 bdv.addTree(tree)
 bdv.getMarkerManager().toggleViewerPanel()
 
Author:
Tiago Ferreira
See Also:
  • Constructor Details

    • Bdv

      public Bdv()
      Creates a standalone BDV viewer (not tethered to an SNT instance).
    • Bdv

      public Bdv(SNT snt)
      Creates a BDV viewer tethered to an SNT instance.
  • Method Details

    • getInstance

      public static Bdv getInstance()
      Returns the most recently created Bdv instance, or null. Convenience accessor for scripts.
    • show

      public bdv.util.BdvStackSource<?> show(ij.ImagePlus imp)
      Opens an ImagePlus in the BDV viewer.
      Parameters:
      imp - the image to display
      Returns:
      the BdvStackSource for the displayed image
    • show

      public <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>> bdv.util.BdvStackSource<?> show(net.imagej.ImgPlus<T> img)
      Opens a calibrated ImgPlus in the BDV viewer.
      Parameters:
      img - the image to display
      Returns:
      the BdvStackSource for the displayed image
    • show

      public <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>> bdv.util.BdvStackSource<?> show(net.imglib2.RandomAccessibleInterval<T> rai, double... calibration)
      Opens a 3D RAI with explicit calibration in the BDV viewer.
      Parameters:
      rai - the 3D volume
      calibration - voxel sizes [x, y, z]
      Returns:
      the BdvStackSource for the displayed image
    • showLoadedData

      public void showLoadedData()
      Displays the main tracing data from the associated SNT instance. This method is only available for BDV instances that are tethered to an SNT instance.
      Specified by:
      showLoadedData in class AbstractBigViewer
      Throws:
      IllegalArgumentException - if this is a standalone viewer or no valid image data is available
    • showSecondaryData

      public void showSecondaryData()
      Displays the secondary tracing data from the associated SNT instance. This method is only available for BDV instances that are tethered to an SNT instance.
      Specified by:
      showSecondaryData in class AbstractBigViewer
      Throws:
      IllegalArgumentException - if this is a standalone viewer or no valid image data is available
    • hideSecondaryData

      public void hideSecondaryData()
      Description copied from class: AbstractBigViewer
      Removes the secondary tracing data layer previously added by AbstractBigViewer.showSecondaryData() from this viewer, if one is currently displayed. No-op otherwise (e.g., standalone viewers, untethered instances, or when no secondary layer has been shown yet).
      Specified by:
      hideSecondaryData in class AbstractBigViewer
      See Also:
    • updateSecondaryLayerIndicator

      public void updateSecondaryLayerIndicator()
      Description copied from class: AbstractBigViewer
      Refreshes the persistent "secondary layer active" indicator shown in this viewer's SNT Controls card, reflecting SNT.isTracingOnSecondaryImageActive(). No-op if this is not a tethered, tracer-enabled instance (i.e., the indicator was never built). Safe to call from any thread.
      Specified by:
      updateSecondaryLayerIndicator in class AbstractBigViewer
    • show

      public List<bdv.util.BdvStackSource<?>> show(mpicbg.spim.data.generic.AbstractSpimData<?> spimData)
      Opens a SpimData dataset (HDF5/N5/Zarr/IMS/OME-TIFF via XML) in the BDV viewer. Populates AbstractBigViewer.cal, AbstractBigViewer.dims, and AbstractBigViewer.calUnit from the first setup's metadata so that calibration is available for tree/marker rendering.
      Parameters:
      spimData - the dataset to display
      Returns:
      list of BdvStackSources, one per setup, in setup order
    • show

      public List<bdv.util.BdvStackSource<?>> show(mpicbg.spim.data.generic.AbstractSpimData<?> spimData, String sourcePath)
      Opens a SpimData dataset and records its source file path for later reference (e.g., for export or re-opening). Delegates to show(AbstractSpimData).
      Parameters:
      spimData - the dataset to display
      sourcePath - the absolute file path from which spimData was loaded; ignored if null or blank
      Returns:
      list of BdvStackSources, one per setup
    • show

      public List<bdv.util.BdvStackSource<?>> show(SpimDataUtils.N5Sources n5Sources)
      Opens sources loaded from an N5 or OME-Zarr container (see SpimDataUtils.resolvePathToSource(String)). Unlike show(AbstractSpimData), there is no BDV-XML descriptor or AbstractSpimData involved: sources are built directly from the container's own N5/OME-NGFF metadata via n5-viewer_fiji.
      Parameters:
      n5Sources - the sources to display
      Returns:
      list of BdvStackSources, one per setup
    • getViewerFrame

      public bdv.viewer.ViewerFrame getViewerFrame()
      Description copied from class: AbstractBigViewer
      Returns the top-level Swing window for this viewer, or null if not yet open.
      Specified by:
      getViewerFrame in class AbstractBigViewer
    • getViewerSplitPanel

      protected JSplitPane getViewerSplitPanel()
      Description copied from class: AbstractBigViewer
      Returns the JSplitPane that separates the viewer canvas from the card panel. Both BDV and BVV frames expose this via their own getSplitPanel() methods, but those classes share no common supertype above JFrame, so this method lets subclasses expose the split pane without the abstract method returning a viewer-specific frame type.
      Specified by:
      getViewerSplitPanel in class AbstractBigViewer
    • getViewerWidth

      public int getViewerWidth()
      Description copied from class: AbstractBigViewer
      Returns the width of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.
      Specified by:
      getViewerWidth in class AbstractBigViewer
    • getViewerHeight

      public int getViewerHeight()
      Description copied from class: AbstractBigViewer
      Returns the height of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.
      Specified by:
      getViewerHeight in class AbstractBigViewer
    • getViewerTransform

      public net.imglib2.realtransform.AffineTransform3D getViewerTransform()
      Description copied from class: AbstractBigViewer
      Returns a snapshot of the current viewer-to-screen (world-to-screen) transform. The returned object is a copy; callers may modify it freely.
      Specified by:
      getViewerTransform in class AbstractBigViewer
    • setViewerTransform

      public void setViewerTransform(net.imglib2.realtransform.AffineTransform3D target, long durationMs)
      Description copied from class: AbstractBigViewer
      Animates the viewer transform to target over durationMs milliseconds. Use durationMs = 0 for an immediate jump.
      Specified by:
      setViewerTransform in class AbstractBigViewer
      Parameters:
      target - the desired world-to-screen transform
      durationMs - animation duration in milliseconds (0 = immediate)
    • showViewerMessage

      public void showViewerMessage(String msg)
      Description copied from class: AbstractBigViewer
      Displays a short status message in the viewer's overlay area.

      This is bdv-core/bvv-core's fading toast: it auto-dismisses after a few seconds. For an ongoing, non-auto-dismissing indication of a long-running operation, use AbstractBigViewer.updateStatus(java.lang.String, int, int) instead.

      Specified by:
      showViewerMessage in class AbstractBigViewer
      Parameters:
      msg - the message to show
    • getGlobalMouseCoordinates

      public void getGlobalMouseCoordinates(net.imglib2.RealPoint pos)
      Description copied from class: AbstractBigViewer
      Writes the current global (world-space) mouse position into pos. Callers must supply a pre-allocated RealPoint with at least 3 dimensions.
      Specified by:
      getGlobalMouseCoordinates in class AbstractBigViewer
      Parameters:
      pos - 3D point to receive the world-space cursor position
    • getCurrentSource

      protected bdv.viewer.SourceAndConverter<?> getCurrentSource()
      Description copied from class: AbstractBigViewer
      Returns the currently active source, or null if none.
      Specified by:
      getCurrentSource in class AbstractBigViewer
    • getViewerAction

      protected Action getViewerAction(String name)
      Description copied from class: AbstractBigViewer
      Looks up a named action from the viewer's keybindings action map. Returns null if the action is not registered or the viewer is not ready.
      Specified by:
      getViewerAction in class AbstractBigViewer
      Parameters:
      name - the action key (e.g., "align XY plane")
    • addMouseListenerToDisplay

      public void addMouseListenerToDisplay(MouseListener ml)
      Description copied from class: AbstractBigViewer
      Adds a mouse listener to the viewer's canvas component so that click events on the display surface can be handled (e.g. for hit testing annotation markers).
      Specified by:
      addMouseListenerToDisplay in class AbstractBigViewer
      Parameters:
      ml - the listener to add
    • resetView

      public void resetView()
      Description copied from class: AbstractBigViewer
      Resets the view to frame all loaded data.
      Specified by:
      resetView in class AbstractBigViewer
    • isOpen

      public boolean isOpen()
      Description copied from class: AbstractBigViewer
      Returns true if the viewer window is currently visible and usable.
      Specified by:
      isOpen in class AbstractBigViewer
    • repaint

      public void repaint()
      Description copied from class: AbstractBigViewer
      Requests a repaint of the viewer canvas.
      Specified by:
      repaint in class AbstractBigViewer
    • updateStatus

      public void updateStatus(String message, int step, int nSteps)
      Description copied from class: AbstractBigViewer
      Updates the persistent progress bar docked at the bottom of this viewer's card panel. Unlike AbstractBigViewer.showViewerMessage(java.lang.String), it stays visible until reset.
      • nSteps = 0: hides the bar
      • nSteps < 0: indeterminate mode (animated, no percentage)
      • nSteps > 0: determinate mode showing step/nSteps
      Safe to call from any thread.
      Specified by:
      updateStatus in class AbstractBigViewer
      Parameters:
      message - short status message displayed inside the bar
      step - current step (0-based; ignored in indeterminate mode)
      nSteps - total steps (0 = hide, negative = indeterminate)
      See Also:
    • resyncCalibrationFromActiveSource

      public void resyncCalibrationFromActiveSource()
      Description copied from class: AbstractBigViewer
      Forces snt's image metadata (dimensions, calibration, pixel data, channel/frame) to be re-read from this viewer's currently active Source, the same resync AbstractBigViewer.AbstractTracer performs on its own before starting a new path (see AbstractTracer#syncChannelFromActiveSource()).

      That resync is otherwise only triggered by the first click of a new path, so snt's calibration can be stale (or still at whatever BigDataLoaderCmd's best-effort fallback produced at load time) for anything that reads it beforehand - such as SNT#buildMaterializedCrop(BoundingBox). Callers that need calibration to reflect exactly what this viewer is currently rendering, before the user has traced anything, should call this first.

      A no-op if no tracer has been created yet, or if the active source can't be resolved.

      Specified by:
      resyncCalibrationFromActiveSource in class AbstractBigViewer
      See Also:
    • syncOverlays

      public void syncOverlays()
      Description copied from class: AbstractBigViewer
      Synchronizes all active rendering overlays (paths, markers) with the current state of AbstractBigViewer.renderedTrees and any pending annotation changes.
      Specified by:
      syncOverlays in class AbstractBigViewer
    • annotations

      public Bvv.AnnotationOverlay annotations()
      Description copied from class: AbstractBigViewer
      Returns the annotation overlay for this viewer. The overlay renders point markers in the viewer's world coordinate space. May return null if the viewer has not been opened yet.
      Specified by:
      annotations in class AbstractBigViewer
    • getDefaultMarkerSize

      public float getDefaultMarkerSize()
      Description copied from class: AbstractBigViewer
      Returns the default sphere radius (in physical units) for newly placed markers. Implementations typically derive this from their rendering-options or a sensible default.
      Specified by:
      getDefaultMarkerSize in class AbstractBigViewer
    • getDefaultMarkerColor

      public Color getDefaultMarkerColor()
      Description copied from class: AbstractBigViewer
      Returns the default color for newly placed markers, or null to use the viewer's own fallback color.
      Specified by:
      getDefaultMarkerColor in class AbstractBigViewer
    • getCurrentTimepoint

      public int getCurrentTimepoint()
      Description copied from class: AbstractBigViewer
      Returns this viewer's current timepoint (1-based, matching Path.getFrame()'s convention), or 1 if no data is loaded / timepoint tracking is unavailable.
      Specified by:
      getCurrentTimepoint in class AbstractBigViewer
    • setCurrentTimepoint

      public void setCurrentTimepoint(int timepoint)
      Description copied from class: AbstractBigViewer
      Navigates this viewer to the specified timepoint (1-based, matching Path.getFrame()'s convention). Does nothing if no data is loaded.
      Specified by:
      setCurrentTimepoint in class AbstractBigViewer
      Parameters:
      timepoint - the 1-based timepoint to navigate to; values < 1 are coerced to 1
    • createMarkerManager

      protected BookmarkManager createMarkerManager()
      Description copied from class: AbstractBigViewer
      Creates and returns a new BookmarkManager for this viewer. Called exactly once (lazily) by AbstractBigViewer.getMarkerManager().
      Specified by:
      createMarkerManager in class AbstractBigViewer
    • getBdvHandle

      public bdv.util.BdvHandle getBdvHandle()
      Returns the underlying BdvHandle that manages sources and the viewer state.
    • getViewerPanel

      public bdv.viewer.ViewerPanel getViewerPanel()
      Returns the BDV display panel. Unlike BVV, BDV uses a ViewerPanel (orthographic slice viewer).
    • applyAutoBrightness

      protected void applyAutoBrightness(AbstractBigViewer.BrightnessScope scope)
      Description copied from class: AbstractBigViewer
      Recomputes the display range (brightness/contrast) for the source(s) selected by scope, from data percentiles, on a bounded background thread - see AbstractBigViewer.initBrightnessSafely(bdv.viewer.ViewerState, bdv.viewer.ConverterSetups, java.lang.String). Called automatically with AbstractBigViewer.BrightnessScope.ALL right after a source is first added, and re-invocable on demand (any scope) via the "Auto Brightness/Contrast" scene-control button (see AbstractBigViewer.autoBrightnessButton(sc.fiji.snt.viewer.AbstractBigViewer.Actions)). Does nothing if this viewer isn't yet backed by an underlying BDV/BVV scene (e.g. show(...) hasn't been called).
      Specified by:
      applyAutoBrightness in class AbstractBigViewer
      Parameters:
      scope - which source(s) to recompute
    • getRenderingOptions

      public AbstractBigViewer.PathRenderingOptions getRenderingOptions()
      Returns the rendering options controlling path thickness, transparency, etc. For BDV, slab clipping options have no effect (slab mode is BVV-only).
      Overrides:
      getRenderingOptions in class AbstractBigViewer
    • setPathOverlayOffset

      public void setPathOverlayOffset(double offsetX, double offsetY, double offsetZ)
      Shifts all rendered trees by (offsetX, offsetY, offsetZ) in world coordinates, for rendering purposes only.
      Specified by:
      setPathOverlayOffset in class AbstractBigViewer
      Parameters:
      offsetX - x offset in calibrated units
      offsetY - y offset in calibrated units
      offsetZ - z offset in calibrated units
    • isPathRenderingEnabled

      protected boolean isPathRenderingEnabled()
      Description copied from class: AbstractBigViewer
      Returns true if path/tree overlay rendering is currently enabled.
      Specified by:
      isPathRenderingEnabled in class AbstractBigViewer
    • setPathRenderingEnabled

      protected void setPathRenderingEnabled(boolean enabled)
      Description copied from class: AbstractBigViewer
      Enables or disables path/tree overlay rendering.
      Specified by:
      setPathRenderingEnabled in class AbstractBigViewer
    • setDisplayRadii

      public void setDisplayRadii(boolean display)
      Switches between frustum (radius-based) and centerline rendering. Invalidates the overlay cache and requests a repaint.
      Specified by:
      setDisplayRadii in class AbstractBigViewer
      Parameters:
      display - true to render frusta using per-node radii; false for fast centerline rendering
    • getDisplayRadii

      public boolean getDisplayRadii()
      Returns whether paths are rendered as frusta (true) or centerlines (false).