Package sc.fiji.snt
Class SNTService
java.lang.Object
org.scijava.AbstractContextual
org.scijava.plugin.AbstractRichPlugin
org.scijava.service.AbstractService
sc.fiji.snt.SNTService
- All Implemented Interfaces:
Comparable<org.scijava.Prioritized>,net.imagej.ImageJService,org.scijava.Contextual,org.scijava.Disposable,org.scijava.Identifiable,org.scijava.Initializable,org.scijava.Locatable,org.scijava.log.Logged,org.scijava.plugin.HasPluginInfo,org.scijava.plugin.RichPlugin,org.scijava.plugin.SciJavaPlugin,org.scijava.Prioritized,org.scijava.service.Service,org.scijava.Versioned
public class SNTService
extends org.scijava.service.AbstractService
implements net.imagej.ImageJService
Service for accessing and scripting the active instance of
SNT.- Author:
- Tiago Ferreira, Kyle Harrington
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassignValues(boolean selectedPathsOnly) Assigns pixel intensities at each Path node, storing them as Path values.ij.ImagePlusReturns one of the demo images bundled with SNT image associated with the demo (fractal) tree.net.imagej.ImgPlus<?> Returns one of the demo images bundled with SNT as anImgPlus.demoTree()Deprecated.Returns a demo tree.ij.ImagePlusDeprecated.Returns a collection of four demo reconstructions (dendrites from pyramidal cells from the MouseLight database).voiddispose()Quits SNT.getAnalyzer(boolean selectedPathsOnly) Deprecated.org.scijava.ContextReturns a reference to the activeSNTinstance.Returns thePathAndFillManagerassociated with the current SNT instance.getPaths()Gets the paths currently listed in the Path ManagerDeprecated.usegetInstance()insteadReturns a reference to the active Reconstruction Viewer (either stand-alone or SNT-associated instance).getRecViewer(int id) Returns a reference to an opened Reconstruction Viewer (standalone instance)Gets the paths currently selected in the Path Manager list.getStatistics(boolean selectedPathsOnly) Returns aTreeStatisticsinstance constructed from current Paths.getTable()Returns a reference to SNT's main table of measurements.getTree()Gets the collection of paths listed in the Path Manager as aTreeobject.getTree(boolean selectedPathsOnly) Gets the collection of paths listed in the Path Manager as aTreeobject.getTrees()Gets the collection of paths listed in the Path Manager as aTreeobject.getUI()Returns a reference to SNT's UI.initialize(boolean startUI) Initializes SNT.initialize(ij.ImagePlus imp, boolean startUI) Initializes SNT.initialize(String imagePath, boolean startUI) Initializes SNT.<T extends net.imglib2.type.numeric.RealType<T>>
SNTinitialize(net.imagej.ImgPlus<T> img, boolean startUI) Initializes SNT from anImgPlusimage.booleanisActive()Gets whether SNT is running.voidloadGraph(DirectedWeightedGraph graph) voidloadTracings(String filePathOrURL) Loads the specified tracings file.voidLoads the specified tree.voidloadTrees(Collection<Tree> trees) Loads the specified collection of trees.newRecViewer(boolean guiControls) Instantiates a new standalone Reconstruction Viewer.voidrequireVersion(String minVersion) Ensures the running SNT version meets a minimum requirement.booleanSaves all the existing paths to a file.voidScript-friendly method for updating (refreshing) all viewers currently in use by SNT.Methods inherited from class org.scijava.service.AbstractService
setContext, toStringMethods inherited from class org.scijava.plugin.AbstractRichPlugin
getInfo, getPriority, setInfo, setPriorityMethods inherited from class org.scijava.AbstractContextual
contextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.scijava.Contextual
context, setContextMethods inherited from interface org.scijava.plugin.HasPluginInfo
getInfo, setInfoMethods inherited from interface org.scijava.Locatable
getLocationMethods inherited from interface org.scijava.Prioritized
compareTo, getPriority, setPriorityMethods inherited from interface org.scijava.plugin.RichPlugin
getIdentifier, logMethods inherited from interface org.scijava.service.Service
initialize, registerEventHandlersMethods inherited from interface org.scijava.Versioned
getVersion
-
Constructor Details
-
SNTService
public SNTService()
-
-
Method Details
-
requireVersion
Ensures the running SNT version meets a minimum requirement. This is analogous to IJ'srequires()macro function.- Parameters:
minVersion- the minimum required version string, e.g.,"5.0.4"- Throws:
IllegalStateException- if the running version is older thanminVersion
-
isActive
public boolean isActive()Gets whether SNT is running.- Returns:
- true if this
SNTServiceis active, tied to the active instance of SNT
-
assignValues
public void assignValues(boolean selectedPathsOnly) throws UnsupportedOperationException, IllegalArgumentException Assigns pixel intensities at each Path node, storing them as Path values. Assigned intensities are those of the channel and time point currently being traced. Assumes SNT has been initialized with a valid image.- Parameters:
selectedPathsOnly- If true, only selected paths will be assigned values, otherwise voxel intensities will be assigned to all paths- Throws:
UnsupportedOperationException- if SNT is not runningIllegalArgumentException- If valid imaged data is not available- See Also:
-
initialize
Initializes SNT. Since no image is specified, tracing functions are disabled.- Parameters:
startUI- Whether SNT's UI should also be initialized;- Returns:
- the SNT instance.
-
initialize
public SNT initialize(String imagePath, boolean startUI) throws InterruptedException, InvocationTargetException Initializes SNT.- Parameters:
imagePath- the image to be traced. If starting with "demo:" followed by the name of a demo dataset, SNT is initialized using the correspondingdemoImage(String)image. If empty or null and SNT's UI is available an "Open" dialog prompt is displayed. URL's supported.startUI- Whether SNT's UI should also be initialized;- Returns:
- the SNT instance.
- Throws:
InterruptedExceptionInvocationTargetException
-
initialize
public SNT initialize(ij.ImagePlus imp, boolean startUI) throws InterruptedException, InvocationTargetException Initializes SNT.- Parameters:
imp- the image to be traced (null not allowed)startUI- Whether SNT's UI should also be initialized;- Returns:
- the SNT instance.
- Throws:
InterruptedExceptionInvocationTargetException
-
initialize
public <T extends net.imglib2.type.numeric.RealType<T>> SNT initialize(net.imagej.ImgPlus<T> img, boolean startUI) throws InterruptedException, InvocationTargetException Initializes SNT from anImgPlusimage. This is the imglib2 counterpart ofinitialize(ImagePlus, boolean).- Type Parameters:
T- pixel type- Parameters:
img- the image to be traced (null not allowed)startUI- Whether SNT's UI should also be initialized- Returns:
- the SNT instance.
- Throws:
InterruptedExceptionInvocationTargetException- See Also:
-
getPlugin
Deprecated.usegetInstance()instead -
getInstance
Returns a reference to the activeSNTinstance.- Returns:
- the
SNTinstance
-
loadTracings
public void loadTracings(String filePathOrURL) throws UnsupportedOperationException, IOException, URISyntaxException Loads the specified tracings file.- Parameters:
filePathOrURL- either a "SWC", "TRACES" or "JSON" file path. URLs defining remote files also supported. Null not allowed.- Throws:
UnsupportedOperationException- if SNT is not runningIOException- if data cannot be importedURISyntaxException
-
loadTree
Loads the specified tree. Note that if SNT has not been properly initialized, spatial calibration mismatches may occur. In that case, assign the spatial calibration of the image to {#@code Tree} usingTree.assignImage(ImagePlus), before loading it.- Parameters:
tree- theTreeto be loaded (null not allowed).- Throws:
UnsupportedOperationException- if SNT is not running
-
loadTrees
Loads the specified collection of trees.- Parameters:
trees- the collection ofTreeto be loaded (null not allowed).- Throws:
UnsupportedOperationException- if SNT is not running- See Also:
-
loadGraph
- Throws:
UnsupportedOperationException
-
save
Saves all the existing paths to a file.- Parameters:
filePath- the saving output file path. IffilePathends in ".swc" (case-insensitive), an SWC file is created, otherwise a "traces" file is created. If empty and a GUI exists, a save prompt is displayed.- Returns:
- true, if paths exist and file was successfully written.
- Throws:
UnsupportedOperationException- if SNT is not running
-
getSelectedPaths
Gets the paths currently selected in the Path Manager list.- Returns:
- the paths currently selected, or null if no selection exists
- Throws:
UnsupportedOperationException- if SNT is not running- See Also:
-
getPaths
Gets the paths currently listed in the Path Manager- Returns:
- all the listed paths, or null if the Path Manager is empty
- Throws:
UnsupportedOperationException- if SNT is not running- See Also:
-
getTree
Gets the collection of paths listed in the Path Manager as aTreeobject.- Parameters:
selectedPathsOnly- If true, only selected paths are retrieved- Returns:
- the Tree holding the Path collection
- Throws:
UnsupportedOperationException- if SNT is not running
-
getTree
Gets the collection of paths listed in the Path Manager as aTreeobject.- Returns:
- the Tree holding the Path collection
- Throws:
UnsupportedOperationException- if SNT is not running
-
getTrees
Gets the collection of paths listed in the Path Manager as aTreeobject.- Returns:
- the Tree holding the Path collection
- Throws:
UnsupportedOperationException- if SNT is not running
-
getAnalyzer
Deprecated.UsegetStatistics(boolean)instead -
getStatistics
Returns aTreeStatisticsinstance constructed from current Paths.- Parameters:
selectedPathsOnly- If true only selected paths will be considered- Returns:
- the TreeStatistics instance
- Throws:
UnsupportedOperationException- if SNT is not running
-
getPathAndFillManager
Returns thePathAndFillManagerassociated with the current SNT instance.- Returns:
- the PathAndFillManager instance
- Throws:
UnsupportedOperationException- if no SNT instance exists.
-
updateViewers
public void updateViewers()Script-friendly method for updating (refreshing) all viewers currently in use by SNT. Does nothing if no SNT instance exists. -
getUI
Returns a reference to SNT's UI.- Returns:
- the
SNTUIwindow, or null if SNT is not running, or is running without GUI
-
getRecViewer
Returns a reference to the active Reconstruction Viewer (either stand-alone or SNT-associated instance). A new instance is retrieved if none exists.- Returns:
- The active
Viewer3Dinstance. For stand-alone viewers, this is typically the viewer that is frontmost or the last initiated viewer.
-
getRecViewer
Returns a reference to an opened Reconstruction Viewer (standalone instance). *- Parameters:
id- the unique numeric ID of the Reconstruction Viewer to be retrieved (as used by the "Script This Viewer" command, and typically displayed in the Viewer's window title)- Returns:
- The standalone
Viewer3Dinstance, or null if id was not recognized
-
newRecViewer
Instantiates a new standalone Reconstruction Viewer.- Returns:
- The standalone
Viewer3Dinstance
-
getOrCreateSciViewSNT
- Throws:
NoClassDefFoundError
-
getSciViewSNT
-
getTable
Returns a reference to SNT's main table of measurements.- Returns:
- SNT measurements table (a
DefaultGenericTable) - Throws:
UnsupportedOperationException- if SNT is not running
-
demoTree
Deprecated.Returns a toy reconstruction (fractal tree).- Returns:
- a reference to the loaded tree, or null if data could not be retrieved
- See Also:
-
demoTree
Returns a demo tree.- Parameters:
tree- a string describing the type of demo tree. Either 'fractal' for the L-system toy neuron, 'pyramidal' for the dendritic arbor of mouse pyramidal cell (MouseLight's cell AA0001), 'OP1'for the DIADEM OP_1 reconstruction, or 'DG' for the dentate gyrus granule cell (Neuromorpho's Beining archive)- See Also:
-
demoTreeImage
Deprecated.Returns the image associated with the demo (fractal) tree.- Returns:
- a reference to the image tree, or null if data could not be retrieved
- See Also:
-
demoImage
Returns one of the demo images bundled with SNT image associated with the demo (fractal) tree.- Parameters:
img- a string describing the type of demo image. Options include: 'fractal' for the L-system toy neuron; 'ddaC' for the C4 ddaC drosophila neuron (demo image initially distributed with the Sholl plugin); 'OP1'/'OP_1' for the DIADEM OP_1 dataset; 'cil701', 'cil810', or 'ci41458' for the respective Cell Image Library entries, and 'binary timelapse' for a small 4-frame sequence of neurite growth- Returns:
- the demo image, or null if data could not be retrieved
- See Also:
-
demoImg
Returns one of the demo images bundled with SNT as anImgPlus. This is the imglib2 counterpart ofdemoImage(String).- Parameters:
img- a string describing the type of demo image (same options asdemoImage(String))- Returns:
- the demo image as an ImgPlus, or null if data could not be retrieved or converted
- See Also:
-
demoTrees
Returns a collection of four demo reconstructions (dendrites from pyramidal cells from the MouseLight database). NB: Data is cached locally. No internet connection required.- Returns:
- the list of
Trees, corresponding to the dendritic arbors of cells "AA0001", "AA0002", "AA0003", "AA0004" (MouseLight database IDs).
-
demoTreesSWC
-
dispose
public void dispose()Quits SNT. Does nothing if SNT is currently not running.- Specified by:
disposein interfaceorg.scijava.Disposable
-
getContext
public org.scijava.Context getContext()- Specified by:
getContextin interfaceorg.scijava.Contextual- Overrides:
getContextin classorg.scijava.service.AbstractService
-
getStatistics(boolean)instead