Package sc.fiji.snt
Class PathFitter
java.lang.Object
sc.fiji.snt.PathFitter
Class for fitting circular cross-sections around existing nodes of a
Path in order to compute radii (node thickness) and midpoint
refinement of existing coordinates.
Thread Safety: When fitting multiple paths in parallel:
1. Call call() in parallel (thread-safe)
2. Call applyFit() sequentially (modifies path hierarchy)
Example:
List<PathFitter> fitters = paths.stream()
.map(p -> new PathFitter(img, p))
.collect(Collectors.toList());
<p>
// Parallel fitting
fitters.parallelStream().forEach(PathFitter::call);
<p>
// Sequential application
fitters.forEach(PathFitter::applyFit);
- Author:
- Tiago Ferreira, Mark Longair, Cameron Arshadi
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic doubleThe default value for the smallest angle (in radians) constraining the fit.static final intFlag specifying that radii at invalid fit locations should fall back to the minimum voxel separation (voxel size)static final intFlag specifying that radii at invalid fit locations should fall back to the mode of all possible fitsstatic final intFlag specifying that radii at invalid fit locations should fall back toDouble.NaNstatic final intFlag specifying that the computed path should only inherit midpoint refinement of node coordinatesstatic final intFlag specifying that the computed path should only inherit fitted radii attributesstatic final intFlag specifying that the computed path should inherit both midpoint refinement of node coordinates and radii -
Constructor Summary
ConstructorsConstructorDescriptionPathFitter(ij.ImagePlus imp, Path path) Instantiates a new PathFitter.PathFitter(net.imagej.ImgPlus<? extends net.imglib2.type.numeric.RealType<?>> img, Path path) Instantiates a new PathFitter.PathFitter(net.imglib2.RandomAccessibleInterval<? extends net.imglib2.type.numeric.RealType<?>> img, Path path, double xSpacing, double ySpacing, double zSpacing, String unit) Instantiates a new PathFitter directly from pixel data.PathFitter(SNT plugin, Path path) Instantiates a new PathFitter. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyFit()Applies the fitted result to the path.voidcall()Takes the signal from the image specified in the constructor to fit cross-section circles around the nodes of input path.getPath()booleanChecks whether the fit succeeded.voidvoidsetCrossSectionRadius(double crossSectionRadius) Sets the radius of cross-sectional planes sampled around each node.voidsetImage(net.imglib2.RandomAccessibleInterval<? extends net.imglib2.type.numeric.RealType<?>> img) Sets the target imagevoidsetNodeRadiusFallback(int fallback) Sets the fallback strategy for node radii at locations where fitting failed.voidsetProgressCallback(int fitterIndex, sc.fiji.snt.MultiTaskProgress progress) voidsetReplaceNodes(boolean replaceNodes) Sets whether fitting should occur "in place".voidsetScope(int scope) Sets the fitting scope.voidsetShowAnnotatedView(boolean showAnnotatedView) Sets whether an interactive image of the result should be displayed.
-
Field Details
-
DEFAULT_MIN_ANGLE
public static double DEFAULT_MIN_ANGLEThe default value for the smallest angle (in radians) constraining the fit. -
RADII
public static final int RADIIFlag specifying that the computed path should only inherit fitted radii attributes- See Also:
-
MIDPOINTS
public static final int MIDPOINTSFlag specifying that the computed path should only inherit midpoint refinement of node coordinates- See Also:
-
RADII_AND_MIDPOINTS
public static final int RADII_AND_MIDPOINTSFlag specifying that the computed path should inherit both midpoint refinement of node coordinates and radii- See Also:
-
FALLBACK_NAN
public static final int FALLBACK_NANFlag specifying that radii at invalid fit locations should fall back toDouble.NaN- See Also:
-
FALLBACK_MIN_SEP
public static final int FALLBACK_MIN_SEPFlag specifying that radii at invalid fit locations should fall back to the minimum voxel separation (voxel size)- See Also:
-
FALLBACK_MODE
public static final int FALLBACK_MODEFlag specifying that radii at invalid fit locations should fall back to the mode of all possible fits- See Also:
-
-
Constructor Details
-
PathFitter
Instantiates a new PathFitter.- Parameters:
imp- the Image containing the signal to which the fit will be performedpath- thePathto be fitted. Note that path spacing will change to that of image's voxel size.
-
PathFitter
public PathFitter(net.imagej.ImgPlus<? extends net.imglib2.type.numeric.RealType<?>> img, Path path) Instantiates a new PathFitter.- Parameters:
img- the Image containing the signal to which the fit will be performedpath- thePathto be fitted. Note that path spacing will change to that of image's voxel size.
-
PathFitter
public PathFitter(net.imglib2.RandomAccessibleInterval<? extends net.imglib2.type.numeric.RealType<?>> img, Path path, double xSpacing, double ySpacing, double zSpacing, String unit) Instantiates a new PathFitter directly from pixel data. If img has more than two dimensions, the third dimension is treated as depth.Specified pixel dimensions will be applied to Path's spacing values.
- Parameters:
img- the Image containing the signal to which the fit will be performedpath- thePathto be fittedxSpacing- pixel width in physical distanceySpacing- pixel height in physical distancezSpacing- pixel depth in physical distanceunit- spatial calibration unit
-
PathFitter
Instantiates a new PathFitter.
-
-
Method Details
-
setShowAnnotatedView
public void setShowAnnotatedView(boolean showAnnotatedView) Sets whether an interactive image of the result should be displayed.- Parameters:
showAnnotatedView- If true, an interactive stack (cross-section view) of the fit is displayed. Note that this is probably only useful if SNT's UI is visible and functional.
-
setProgressCallback
public void setProgressCallback(int fitterIndex, sc.fiji.snt.MultiTaskProgress progress) -
readPreferences
public void readPreferences() -
applySettings
-
call
Takes the signal from the image specified in the constructor to fit cross-section circles around the nodes of input path. Computation of fit is confined to the neighborhood specified bysetCrossSectionRadius(double).- Specified by:
callin interfaceCallable<Path>- Returns:
- the reference to the computed result. Note that this Path is *not* automatically
set as the fitted version of input Path. That only happens when
applyFit()is called. - Throws:
IllegalArgumentException- See Also:
-
applyFit
public void applyFit()Applies the fitted result to the path. For multithreaded processing: Must be called sequentially after all parallel fitting is complete. -
getPath
- Returns:
- the path being fitted
-
getSucceeded
public boolean getSucceeded()Checks whether the fit succeeded.- Returns:
- true if fit was successful, false otherwise
-
setCrossSectionRadius
public void setCrossSectionRadius(double crossSectionRadius) Sets the radius of cross-sectional planes sampled around each node.At each node, PathFitter samples a square cross-section perpendicular to the path tangent. This radius controls the physical extent of that sampling.
- Parameters:
crossSectionRadius- the physical search radius (in physical units)
-
setScope
public void setScope(int scope) Sets the fitting scope.- Parameters:
scope- EitherRADII,MIDPOINTS, orRADII_AND_MIDPOINTS
-
setNodeRadiusFallback
public void setNodeRadiusFallback(int fallback) Sets the fallback strategy for node radii at locations where fitting failed.When cross-section fitting fails at a node (e.g., low SNR, ambiguous geometry), this strategy determines what radius value to assign to that node.
- Parameters:
fallback- the fallback strategy:FALLBACK_MODE,FALLBACK_MIN_SEP, orFALLBACK_NAN
-
setReplaceNodes
public void setReplaceNodes(boolean replaceNodes) Sets whether fitting should occur "in place".- Parameters:
replaceNodes- If true, the nodes of the input Path will be replaced by those of the fitted result. If false, the fitted result is kept as a separated Path linked to the input as perPath.getFitted(). Note that in the latter case, some topological operations (e.g., forking) performed on the fitted result may not percolate to the non-fitted Path.
-
setImage
public void setImage(net.imglib2.RandomAccessibleInterval<? extends net.imglib2.type.numeric.RealType<?>> img) Sets the target image- Parameters:
img- the Image containing the signal to which the fit will be performed
-