Class NodeCollector<T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>>
- Type Parameters:
T- the pixel type of the source image
ImagePlus stack, or a montage.
The class operates on an ImgPlus so it works with lazy, tile/cell-backed sources (OME-Zarr, N5, HDF5) for
large datasets: with the default lazy mode, only the cells overlapping each crop are touched. Materialization to an
ImagePlus happens only on demand (e.g., when getStack() or getMontage() is called), so even
thousands of small (e.g. 20x20) crops can fit in-RAM.
Out-of-bounds windows (e.g. tips near the image border) are padded with zeros so that every crop in the output has identical dimensions and the resulting montage forms a uniform grid.
Constructors and factories:
NodeCollector(ImgPlus, Collection)- any collection ofSNTPoints (tips, BPs, bookmarks, seeds, ...).fromTips(ImgPlus, Tree),fromBranchPoints(ImgPlus, Tree),fromRoots(ImgPlus, Collection),fromNodes(ImgPlus, Tree, int)- Tree-aware sugar.
- Author:
- Tiago Ferreira
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumZ-handling strategies for the per-crop window. -
Constructor Summary
ConstructorsConstructorDescriptionNodeCollector(net.imagej.ImgPlus<T> img, Collection<? extends SNTPoint> points) Instantiates a NodeCollector from an arbitrary collection of points. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>>
NodeCollector<T> fromBranchPoints(net.imagej.ImgPlus<T> img, Tree tree) Convenience factory using the branch points oftree.static <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>>
NodeCollector<T> Convenience factory sampling everyeveryNthnode across all paths intree.static <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>>
NodeCollector<T> fromRoots(net.imagej.ImgPlus<T> img, Collection<Tree> trees) Convenience factory using the root of every suppliedtree.static <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>>
NodeCollector<T> Convenience factory using the tips oftree.net.imagej.ImgPlus<T> Returns the crop centered on a single point, respecting the currentsetMaterialize(boolean),setProjection(Projection),setChannel(int), andsetWindow(int, int)settings.getCrops()Returns the per-point crops as a list ofImgPluses.ij.ImagePlusConvenience forgetMontage(int, int, double, int, boolean)with an automatic grid (cols = ceil(sqrt(n))), scale 1, no border, without labels.ij.ImagePlusgetMontage(int cols, int rows, double scale, int border, boolean labels) Builds a montage of the crops via IJ1'sMontageMaker.ij.ImagePlusgetStack()Materializes the crops into a multi-sliceImagePlus(one slice per point, in iteration order).setChannel(int channel) Sets the channel to crop from (0-indexed).setFrame(int frame) Sets the time frame to crop from (0-indexed).setLabelProvider(Function<SNTPoint, String> labelProvider) Provides per-crop slice labels (used bygetStack()andgetMontage(int, int, double, int, boolean)when labels are enabled).setMaterialize(boolean materialize) If true, crops are materialized to contiguous arrays.setPointsInPixelSpace(boolean pointsInPixelSpace) If true, thex/y/zof input points are treated as pixel coordinates (no calibration conversion is performed).setProjection(NodeCollector.Projection projection) Sets the z-projection applied to each crop.setWindow(int wxy, int wz) Sets the size of the crop window in pixels.setWindow(int wx, int wy, int wz) Sets the per-axis crop window (X, Y, Z) in pixels.
-
Constructor Details
-
NodeCollector
Instantiates a NodeCollector from an arbitrary collection of points.- Parameters:
img- the source image. Lazy/cell-backed ImgPluses (OME-Zarr, N5, HDF5) are supported transparentlypoints- the points around which crops will be extracted. Points are interpreted in calibrated units, matching the image axis metadata. If a point'sonPathis set, the path's own calibration is used for pixel conversion instead; otherwise pixel coordinates are derived from the image axes
-
-
Method Details
-
fromTips
public static <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>> NodeCollector<T> fromTips(net.imagej.ImgPlus<T> img, Tree tree) Convenience factory using the tips oftree. -
fromBranchPoints
public static <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>> NodeCollector<T> fromBranchPoints(net.imagej.ImgPlus<T> img, Tree tree) Convenience factory using the branch points oftree. -
fromRoots
public static <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>> NodeCollector<T> fromRoots(net.imagej.ImgPlus<T> img, Collection<Tree> trees) Convenience factory using the root of every suppliedtree. -
fromNodes
public static <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>> NodeCollector<T> fromNodes(net.imagej.ImgPlus<T> img, Tree tree, int everyNth) Convenience factory sampling everyeveryNthnode across all paths intree.- Parameters:
everyNth- stride (1 = every node)
-
setWindow
Sets the size of the crop window in pixels.- Parameters:
wxy- XY edge length (in pixels). Must be>= 1wz- Z slab thickness (in pixels). 1 -> 2D crop; values> 1produce a 3D slab that can be optionally projected viasetProjection(Projection)
-
setWindow
Sets the per-axis crop window (X, Y, Z) in pixels. -
setChannel
Sets the channel to crop from (0-indexed). By default, the channel of the point'sowning Pathis used, falling back to 0 for points with no associated Path.- Parameters:
channel- 0-indexed channel, or a negative value to restore the "infer from path" default
-
setFrame
Sets the time frame to crop from (0-indexed). By default, the frame of the point's owning Path is used, falling back to 0 for points with no associated Path. -
setMaterialize
If true, crops are materialized to contiguous arrays. If false (default), each crop is a lazyViews.interval(net.imglib2.RandomAccessible<T>, long[], long[])view into the source, suitable for very large lazy-loaded sources. Materialization is forced when anImagePlusis requested viagetStack()orgetMontage(). -
setPointsInPixelSpace
If true, thex/y/zof input points are treated as pixel coordinates (no calibration conversion is performed).If false (default), points are assumed to be in calibrated units; SNT points carrying an
onPathreference are unscaled via the path's calibration, otherwise the image's axis metadata is used. -
setProjection
Sets the z-projection applied to each crop.NodeCollector.Projection.NONE(default) returns the full slab;NodeCollector.Projection.MIP_Zreduces the z-slab of each crop to a single 2D slice via max-intensity projection, which is usually what is wanted for a printable montage. -
setLabelProvider
Provides per-crop slice labels (used bygetStack()andgetMontage(int, int, double, int, boolean)when labels are enabled). If unset, labels default to"tip-i pathName". -
getCrop
Returns the crop centered on a single point, respecting the currentsetMaterialize(boolean),setProjection(Projection),setChannel(int), andsetWindow(int, int)settings.Prefer this over
getCrops()when processing large datasets one point at a time (e.g. to keep peak memory bounded to a single crop) -
getCrops
Returns the per-point crops as a list ofImgPluses.If
materializeis false (default), the returned ImgPluses are zero-padded lazy views (out-of-bounds samples yield the zero value ofT). If true, each ImgPlus is backed by a contiguousImg. -
getStack
public ij.ImagePlus getStack()Materializes the crops into a multi-sliceImagePlus(one slice per point, in iteration order). -
getMontage
public ij.ImagePlus getMontage()Convenience forgetMontage(int, int, double, int, boolean)with an automatic grid (cols = ceil(sqrt(n))), scale 1, no border, without labels. -
getMontage
public ij.ImagePlus getMontage(int cols, int rows, double scale, int border, boolean labels) Builds a montage of the crops via IJ1'sMontageMaker.- Parameters:
cols- number of columnsrows- number of rowsscale- resizing scale of each panelborder- border thickness in pixelslabels- whether to render slice labels on each panel- Returns:
- the montage image
-