Package sc.fiji.snt.viewer
Class Bvv
java.lang.Object
sc.fiji.snt.viewer.Bvv
Support for Big Volume Viewer.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRenders spherical annotations atSNTPointworld coordinates.static classA snapshot of the BVV viewer state at a particular moment, used as a keyframe for movie recording.static classConfiguration options for path rendering. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleaccel(double t, int type) Easing functions for keyframe transitions, adapted from BDV movie recorder.voidLoads reconstruction files and adds them to the viewer with live progress feedback.voidScript friendly method to add a supported object (Tree,DirectedWeightedGraph) to the viewer overlay.voidAdds a Tree to the viewer as overlayCaptures the current viewer state as aBvv.Keyframe.voidClears all rendered trees from the overlay.booleanReturns whether paths are currently rendered with per-node radii as tapered frusta (true) or as simple lines (false).static BvvReturns the most recently createdBvvinstance, ornullif none has been created yet.Returns theBookmarkManagerused for placing and managing markers in this BVV instance.Returns allBvvMultiSourcegroups currently managed by this viewer.bvv.vistools.BvvOptionsGets all the trees currently rendered.Gets the path rendering options for controlling thickness, transparency, etc.bvv.core.BigVolumeViewerbvv.core.VolumeViewerFramebvv.core.VolumeViewerPanelstatic Bvvopen(ij.ImagePlus... imps) Convenience factory: creates a standalone BVV viewer and displays one or moreImagePlusvolumes in one step.static BvvConvenience factory: opens a file path into a BVV viewer.static BvvConvenience factory: opens one or more file paths into the same BVV viewer window, choosing the most appropriate loading strategy per file: .ims Imaris HDF5: creates a BDV XML sidecar file next to the.imsfile (using the same base name, e.g.static BvvScript friendly convenience factory: creates a standalone BVV viewer and displays a list of images in one step.static Bvvopen(mpicbg.spim.data.generic.AbstractSpimData<?> spimData) Convenience factory: creates a standalone BVV viewer and displays aAbstractSpimDatadataset using BVV's pyramid-aware GPU cache manager.static <T extends net.imglib2.type.numeric.RealType<T>>
Bvvopen(net.imagej.ImgPlus<T>... imgs) Convenience factory: creates a standalone BVV viewer and displays one or moreImgPlusvolumes in one step.static BvvConvenience factory: creates a BVV instance tethered to the givenSNTinstance and immediately displays its currently loaded image data.voidplayback(List<Bvv.Keyframe> keyframes) Plays back an animation between keyframes in the viewer without saving frames.voidplayback(List<Bvv.Keyframe> keyframes, int from, int to) Plays back a subset of keyframes (from indexfromto indexto, inclusive).booleanremoveTree(String treeLabel) voidrenderFrames(List<Bvv.Keyframe> keyframes, String outputDir) Renders an animation between a list of keyframes, saving each frame as a PNG screenshot.voidrepaint()Forces a repaint of the viewer, updating volume renderings but not overlays.voidResets the viewer to a fit-to-viewport transform, centering the loaded volume in the canvas.booleansaveSnapshot(String filePath) Saves a snapshot of current scene as a PNG image to the specified path.voidsetCalibration(double[] spacing, String unit) Overrides the voxel calibration (spacing and unit) for all loaded sources.voidsetCanvasOffset(double offsetX, double offsetY, double offsetZ) Offsets all paths being rendered.voidsetChannelColors(Color... colors) Sets per-channel colors across all source groups, assigning colors sequentially by global channel order across all groups.voidsetChannelColors(String... colorNames) Script-friendly method for setting per-channel colorsvoidsetChannelColors(BvvMultiSource group, Color... colors) Sets per-channel colors for a specific source group.voidsetDisplayRadii(boolean display) Sets whether paths are rendered as tapered frusta with per-node radii (true) or as anti-aliased lines (false).voidsetDisplayRange(BvvMultiSource group, double min, double max) Sets the display range (min/max intensity) for all channels of a specific source group.bvv.vistools.BvvSourceshow(ij.ImagePlus imp) Displays the BVV viewer with the specified image.<T extends net.imglib2.type.numeric.RealType<T>>
List<BvvMultiSource> Displays a list ofRandomAccessibleIntervalvolumes, each as aBvvMultiSource.show(mpicbg.spim.data.generic.AbstractSpimData<?> spimData) Displays aAbstractSpimDatadataset using BVV's pyramid-aware GPU cache manager.<T extends net.imglib2.type.numeric.RealType<T>>
bvv.vistools.BvvSourceshow(net.imagej.ImgPlus<T> imgPlus) <T extends net.imglib2.type.numeric.RealType<T>>
bvv.vistools.BvvSourceshow(net.imglib2.RandomAccessibleInterval<T> img, double... calibration) Displays the BVV viewer with the specified image.bvv.vistools.BvvSourceDisplays the main tracing data from the associated SNT instance.bvv.vistools.BvvSourceDisplays the secondary tracing data from the associated SNT instance.ij.ImagePlussnapshot()Retrieves the current scene as an image.ij.ImagePlusRetrieves the specified scene view as an image.voidUpdates the viewer display to reflect changes in rendered trees and paths.booleanSynchronizes the Path Manager contents with BVV display.voidupdateStatus(String message, int step, int nSteps) Updates the progress bar at the bottom of the BVV frame.
-
Constructor Details
-
Bvv
public Bvv()Constructor for standalone BVV instance. -
Bvv
Constructor for assembling a BVV instance tethered to SNT.- Parameters:
snt- the snt instance providing paths and imagery to be rendered
-
-
Method Details
-
getInstance
Returns the most recently createdBvvinstance, ornullif none has been created yet. This is a convenience accessor for scripts that need to reference the active BVV viewer without passing it around.- Returns:
- the last initialised Bvv, or
null
-
show
public <T extends net.imglib2.type.numeric.RealType<T>> bvv.vistools.BvvSource show(net.imglib2.RandomAccessibleInterval<T> img, double... calibration) Displays the BVV viewer with the specified image.- Type Parameters:
T- the numeric type of the image data- Parameters:
img- the image data to displaycalibration- optional calibration values for x, y, z dimensions. If null, defaults to {1, 1, 1}- Returns:
- the BvvSource representing the displayed image
-
show
public <T extends net.imglib2.type.numeric.RealType<T>> bvv.vistools.BvvSource show(net.imagej.ImgPlus<T> imgPlus) -
show
public <T extends net.imglib2.type.numeric.RealType<T>> List<BvvMultiSource> show(List<net.imglib2.RandomAccessibleInterval<T>> imgs, List<double[]> calibrations) Displays a list ofRandomAccessibleIntervalvolumes, each as aBvvMultiSource. All volumes are added to the same BVV window.- Type Parameters:
T- the numeric type- Parameters:
imgs- the volumes to displaycalibrations- per-image calibration arrays (x, y, z pixel sizes); may benullto use defaults of {1,1,1}- Returns:
- list of
BvvMultiSource, one per volume
-
getMultiSources
Returns allBvvMultiSourcegroups currently managed by this viewer. This includes multichannel images and any grouped multi-image sources.- Returns:
- unmodifiable list of
BvvMultiSourcegroups
-
setChannelColors
Script-friendly method for setting per-channel colors- Parameters:
colorNames- color representations (HTML/css values, or hex)- See Also:
-
setChannelColors
Sets per-channel colors for a specific source group. Each color is applied to the corresponding channel in order; extra colors are ignored, and channels without a supplied color are left unchanged. Typical script usage:def bvv = Bvv.open([reference, moving]) bvv.setChannelColors(bvv.getMultiSources().get(0), Color.RED, Color.GREEN, Color.BLUE)
- Parameters:
group- the target source group, obtained fromgetMultiSources()colors- one color per channel, in channel order
-
setChannelColors
Sets per-channel colors across all source groups, assigning colors sequentially by global channel order across all groups. For example, with two 3-channel images and colors [R, G, B, C, M, Y], image 1 gets R/G/B and image 2 gets C/M/Y. With a single multichannel image or a dataset where each setup is its own group (e.g. IMS), colors are assigned one-to-one in load order.To apply the same color pattern to every group independently, call
Typical script usage:setChannelColors(BvvMultiSource, Color...)per group.def bvv = Bvv.open(img) bvv.setChannelColors(Color.RED, Color.GREEN, Color.BLUE)
- Parameters:
colors- colors assigned sequentially across all channels in all groups
-
setDisplayRange
Sets the display range (min/max intensity) for all channels of a specific source group.- Parameters:
group- the target source group, obtained fromgetMultiSources()min- the minimum intensity value (maps to black)max- the maximum intensity value (maps to full color)
-
getMarkerManager
Returns theBookmarkManagerused for placing and managing markers in this BVV instance. The manager is created lazily on first call. UseBookmarkManager.showPanel()to display the floating marker panel, andBookmarkManager.save(File)to persist markers to CSV.- Returns:
- the marker manager (never null)
-
open
Convenience factory: creates a standalone BVV viewer and displays one or moreImagePlusvolumes in one step. Multichannel images have their channels grouped and transformed together.Equivalent to:
Bvv bvv = new Bvv(); bvv.show(imp); // single image bvv.show(Arrays.asList(ref, moving)); // multiple images
Typical Groovy/PySNT usage:def bvv = Bvv.open(imp) // single image def bvv = Bvv.open(reference, moving) // multiple images
- Parameters:
imps- one or more images to display; all are added to the same BVV window- Returns:
- the fully initialised
Bvvinstance - Throws:
IllegalArgumentException- if an image type is unsupported (COLOR_256)
-
open
@SafeVarargs public static <T extends net.imglib2.type.numeric.RealType<T>> Bvv open(net.imagej.ImgPlus<T>... imgs) Convenience factory: creates a standalone BVV viewer and displays one or moreImgPlusvolumes in one step. Calibration (pixel sizes) is read automatically from eachImgPlus's metadata.Equivalent to:
Bvv bvv = new Bvv(); bvv.show(img); // single image
Typical Groovy/PySNT usage:def bvv = Bvv.open(imgPlus) def bvv = Bvv.open(imgPlus1, imgPlus2)
- Type Parameters:
T- the numeric type of the image data- Parameters:
imgs- one or more volumes to display; all are added to the same BVV window- Returns:
- the fully initialised
Bvvinstance
-
open
Script friendly convenience factory: creates a standalone BVV viewer and displays a list of images in one step. Accepts any mix ofImagePlus,ImgPlus, orRandomAccessibleIntervalobjects.Typical Groovy/PySNT usage:
def bvv = Bvv.open([reference, moving]) def bvv = Bvv.open(myImageList)
- Parameters:
imgs- the images to display; all are added to the same BVV window. Each element must be anImagePlus,ImgPlus, orRandomAccessibleInterval- Returns:
- the fully initialised
Bvvinstance - Throws:
IllegalArgumentException- if any element is null or of an unsupported type
-
open
Convenience factory: creates a BVV instance tethered to the givenSNTinstance and immediately displays its currently loaded image data.Equivalent to:
Bvv bvv = new Bvv(snt); bvv.showLoadedData();
Typical Groovy/PySNT usage:def bvv = Bvv.open(snt) bvv.add(snt.getPathAndFillManager().getTrees())
- Parameters:
snt- theSNTinstance providing image data and paths- Returns:
- the fully initialised
Bvvinstance tethered tosnt - Throws:
IllegalArgumentException- if no valid image data is loaded insnt
-
open
Convenience factory: creates a standalone BVV viewer and displays aAbstractSpimDatadataset using BVV's pyramid-aware GPU cache manager. Unlike theImgPlus/ImagePluspaths, this does not attempt to upload the entire volume at once: data is streamed as tiles on demand, making it suitable for out-of-core datasets.The caller is responsible for constructing the
AbstractSpimDataobject, typically via an XML/HDF5 loader:import bdv.spimdata.XmlIoSpimDataMinimal spimData = new XmlIoSpimDataMinimal().load("/path/to/dataset.xml") def bvv = Bvv.open(spimData)or via Bio-Formats/IMS loaders that produce aAbstractSpimDatawith a multiresolution pyramid.- Parameters:
spimData- the dataset to display- Returns:
- the fully initialised
Bvvinstance
-
open
Convenience factory: opens a file path into a BVV viewer. Seeopen(String...)for supported formats and behavior.- Parameters:
filePathOrUrl- the file path or URL to open- Returns:
- the fully initialised
Bvvinstance - Throws:
IllegalArgumentException- if the file cannot be opened or an.imsdirectory is not writable
-
open
Convenience factory: opens one or more file paths into the same BVV viewer window, choosing the most appropriate loading strategy per file:- .ims Imaris HDF5: creates a BDV XML sidecar file next to
the
.imsfile (using the same base name, e.g.dataset.xml), then loads it viaXmlIoSpimDataMinimal. BVV's pyramid-aware GPU cache manager is used, so the full volume is never loaded into RAM. If the directory is not writable, anIllegalArgumentExceptionis thrown with instructions to create the XML manually usingPlugins > BigDataViewer > Create XML for Imaris file. - .xml BDV XML/HDF5: loaded directly via
XmlIoSpimDataMinimaland displayed using BVV's cache manager. This covers BDV HDF5, BDV N5, and OME-Zarr datasets. - anything else delegated to
ImgUtils.open(String)and displayed via the standardImgPluspath. Very large flat volumes will fail with a descriptive error rather than a GL crash.
def bvv = Bvv.open("/path/to/reference.xml", "/path/to/moving.ims")- Parameters:
paths- one or more file paths or URLs to open- Returns:
- the fully initialised
Bvvinstance - Throws:
IllegalArgumentException- if any file cannot be opened or an.imsdirectory is not writable
- .ims Imaris HDF5: creates a BDV XML sidecar file next to
the
-
show
Displays aAbstractSpimDatadataset using BVV's pyramid-aware GPU cache manager. Each setup (channel/angle) is added as a source and wrapped in aBvvMultiSource. Unlike theImgPlus/ImagePluspaths, the full volume is never loaded into RAM or GPU at once.- Parameters:
spimData- the dataset to display- Returns:
- list of
BvvMultiSource, one per BDV setup, in setup order
-
show
public bvv.vistools.BvvSource show(ij.ImagePlus imp) Displays the BVV viewer with the specified image.- Parameters:
imp- the ImagePlus to display- Returns:
- the BvvSource representing the displayed image
- Throws:
IllegalArgumentException- if the image type is unsupported (COLOR_256)
-
addTree
Adds a Tree to the viewer as overlay- Parameters:
tree- the Tree to render
-
add
Script friendly method to add a supported object (Tree,DirectedWeightedGraph) to the viewer overlay. Collections are also supported, which is an effective way of adding multiple items since the scene is only updated once all items have been added.- Parameters:
object- the object to be added. Null objects are ignored- Throws:
IllegalArgumentException- if object is not supported
-
add
Loads reconstruction files and adds them to the viewer with live progress feedback. Files are loaded one at a time on a background thread; the viewer scene is updated after each file so the user sees trees appearing incrementally. The progress bar in the SNT Annotations card tracks progress.- Parameters:
reconstructionFiles- the reconstruction files (SWC, JSON, etc.) to load
-
updateStatus
Updates the progress bar at the bottom of the BVV frame.nSteps = 0: hides the barnSteps < 0: indeterminate mode (animated, no percentage)nSteps > 0: determinate mode showingstep/nSteps
- Parameters:
message- short status message displayed inside the barstep- current step (0-based; ignored in indeterminate mode)nSteps- total steps (0 = hide, negative = indeterminate)
-
syncOverlays
public void syncOverlays()Updates the viewer display to reflect changes in rendered trees and paths. This method should be called after modifying the collection of rendered objects to ensure the display is synchronized. -
annotations
-
repaint
public void repaint()Forces a repaint of the viewer, updating volume renderings but not overlays. -
resetView
public void resetView()Resets the viewer to a fit-to-viewport transform, centering the loaded volume in the canvas. Equivalent to the Reset button in Camera Controls. No-op if no volume has been loaded. -
snapshot
public ij.ImagePlus snapshot()Retrieves the current scene as an image.- Returns:
- the bitmap image of the current scene
-
snapshot
Retrieves the specified scene view as an image. Must be called from a non-EDT thread (e.g. a script or SwingWorker), otherwise the render latch will time out.- Parameters:
viewMode- the view mode (case-insensitive):"xy","xz","yz","default"(fit-to-viewport), or"current"(scene as-is).- Returns:
- the bitmap image of the scene view, or
nullif the viewer is not initialized
-
saveSnapshot
Saves a snapshot of current scene as a PNG image to the specified path.- Parameters:
filePath- the absolute path of the destination file- Returns:
- true, if file was successfully saved
-
removeTree
-
clearAllTrees
public void clearAllTrees()Clears all rendered trees from the overlay. -
getRenderedTrees
Gets all the trees currently rendered.- Returns:
- collection of rendered trees
-
getViewerFrame
public bvv.core.VolumeViewerFrame getViewerFrame()- Returns:
- a reference to the viewer's frame.
-
getOptions
public bvv.vistools.BvvOptions getOptions()- Returns:
- a reference to the viewer's options.
-
getViewer
public bvv.core.BigVolumeViewer getViewer()- Returns:
- a reference to the underlying BigVolumeViewer instance.
-
getViewerPanel
public bvv.core.VolumeViewerPanel getViewerPanel()- Returns:
- a reference to the viewer's panel.
-
getRenderingOptions
Gets the path rendering options for controlling thickness, transparency, etc.- Returns:
- the rendering options
-
setCalibration
Overrides the voxel calibration (spacing and unit) for all loaded sources. This is useful when the image metadata does not carry the correct spatial calibration (e.g., ND2 files opened via SCIFIO/Bio-Formats where the unit string is lost). The change takes effect immediately: the scale bar, distance measurements, and slab-thickness controls will all use the new values.- Parameters:
spacing- voxel size in {x, y, z} orderunit- physical unit string (e.g. "µm")
-
setDisplayRadii
public void setDisplayRadii(boolean display) Sets whether paths are rendered as tapered frusta with per-node radii (true) or as anti-aliased lines (false). Line rendering is significantly faster for datasets with many paths. Automatically invalidates the overlay cache and repaints.- Parameters:
display-truefor frustum/radius rendering (default),falsefor fast line rendering
-
getDisplayRadii
public boolean getDisplayRadii()Returns whether paths are currently rendered with per-node radii as tapered frusta (true) or as simple lines (false).- Returns:
trueif frustum/radius rendering is active
-
setCanvasOffset
public void setCanvasOffset(double offsetX, double offsetY, double offsetZ) Offsets all paths being rendered. This allows for 'dislodging' paths from their underlying signal without altering their coordinates.- Parameters:
offsetX- X offset (calibrated distance)offsetY- Y offset (calibrated distance)offsetZ- Z offset (calibrated distance)
-
showLoadedData
public bvv.vistools.BvvSource showLoadedData()Displays the main tracing data from the associated SNT instance. This method is only available for BVV instances that are tethered to an SNT instance.- Returns:
- the BvvSource representing the displayed tracing data
- Throws:
IllegalArgumentException- if this is a standalone viewer or no valid image data is available
-
showSecondaryData
public bvv.vistools.BvvSource showSecondaryData()Displays the secondary tracing data from the associated SNT instance. This method is only available for BVV instances that are tethered to an SNT instance.- Returns:
- the BvvSource representing the displayed secondary data
- Throws:
IllegalArgumentException- if this is a standalone viewer or no valid image data is available
-
syncPathManagerList
public boolean syncPathManagerList()Synchronizes the Path Manager contents with BVV display.- Returns:
- true if synchronization was successful
- Throws:
IllegalArgumentException- if this is a standalone viewer not tethered to a SNT instance
-
captureKeyframe
Captures the current viewer state as aBvv.Keyframe. The transform, camera/slab parameters, and visible actor set are all snapshotted.- Returns:
- the current state as a Keyframe
-
accel
public static double accel(double t, int type) Easing functions for keyframe transitions, adapted from BDV movie recorder.- Parameters:
t- progress value in [0, 1]type- easing type: 0 = symmetric, 1 = slow start, 2 = slow end, 3 = soft symmetric, 4 = soft slow start, 5 = soft slow end- Returns:
- eased progress value in [0, 1]
-
playback
Plays back an animation between keyframes in the viewer without saving frames. Useful for previewing a movie before committing to a render. The frame count for each transition is read fromBvv.Keyframe.frameson the destination keyframe.- Parameters:
keyframes- ordered list of keyframes (at least 2)- See Also:
-
playback
Plays back a subset of keyframes (from indexfromto indexto, inclusive). Useful for previewing a specific transition without replaying the entire sequence.- Parameters:
keyframes- ordered list of all keyframesfrom- start index (inclusive, 0-based)to- end index (inclusive, 0-based)- See Also:
-
renderFrames
Renders an animation between a list of keyframes, saving each frame as a PNG screenshot. The transform is interpolated smoothly between keyframes usingSimilarityTransformAnimator; visibility and slab bounds snap at keyframe boundaries (no interpolation).The number of frames for each transition is read from
Bvv.Keyframe.frameson each destination keyframe (the first keyframe's value is ignored).This method must be called from a non-EDT thread. It blocks until all frames have been rendered and saved.
- Parameters:
keyframes- ordered list of keyframes (at least 2)outputDir- directory where PNGs will be saved (created if needed); ifnull, frames are played back live without saving- Throws:
IllegalArgumentException- if arguments are inconsistentIllegalStateException- if no BVV viewer is active
-