Class BvvUtils
Bvv, ChannelUnmixingCard, etc.).-
Method Summary
Modifier and TypeMethodDescriptionstatic voidpreferMultiResolutionIfSafe(bdv.viewer.Source<?> source, int timepoint) Forces BVV to rendersourcewith its pyramid-aware, block-streaming path (bvv.core.multires.MultiResolutionStack3D) instead of the naive single-texture path (bvv.core.multires.SimpleStack3D), when it is safe to do so.static <T> voidprefetchForShow(bdv.viewer.Source<T> source, int timepoint) Fetches and locally caches whichever mipmap level BVV will actually render first forsource, by touching every pixel on the calling thread.static <T extends net.imglib2.type.numeric.NumericType<T> & net.imglib2.type.NativeType<T>>
bdv.viewer.Source<T> synthesizeMipmapPyramid(bdv.viewer.Source<T> source, int nLevels) Wraps a single-resolutionSourcein a synthetic mipmap pyramid, built by materializing it locally (seeImgUtils.materialize(net.imglib2.RandomAccessibleInterval<T>)) and lazily subsampling that local copy.static voidwarnIfLikelyRemoteImgPlus(net.imagej.ImgPlus<?> img, String pathOrUrl) Diagnostic-only warning for the plainImgPlusfallback path (seeSpimDataUtils.resolvePathToSource(String)).static voidwarnIfLikelySimpleStack(bdv.viewer.Source<?> source, int timepoint) Read-only counterpart topreferMultiResolutionIfSafe(bdv.viewer.Source<?>, int)forAbstractSpimDatasources (BDV-XML/HDF5, IMS): logs a warning ifsourcelooks likely to fall back to BVV's non-pyramid-awareSimpleStack3Drenderer, without attempting to prevent it.
-
Method Details
-
synthesizeMipmapPyramid
public static <T extends net.imglib2.type.numeric.NumericType<T> & net.imglib2.type.NativeType<T>> bdv.viewer.Source<T> synthesizeMipmapPyramid(bdv.viewer.Source<T> source, int nLevels) Wraps a single-resolutionSourcein a synthetic mipmap pyramid, built by materializing it locally (seeImgUtils.materialize(net.imglib2.RandomAccessibleInterval<T>)) and lazily subsampling that local copy. BVV'sVolumeRendererrequires multiple resolution levels to pick a LOD; without one it throws on every repaint. Use this for non-pyramidal N5/Zarr sources that cannot be re-exported with a real pyramid.Level 0 is the full-resolution, now-local copy; each extra level doubles the previous step size along X/Y/Z, matching how a real N5/Zarr multiscale pyramid is laid out
- Type Parameters:
T- pixel type- Parameters:
source- the single-level source to wrapnLevels- number of extra downsampled levels to synthesize- Returns:
- a multi-resolution
Sourcewrappingsource, orsourceunchanged if it already has more than one level
-
prefetchForShow
public static <T> void prefetchForShow(bdv.viewer.Source<T> source, int timepoint) Fetches and locally caches whichever mipmap level BVV will actually render first forsource, by touching every pixel on the calling thread. CallpreferMultiResolutionIfSafe(bdv.viewer.Source<?>, int)first so the stack type is already decided when this runsSimpleStack3Dalways uploads level 0 (full resolution) as a single texture on first paint (seebvv.core.render.DefaultSimpleStackManager) so that upload is what must be warmed for it.MultiResolutionStack3Dstreams blocks progressively and never blocks the EDT regardless of what is cached, so warming its coarsest level here is only a courtesy (a faster first frame).Call this on a background thread before
bvv.show(...)so the EDT only ever sees already-cached data- Type Parameters:
T- pixel type- Parameters:
source- the source to warm uptimepoint- the timepoint to warm up
-
preferMultiResolutionIfSafe
public static void preferMultiResolutionIfSafe(bdv.viewer.Source<?> source, int timepoint) Forces BVV to rendersourcewith its pyramid-aware, block-streaming path (bvv.core.multires.MultiResolutionStack3D) instead of the naive single-texture path (bvv.core.multires.SimpleStack3D), when it is safe to do so.BVV auto-detects which path to use (
bvv.core.multires.SourceStacks#inferSourceStackType): it only picks the multi-resolution path whensource's pixel type isTileAccess-supported ANDsource.getSource(timepoint, 0)is (or wraps, viaVolatileView) anAbstractCellImg. Many BDV/N5 source builders wrap their levels in a plainViews-based interval (not anAbstractCellImg), which makes BVV fall back toSimpleStack3Deven for a genuinely multi-resolution, remote source.SimpleStack3Duploads the entire full-resolution volume as one texture on first paint, fetching all of it synchronouslyThis mirrors BVV's own
inferSourceStackTypecheck before overriding it, so it never forces multi-resolution rendering on a source that would actually fail it (which would throwUnsupportedOperationExceptionfromTileAccess.createon the render thread). If the check fails, this method does nothing and BVV falls back to its own (slower) default- Parameters:
source- the source about to be shown in BVVtimepoint- the timepoint to inspect
-
warnIfLikelySimpleStack
public static void warnIfLikelySimpleStack(bdv.viewer.Source<?> source, int timepoint) Read-only counterpart topreferMultiResolutionIfSafe(bdv.viewer.Source<?>, int)forAbstractSpimDatasources (BDV-XML/HDF5, IMS): logs a warning ifsourcelooks likely to fall back to BVV's non-pyramid-awareSimpleStack3Drenderer, without attempting to prevent it.Unlike the
SpimDataUtils.N5Sourcespath,BvvFunctions.show(AbstractSpimData, BvvOptions)builds its ownSourceinstances internally (viaBigDataViewer#initSetups), so there is no hook to callpreferMultiResolutionIfSafe(bdv.viewer.Source<?>, int)on the actual instance before it first renders.inferSourceStackType's check is a pure function of the source's structural properties (pixel type, whether level 0 is anAbstractCellImg), not of instance identity or any per-instance cached state, so running the same check here - on theSourceSNT already has a handle to aftershow()returns - still gives an accurate answer; it just can't change the outcomeThis is diagnostic only: it neither prefetches nor forces a stack type, so it carries none of
preferMultiResolutionIfSafe(bdv.viewer.Source<?>, int)/prefetchForShow(bdv.viewer.Source<T>, int)'s risk of misbehaving on a source shape this hasn't been exercised against - it only makes a slow first paint traceable in the log after the fact, for whicheverAbstractSpimDatabackend produced it- Parameters:
source- the (already-shown) source to inspecttimepoint- the timepoint to inspect (0 is fine for this purely structural check)
-
warnIfLikelyRemoteImgPlus
Diagnostic-only warning for the plainImgPlusfallback path (seeSpimDataUtils.resolvePathToSource(String)). UnlikepreferMultiResolutionIfSafe(bdv.viewer.Source<?>, int)/warnIfLikelySimpleStack(bdv.viewer.Source<?>, int), anImgPlusalways has a single mipmap level, so BVV always renders it via the non-pyramid-awareSimpleStack3Dpath regardless of pixel type or backing storage - there is no "is it structurally eligible for MULTIRESOLUTION" question to ask here the way there is forAbstractSpimData/N5Sources.resolvePathToSourcealready knows this at resolution time - a remoteImgPlusis only ever produced by its own URL fallback branch (ImgUtils.open(url)) - so this simply carries that signal forward rather than trying to re-derive it by introspecting the RAI (which, for a lazily-opened remote image, may not even be a recognizable cache type)- Parameters:
img- the resolvedImgPlusabout to be shown in BVVpathOrUrl- the original path or URLimgwas resolved from
-