Class TreeParser

java.lang.Object
sc.fiji.snt.analysis.sholl.parsers.TreeParser
All Implemented Interfaces:
Parser, ProfileProperties

public class TreeParser extends Object implements Parser
A Parser for extracting Sholl Profiles from a Tree.
Author:
Tiago Ferreira
  • Field Details

    • ROOT_NODES_ANY

      public static final int ROOT_NODES_ANY
      Flag for defining the profile center as the average position of root nodes of all primary Paths.
      See Also:
    • ROOT_NODES_APICAL_DENDRITE

      public static final int ROOT_NODES_APICAL_DENDRITE
      Flag for defining the profile center as the average position of root nodes of Paths tagged as Apical Dendrite.
      See Also:
    • ROOT_NODES_AXON

      public static final int ROOT_NODES_AXON
      Flag for defining the profile center as the average position of root nodes of Paths tagged as Axon.
      See Also:
    • ROOT_NODES_CUSTOM

      public static final int ROOT_NODES_CUSTOM
      Flag for defining the profile center as the average position of root nodes of Paths tagged as Custom.
      See Also:
    • ROOT_NODES_DENDRITE

      public static final int ROOT_NODES_DENDRITE
      Flag for defining the profile center as the average position of root nodes of Paths tagged as (Basal) Dendrite
      See Also:
    • ROOT_NODES_SOMA

      public static final int ROOT_NODES_SOMA
      Flag for defining the profile center as the average position of root nodes of primary Paths tagged as Soma
      See Also:
    • ROOT_NODES_SOMA_ANY

      public static final int ROOT_NODES_SOMA_ANY
      Flag for defining the profile center as the average position of root nodes of _ANY_ Paths tagged as Soma, independently of connectivity
      See Also:
    • ROOT_NODES_UNDEFINED

      public static final int ROOT_NODES_UNDEFINED
      Flag for defining the profile center as the average position of root nodes of Paths tagged as Undefined
      See Also:
  • Constructor Details

    • TreeParser

      public TreeParser(Tree tree)
      Instantiates a new Tree Parser.
      Parameters:
      tree - the Tree to be profiled
  • Method Details

    • setCenter

      public void setCenter(int choice) throws IllegalArgumentException
      Computes the center of the Profile.
      Parameters:
      choice - the flag specifying the center (e.g., ROOT_NODES_SOMA, ROOT_NODES_ANY, etc.)
      Throws:
      IllegalArgumentException - if choice is not a recognized flag or if no Paths in the Tree match the choice criteria
    • getCenter

      public PointInImage getCenter()
      Returns the center coordinates
      Returns:
      the point defining the center, or null if it has not yet been set.
    • setCenter

      public void setCenter(PointInImage center)
      Sets the center of the profile.
      Parameters:
      center - the focal point of the profile
    • setCenter

      public void setCenter(double[] coordinates)
      Sets the center of the profile.
      Parameters:
      coordinates - the array holding the focal point coordinates of the profile
    • setIntersectedVolumeAsExtraMeasurement

      public void setIntersectedVolumeAsExtraMeasurement(boolean b)
      Enables storing the intersected arbor volume as a per-shell extra measurement in the resulting Profile.

      When enabled, each ProfileEntry will include the volume of cable lying inside the current sampling shell, expressed in calibrated units cubed (e.g., µm³). The value is computed by clipping each traced segment to the shell and summing the volumes of the resulting truncated-cone (frustum) pieces. If only one endpoint radius is available, that radius is used for both ends; if neither endpoint has a radius, the piece contributes no volume.

      Shells are defined by the parser’s sampling mode: for discontinuous sampling (step size > 0), shells have thickness equal to stepSize; for continuous sampling (step size = 0), a thin shell is used whose thickness falls back to the median internode distance of the Tree.

      Important: This method must be called before parse().

      Parameters:
      b - whether to store the intersected volume as an extra measurement
    • setStepSize

      public void setStepSize(double stepSize)
      Sets the radius step size.
      Parameters:
      stepSize - the radius step size
    • parse

      public void parse() throws IllegalArgumentException
      Description copied from interface: Parser
      Performs the parsing operation to extract the Sholl profile.

      This method analyzes the data source and computes intersection counts at various radial distances from the center point. The resulting profile can be retrieved using Parser.getProfile().

      Implementations should handle any necessary preprocessing, validation, and error handling during the parsing process.

      Specified by:
      parse in interface Parser
      Throws:
      IllegalArgumentException
    • successful

      public boolean successful()
      Description copied from interface: Parser
      Checks if the parsing operation was successful.

      This method should be called after Parser.parse() to determine if the parsing completed without errors and produced a valid profile.

      Specified by:
      successful in interface Parser
      Returns:
      true if parsing was successful, false otherwise
    • terminate

      public void terminate()
      Description copied from interface: Parser
      Terminates the parsing operation.

      This method should be called to clean up resources and stop any ongoing parsing operations. It may be used to interrupt long-running analyses or to ensure proper cleanup when the parser is no longer needed.

      Specified by:
      terminate in interface Parser
    • getProfile

      public Profile getProfile()
      Description copied from interface: Parser
      Gets the Sholl profile generated by the parsing operation.

      This method returns the profile containing intersection counts at various radial distances. The profile should only be retrieved after calling Parser.parse() and verifying success with Parser.successful().

      Specified by:
      getProfile in interface Parser
      Returns:
      the Sholl profile, or null if parsing has not been performed or was unsuccessful
    • getLabelsImage

      public ij.ImagePlus getLabelsImage(ij.ImagePlus templateImg, net.imglib2.display.ColorTable cTable)
      Gets the labels image.
      Parameters:
      templateImg - the template img
      cTable - the c table
      Returns:
      the labels image
    • main

      public static void main(String... args)
    • getTree

      public Tree getTree()
      Returns the tree associated with this parser
      Returns:
      the profiled tree
    • isSkipSomaticSegments

      public boolean isSkipSomaticSegments()
      See Also:
    • setSkipSomaticSegments

      public void setSkipSomaticSegments(boolean skipSomaticSegments)
      If primary paths start far-away from the soma (expected to be defined by a single-point (soma centroid)), should segments between the soma and neurite be ignored. Useful when soma is large relatively to the length of arbor, as in microglia cells. See e.g., this forum thread.
      Parameters:
      skipSomaticSegments - the skipFirsNode to set