Package sc.fiji.snt

Class 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 Details

    • SNTService

      public SNTService()
  • Method Details

    • requireVersion

      public void requireVersion(String minVersion) throws IllegalStateException
      Ensures the running SNT version meets a minimum requirement. This is analogous to IJ's requires() macro function.
      Parameters:
      minVersion - the minimum required version string, e.g., "5.0.4"
      Throws:
      IllegalStateException - if the running version is older than minVersion
    • isActive

      public boolean isActive()
      Gets whether SNT is running.
      Returns:
      true if this SNTService is 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 running
      IllegalArgumentException - If valid imaged data is not available
      See Also:
    • initialize

      public SNT initialize(boolean startUI)
      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 corresponding demoImage(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:
      InterruptedException
      InvocationTargetException
    • 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:
      InterruptedException
      InvocationTargetException
    • getPlugin

      @Deprecated public SNT getPlugin()
      Deprecated.
      use getInstance() instead
    • getInstance

      public SNT getInstance()
      Returns a reference to the active SNT instance.
      Returns:
      the SNT instance
    • 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 running
      IOException - if data cannot be imported
      URISyntaxException
    • loadTree

      public void loadTree(Tree tree) throws UnsupportedOperationException
      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} using Tree.assignImage(ImagePlus), before loading it.
      Parameters:
      tree - the Tree to be loaded (null not allowed).
      Throws:
      UnsupportedOperationException - if SNT is not running
    • loadGraph

      public void loadGraph(DirectedWeightedGraph graph) throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException
    • save

      public boolean save(String filePath)
      Saves all the existing paths to a file.
      Parameters:
      filePath - the saving output file path. If filePath ends 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

      public Collection<Path> 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

      public List<Path> 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

      public Tree getTree(boolean selectedPathsOnly)
      Gets the collection of paths listed in the Path Manager as a Tree object.
      Parameters:
      selectedPathsOnly - If true, only selected paths are retrieved
      Returns:
      the Tree holding the Path collection
      Throws:
      UnsupportedOperationException - if SNT is not running
    • getTree

      public Tree getTree()
      Gets the collection of paths listed in the Path Manager as a Tree object.
      Returns:
      the Tree holding the Path collection
      Throws:
      UnsupportedOperationException - if SNT is not running
    • getTrees

      public Collection<Tree> getTrees()
      Gets the collection of paths listed in the Path Manager as a Tree object.
      Returns:
      the Tree holding the Path collection
      Throws:
      UnsupportedOperationException - if SNT is not running
    • getAnalyzer

      @Deprecated public TreeStatistics getAnalyzer(boolean selectedPathsOnly)
      Deprecated.
    • getStatistics

      public TreeStatistics getStatistics(boolean selectedPathsOnly)
      Returns a TreeStatistics instance 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

      public PathAndFillManager getPathAndFillManager()
      Returns the PathAndFillManager associated 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

      public SNTUI getUI()
      Returns a reference to SNT's UI.
      Returns:
      the SNTUI window, or null if SNT is not running, or is running without GUI
    • getRecViewer

      public Viewer3D 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 Viewer3D instance. For stand-alone viewers, this is typically the viewer that is frontmost or the last initiated viewer.
    • getRecViewer

      public Viewer3D getRecViewer(int id)
      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 Viewer3D instance, or null if id was not recognized
    • newRecViewer

      public Viewer3D newRecViewer(boolean guiControls)
      Instantiates a new standalone Reconstruction Viewer.
      Returns:
      The standalone Viewer3D instance
    • getOrCreateSciViewSNT

      public SciViewSNT getOrCreateSciViewSNT() throws NoClassDefFoundError
      Throws:
      NoClassDefFoundError
    • getSciViewSNT

      Throws:
      UnsupportedOperationException
      NoClassDefFoundError
    • getTable

      public SNTTable 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 public Tree 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

      public Tree demoTree(String tree)
      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 public ij.ImagePlus 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

      public ij.ImagePlus demoImage(String img)
      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:
    • demoTrees

      public List<Tree> 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

      protected List<Tree> demoTreesSWC()
    • dispose

      public void dispose()
      Quits SNT. Does nothing if SNT is currently not running.
      Specified by:
      dispose in interface org.scijava.Disposable
    • getContext

      public org.scijava.Context getContext()
      Specified by:
      getContext in interface org.scijava.Contextual
      Overrides:
      getContext in class org.scijava.service.AbstractService