public class PathAndFillManager
extends org.xml.sax.helpers.DefaultHandler
implements ij3d.UniverseListener
SNT
instance, but accessing a PathAndFillManager directly is useful
for batch/headless operations.Modifier and Type | Class and Description |
---|---|
class |
PathAndFillManager.AllPointsIterator |
Constructor and Description |
---|
PathAndFillManager()
Instantiates a new PathAndFillManager using default values.
|
PathAndFillManager(double x_spacing,
double y_spacing,
double z_spacing,
java.lang.String spacing_units)
Instantiates a new PathAndFillManager imposing specified pixel dimensions,
which may be required for pixel operations.
|
Modifier and Type | Method and Description |
---|---|
void |
addPath(Path p)
Adds a new path.
|
void |
addPathAndFillListener(sc.fiji.snt.PathAndFillListener listener)
Adds a PathAndFillListener.
|
void |
addTree(Tree tree)
Adds a
Tree . |
java.util.Iterator<PointInImage> |
allPointsIterator() |
boolean |
anySelected()
Checks whether at least one Path is currently selected in the UI.
|
void |
canvasResized()
Deprecated.
|
void |
clear()
Deletes all paths and fills.
|
void |
contentAdded(ij3d.Content c)
Deprecated.
|
void |
contentChanged(ij3d.Content c)
Deprecated.
|
void |
contentRemoved(ij3d.Content c)
Deprecated.
|
void |
contentSelected(ij3d.Content c)
Deprecated.
|
static PathAndFillManager |
createFromFile(java.lang.String filePath)
Creates a PathAndFillManager instance from imported data
|
static PathAndFillManager |
createFromNodes(java.util.Collection<SWCPoint> nodes)
Creates a PathAndFillManager instance from a collection of reconstruction
nodes.
|
boolean |
deletePath(int index)
Deletes a Path by index
|
boolean |
deletePath(Path p)
Deletes a path.
|
void |
deletePaths(int[] indices)
Delete paths by position.
|
void |
downsampleAll(double maximumPermittedDistance)
Downsamples alls path using Ramer–Douglas–Peucker simplification.
|
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName) |
boolean |
exportAllPathsAsSWC(java.lang.String baseFilename)
Exports all as Paths as SWC file(s).
|
void |
exportFillsAsCSV(java.io.File outputFile)
Export fills as CSV.
|
void |
exportToCSV(java.io.File outputFile)
Output some potentially useful information about all the Paths managed by
this instance as a CSV (comma separated values) file.
|
BoundingBox |
getBoundingBox(boolean compute)
Returns the BoundingBox enclosing all nodes of all existing Paths.
|
java.util.List<NearPoint> |
getCorrespondences(PathAndFillManager other,
double maxDistance)
For each point in this PathAndFillManager, find the corresponding point on
the other one.
|
Path |
getPath(int i)
Returns the Path at the specified position in the PathAndFillManager list.
|
Path |
getPathFromID(int id)
Returns the Path with the specified id.
|
Path |
getPathFromName(java.lang.String name,
boolean caseSensitive)
Returns the Path with the specified name.
|
int |
getPathIndex(Path p)
Gets the index of a Path
|
java.util.ArrayList<Path> |
getPaths()
Returns all the paths.
|
java.util.ArrayList<Path> |
getPathsFiltered() |
Path[] |
getPathsStructured() |
Path[] |
getPathsStructured(java.util.Collection<Path> paths) |
SNT |
getPlugin()
Gets the SNT instance.
|
java.util.Set<Path> |
getSelectedPaths()
Gets all paths selected in the GUI
|
java.util.List<SWCPoint> |
getSWCFor(java.util.Collection<Path> paths)
Gets the list of SWCPoints associated with a collection of Paths.
|
java.util.Map<java.lang.String,Tree> |
importNeurons(java.util.Map<java.lang.String,java.util.TreeSet<SWCPoint>> map,
org.scijava.util.ColorRGB color,
java.lang.String spatialUnit)
Import neuron(s) as a collection of reconstruction nodes (SWC points)
|
boolean |
importSWC(java.lang.String urlOrFilePath)
Imports an SWC file using default settings.
|
boolean |
importSWC(java.lang.String filePath,
boolean assumeCoordinatesInVoxels,
double xOffset,
double yOffset,
double zOffset,
double xScale,
double yScale,
double zScale,
boolean replaceAllPaths)
Imports an SWC file using advanced options.
|
java.util.List<Tree> |
importSWCs(java.util.Map<java.lang.String,java.lang.String> swcs,
org.scijava.util.ColorRGB color)
Imports a group of SWC files (Remote URLs supported).
|
boolean |
isSelected(Path path)
Checks if a Path is currently selected in the GUI.
|
boolean |
load(java.lang.String filePath)
Imports a reconstruction file (any supported extension).
|
NearPoint |
nearestPointOnAnyPath(double x,
double y,
double z,
double distanceLimit) |
void |
resetListeners(Path justAdded) |
void |
setHeadless(boolean headless)
Sets whether this PathAndFillManager instance should run headless.
|
int |
size()
Returns the number of Paths in the PathAndFillManager list.
|
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes) |
void |
transformationFinished(org.scijava.java3d.View view) |
void |
transformationStarted(org.scijava.java3d.View view) |
void |
transformationUpdated(org.scijava.java3d.View view) |
PathAndFillManager |
transformPaths(PathTransformer transformation,
ij.ImagePlus templateImage,
ij.ImagePlus modelImage) |
void |
universeClosed()
Deprecated.
|
public PathAndFillManager()
public PathAndFillManager(double x_spacing, double y_spacing, double z_spacing, java.lang.String spacing_units)
Path
s created under
this instance, will adopt the specified spacing details.x_spacing
- the 'voxel width'y_spacing
- the 'voxel height'z_spacing
- the 'voxel depth'spacing_units
- the spacing units (e.g., 'um', 'mm)public int size()
public void addPathAndFillListener(sc.fiji.snt.PathAndFillListener listener)
listener
- the listenerpublic Path getPath(int i)
i
- the index of the Pathpublic Path getPathFromName(java.lang.String name, boolean caseSensitive)
name
- the name of the Path to be retrievedcaseSensitive
- If true, case considerations are ignoredpublic Path getPathFromID(int id)
id
- the id of the Path to be retrievedpublic boolean isSelected(Path path)
path
- the path to be checkedpublic java.util.Set<Path> getSelectedPaths()
public boolean anySelected()
public boolean exportAllPathsAsSWC(java.lang.String baseFilename)
baseFilename
- the file path (including common basename) for exported
files. The .swc
extension can be omitted. Each
traced structure will be saved into a dedicated file
using a 3-digits identifier. E.g., if only a single
structure exists, specifying /path/to/results
,
generates a /path/to/results-000.swc
file.public void setHeadless(boolean headless)
headless
- true to activate headless calls, otherwise falsepublic BoundingBox getBoundingBox(boolean compute)
compute
- If true, BoundingBox dimensions will be computed for all the
existing Paths. If false, the last computed BoundingBox will be
returned. Also, if BoundingBox is not scaled, its spacing will be
computed from the smallest inter-node distance of an arbitrary '
large' Path. Computations of Path boundaries typically occur
during import operations.public Path[] getPathsStructured()
public java.util.List<SWCPoint> getSWCFor(java.util.Collection<Path> paths) throws sc.fiji.snt.SWCExportException
paths
- the paths from which to retrieve the listpaths
sc.fiji.snt.SWCExportException
- if list could not be retrievedpublic void resetListeners(Path justAdded)
public void addTree(Tree tree)
Tree
.tree
- the collection of paths to be addedpublic void addPath(Path p)
p
- the Path to be addedpublic boolean deletePath(int index)
index
- the index (zero-based) of the Path to be deletedpublic boolean deletePath(Path p) throws java.lang.IllegalArgumentException
p
- the path to be deletedjava.lang.IllegalArgumentException
public int getPathIndex(Path p)
p
- the Path for which the index should be retrievedpublic void deletePaths(int[] indices)
indices
- the indices to be deletedpublic void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws sc.fiji.snt.TracesFileFormatException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
sc.fiji.snt.TracesFileFormatException
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws sc.fiji.snt.TracesFileFormatException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
sc.fiji.snt.TracesFileFormatException
public static PathAndFillManager createFromFile(java.lang.String filePath)
filePath
- the absolute path of the file to be imported as per
load(String)
public static PathAndFillManager createFromNodes(java.util.Collection<SWCPoint> nodes)
nodes
- the collection of reconstruction nodes. Nodes will be sorted by
id and any duplicate entries pruned.public void clear()
public boolean importSWC(java.lang.String urlOrFilePath)
urlOrFilePath
- the URL pointing to the SWC file or the absolute file
path of a local file. Note that with URLs, https may not be
supported.NeuroMorphoLoader
,
importSWC(String, boolean)
,
importSWC(BufferedReader, boolean, double, double, double, double,
double, double, boolean)
public java.util.List<Tree> importSWCs(java.util.Map<java.lang.String,java.lang.String> swcs, org.scijava.util.ColorRGB color)
swcs
- the HashMap containing the absolute file paths (or URLs) of
files to be imported as values and a file descriptor as keys.color
- the color to be applied to imported Paths. If null, paths from
each file will assigned unique colorsTree
s labeled after the file
descriptor. The returned list will not contain null elements: If a
file was not successfully imported an empty Tree will be generatedTree.isEmpty()
,
Tree.getLabel()
,
SNTColor.getDistinctColors(int)
public java.util.Map<java.lang.String,Tree> importNeurons(java.util.Map<java.lang.String,java.util.TreeSet<SWCPoint>> map, org.scijava.util.ColorRGB color, java.lang.String spatialUnit)
map
- the input map of reconstruction nodescolor
- the color to be applied to imported Paths. If null, paths
from each ID will assigned unique colorsspatialUnit
- the spatial unit (um, mm, etc) associated with imported
nodes. If null, "um" are assumedSNTColor.getDistinctColors(int)
public boolean importSWC(java.lang.String filePath, boolean assumeCoordinatesInVoxels, double xOffset, double yOffset, double zOffset, double xScale, double yScale, double zScale, boolean replaceAllPaths)
filePath
- the absolute file path to the imported fileassumeCoordinatesInVoxels
- see
importSWC(BufferedReader, boolean, double, double, double, double, double, double, boolean)
xOffset
- see
importSWC(BufferedReader, boolean, double, double, double, double, double, double, boolean)
yOffset
- see
importSWC(BufferedReader, boolean, double, double, double, double, double, double, boolean)
zOffset
- see
importSWC(BufferedReader, boolean, double, double, double, double, double, double, boolean)
xScale
- see
importSWC(BufferedReader, boolean, double, double, double, double, double, double, boolean)
yScale
- see
importSWC(BufferedReader, boolean, double, double, double, double, double, double, boolean)
zScale
- see
importSWC(BufferedReader, boolean, double, double, double, double, double, double, boolean)
replaceAllPaths
- see
importSWC(BufferedReader, boolean, double, double, double, double, double, double, boolean)
public boolean load(java.lang.String filePath)
filePath
- the absolute path to the file (.Traces, SWC or JSON) to be
importedpublic java.util.ArrayList<Path> getPaths()
public java.util.ArrayList<Path> getPathsFiltered()
public void transformationStarted(org.scijava.java3d.View view)
transformationStarted
in interface ij3d.UniverseListener
public void transformationUpdated(org.scijava.java3d.View view)
transformationUpdated
in interface ij3d.UniverseListener
public void transformationFinished(org.scijava.java3d.View view)
transformationFinished
in interface ij3d.UniverseListener
@Deprecated public void contentAdded(ij3d.Content c)
contentAdded
in interface ij3d.UniverseListener
@Deprecated public void contentRemoved(ij3d.Content c)
contentRemoved
in interface ij3d.UniverseListener
@Deprecated public void contentChanged(ij3d.Content c)
contentChanged
in interface ij3d.UniverseListener
@Deprecated public void contentSelected(ij3d.Content c)
contentSelected
in interface ij3d.UniverseListener
@Deprecated public void canvasResized()
canvasResized
in interface ij3d.UniverseListener
@Deprecated public void universeClosed()
universeClosed
in interface ij3d.UniverseListener
public NearPoint nearestPointOnAnyPath(double x, double y, double z, double distanceLimit)
public java.util.Iterator<PointInImage> allPointsIterator()
public java.util.List<NearPoint> getCorrespondences(PathAndFillManager other, double maxDistance)
other
- the other PathAndFillManager holding the corresponding PathsmaxDistance
- the distance limit below which the NearPoint is
consideredNearPoint
correspondencespublic void exportFillsAsCSV(java.io.File outputFile) throws java.io.IOException
outputFile
- the output filejava.io.IOException
- Signals that an I/O exception has occurred.public void exportToCSV(java.io.File outputFile) throws java.io.IOException
outputFile
- the output filejava.io.IOException
- if data could not be storedpublic PathAndFillManager transformPaths(PathTransformer transformation, ij.ImagePlus templateImage, ij.ImagePlus modelImage)
public void downsampleAll(double maximumPermittedDistance)
maximumPermittedDistance
- the maximum permitted distance between
nodes.