Package sc.fiji.snt.analysis
Class RoiConverter
java.lang.Object
sc.fiji.snt.analysis.RoiConverter
Converts SNT
Paths into (IJ1) ROIs.- Author:
- Tiago Ferreira
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRoiConverter(Collection<Path> paths, ij.ImagePlus imp) Instantiates a new Converter.RoiConverter(Path path, ij.ImagePlus imp) Instantiates a new Converter.RoiConverter(Tree tree) Instantiates a new Converter.RoiConverter(Tree tree, ij.ImagePlus imp) Instantiates a new Converter. -
Method Summary
Modifier and TypeMethodDescriptionstatic ij.gui.Roistatic ij.gui.Roiconvert(Collection<Path> paths, ij.ImagePlus imp) voidconvertBranches(ij.gui.Overlay overlay) voidConverts all the branch points associated with the parsed paths intoPointRois, adding them to the overlay of the image specified in the constructor.voidconvertBranchPoints(ij.gui.Overlay overlay) Converts all the branch points associated with the parsed paths intoPointRoisvoidconvertInnerBranches(ij.gui.Overlay overlay) voidConverts paths into 2D polyline ROIs (segment paths), adding them to the overlay of the image specified in the constructor.ij.gui.OverlayconvertPaths(ij.gui.Overlay overlay) Converts paths into 2D polyline ROIs.ij.gui.OverlayconvertPaths(ij.gui.Overlay overlay, Collection<Path> paths) Converts an ad-hoc collection of paths into 2D polyline ROIs.voidconvertPrimaryBranches(ij.gui.Overlay overlay) voidConverts the starting nodes of primary paths in the parsed pool intoPointRoisvoidconvertRoots(ij.gui.Overlay overlay) Converts the starting nodes of primary paths in the parsed pool intoPointRoisvoidconvertTerminalBranches(ij.gui.Overlay overlay) voidConverts all the tips associated with the parsed paths intoPointRois, adding them to the overlay of the image specified in the constructor.voidconvertTips(ij.gui.Overlay overlay) Converts all the tips associated with the parsed paths intoPointRoisstatic ij.gui.Roienlarge(ij.gui.Roi roi, int pixels) static ij.gui.Roiget2DBoundingBox(Collection<Path> paths, int exportPlane) static double[]get2dCentroid(ij.gui.Roi roi) static List<long[]> getCentroids(Collection<ij.gui.Roi> rois) Extracts centroids from a collection of ROIs as integer pixel coordinates.static doublegetFittedRadius(ij.ImagePlus imp, ij.gui.Roi areaRoi) Retrieves the radius of a circle with the same area of the specified area ROI.static List<ij.gui.Roi> getROIs(ij.gui.Overlay overlay, int channel, int zSlice, int tFrame) Extracts ROIs associated with a specified CZT position.List<ij.gui.PolygonRoi> Gets ROI representations of the specified path.List<ij.gui.Roi> getZplaneROIs(int zSlice) Extracts all the ROIs converted so far associated with the specified Z-plane.static List<ij.gui.Roi> getZplaneROIs(ij.gui.Overlay overlay, int zSlice) Extracts ROIs associated with a specified Z position.static List<ij.gui.Roi> loadRoisFromZip(File zipFile) static booleansaveRoisToZip(List<ij.gui.Roi> rois, File file) voidsetStrokeWidth(int width) Sets the line width of converted segment paths.voidsetView(int view) Sets the exporting view for segment paths (XY by default).static ij.gui.PointRoitoPointRoi(List<Detection> detections, ij.ImagePlus imp, String name, Color color) Creates a groupedPointRoifrom a list ofDetections.voiduseSWCcolors(boolean useSWCcolors) Specifies coloring of ROIs by SWC type.
-
Field Details
-
XY_PLANE
public static final int XY_PLANESNT's XY view (the default export plane)- See Also:
-
ZY_PLANE
public static final int ZY_PLANESNT's ZY view- See Also:
-
XZ_PLANE
public static final int XZ_PLANESNT's XZ view- See Also:
-
-
Constructor Details
-
RoiConverter
Instantiates a new Converter. Since an image has not been specified, C,Z,T positions may not be properly for converted nodes.- Parameters:
tree- the Tree to be converted
-
RoiConverter
Instantiates a new Converter.- Parameters:
path- the Path to be convertedimp- the image associated with the Tree, used to properly assign C,T positions of converted nodes
-
RoiConverter
Instantiates a new Converter.- Parameters:
paths- the collection of Paths to be convertedimp- the image associated with the collection, used to properly assign C,T positions of converted nodes
-
RoiConverter
Instantiates a new Converter.- Parameters:
tree- the Tree to be convertedimp- the image associated with the Tree, used to properly assign C,T positions of converted nodes
-
-
Method Details
-
convertPaths
public ij.gui.Overlay convertPaths(ij.gui.Overlay overlay) Converts paths into 2D polyline ROIs.- Parameters:
overlay- the target overlay to hold converted paths- Returns:
- a reference to the overlay holding paths
-
convertPaths
Converts an ad-hoc collection of paths into 2D polyline ROIs.- Parameters:
overlay- the target overlay to hold converted pathspaths- the collection of paths to be converted (e.g., a list of branches produced byStrahlerAnalyzer- Returns:
- a reference to the overlay holding paths
-
getROIs
Gets ROI representations of the specified path.Converts the path to a list of PolygonRoi objects using the path's name as the ROI name. The conversion respects the current view setting.
- Parameters:
path- the path to convert- Returns:
- a list of PolygonRoi objects representing the path
-
convertTips
public void convertTips(ij.gui.Overlay overlay) Converts all the tips associated with the parsed paths intoPointRois- Parameters:
overlay- the target overlay to hold converted point- See Also:
-
convertRoots
public void convertRoots(ij.gui.Overlay overlay) Converts the starting nodes of primary paths in the parsed pool intoPointRois- Parameters:
overlay- the target overlay to hold converted point
-
convertPaths
Converts paths into 2D polyline ROIs (segment paths), adding them to the overlay of the image specified in the constructor.- Throws:
IllegalArgumentException- if this RoiConverter instance is not aware of any image- See Also:
-
convertBranches
public void convertBranches(ij.gui.Overlay overlay) -
convertInnerBranches
public void convertInnerBranches(ij.gui.Overlay overlay) -
convertPrimaryBranches
public void convertPrimaryBranches(ij.gui.Overlay overlay) -
convertTerminalBranches
public void convertTerminalBranches(ij.gui.Overlay overlay) -
convertTips
Converts all the tips associated with the parsed paths intoPointRois, adding them to the overlay of the image specified in the constructor.- Throws:
IllegalArgumentException- if this RoiConverter instance is not aware of any image- See Also:
-
convertBranchPoints
Converts all the branch points associated with the parsed paths intoPointRois, adding them to the overlay of the image specified in the constructor.- Throws:
IllegalArgumentException- if this RoiConverter instance is not aware of any image- See Also:
-
convertRoots
Converts the starting nodes of primary paths in the parsed pool intoPointRois- Throws:
IllegalArgumentException- if this RoiConverter instance is not aware of any image- See Also:
-
getZplaneROIs
Extracts all the ROIs converted so far associated with the specified Z-plane. It is assumed that ROIs are stored in the overlay of the image specified in the constructor.- Throws:
IllegalArgumentException- if this RoiConverter instance is not aware of any image
-
convertBranchPoints
public void convertBranchPoints(ij.gui.Overlay overlay) Converts all the branch points associated with the parsed paths intoPointRois- Parameters:
overlay- the target overlay to hold converted point- See Also:
-
setView
public void setView(int view) Sets the exporting view for segment paths (XY by default). -
useSWCcolors
public void useSWCcolors(boolean useSWCcolors) Specifies coloring of ROIs by SWC type.- Parameters:
useSWCcolors- if true converted ROIs are colored according to their SWC type integer flag
-
setStrokeWidth
public void setStrokeWidth(int width) Sets the line width of converted segment paths. Set it to -1 to have ROIs plotted using the average diameter of the path- Parameters:
width- the new stroke width- See Also:
-
getZplaneROIs
Extracts ROIs associated with a specified Z position.- Parameters:
overlay- the overlay holding ROIszSlice- the z-plane (1-based index)- Returns:
- the sub-list of ROIs associated with the specified Z position. Note that ROIs with a ZPosition of 0 are considered to be associated with all Z-slices of a stack
-
getROIs
Extracts ROIs associated with a specified CZT position. Only ROIS with known hyperstackPosition are considered.- Parameters:
overlay- the overlay holding ROIschannel- the channel (1-based index)zSlice- the z-plane (1-based index)tFrame- the t-frame (1-based index)- Returns:
- the sub-list of ROIs associated with the specified CZT position
- See Also:
-
enlarge
public static ij.gui.Roi enlarge(ij.gui.Roi roi, int pixels) -
combine
-
convert
-
toPointRoi
public static ij.gui.PointRoi toPointRoi(List<Detection> detections, ij.ImagePlus imp, String name, Color color) Creates a groupedPointRoifrom a list ofDetections. Each detection's pixel coordinates and stack position are computed viaDetection.xyzct().- Parameters:
detections- the detections to convertimp- the image used to resolve stack positions (channel, Z, frame)name- the ROI name, ornullfor no namecolor- the stroke color, ornullfor default- Returns:
- a PointRoi containing all detection points with per-point Z positions
- Throws:
IllegalArgumentException- if detections or imp is null
-
get2DBoundingBox
-
getFittedRadius
public static double getFittedRadius(ij.ImagePlus imp, ij.gui.Roi areaRoi) Retrieves the radius of a circle with the same area of the specified area ROI.- Parameters:
imp- The image associated with the ROIareaRoi- The input area ROI- Returns:
- the radius (in calibrated units) of a circle with the same area of
areaRoi
-
get2dCentroid
public static double[] get2dCentroid(ij.gui.Roi roi) -
getCentroids
Extracts centroids from a collection of ROIs as integer pixel coordinates. Each centroid is computed viaget2dCentroid(Roi)and rounded to the nearest pixel. The Z coordinate is derived fromRoi.getZPosition(): ROIs associated with a specific slice produce a 0-indexed Z value (getZPosition() - 1); ROIs not associated with a particular slice (getZPosition() == 0) producez = -1, indicating that the Z position is unresolved and should be determined by the caller. Null ROIs or ROIs whose centroid cannot be determined are silently skipped.- Parameters:
rois- the ROIs to extract centroids from- Returns:
- list of
long[]{x, y, z}pixel coordinates (z is 0-indexed, or-1if the ROI has no slice association), one per valid ROI (may be smaller than input if some ROIs are null/invalid) - See Also:
-
saveRoisToZip
-
loadRoisFromZip
-