Class AllenUtils

java.lang.Object
sc.fiji.snt.annotation.AllenUtils

public class AllenUtils extends Object
Utility methods for accessing/handling AllenCompartments
Author:
Tiago Ferreira, Cameron Arshadi
  • Field Details

  • Method Details

    • getBrainAreasList

      protected static org.json.JSONArray getBrainAreasList()
    • hostedMeshesLocation

      protected static String hostedMeshesLocation()
    • getBrainAreasByStructureId

      protected static org.json.JSONObject getBrainAreasByStructureId()
    • getBrainAreasByUUID

      protected static org.json.JSONObject getBrainAreasByUUID()
    • getCompartment

      public static AllenCompartment getCompartment(int id)
      Constructs a compartment from its CCF id
      Parameters:
      id - the integer identifier
      Returns:
      the compartment matching the id or null if id is not valid
    • getCompartment

      public static AllenCompartment getCompartment(String nameOrAcronym)
      Constructs a compartment from its CCF name or acronym
      Parameters:
      nameOrAcronym - the name or acronym (case-insensitive) identifying the compartment
      Returns:
      the compartment whose name or acronym matches the specified string or null if no match was found
    • assignToLeftHemisphere

      public static void assignToLeftHemisphere(Tree tree)
      Assigns a tree to the left hemisphere by mirroring it if necessary.
      Parameters:
      tree - the tree to assign to the left hemisphere
    • assignToRightHemisphere

      public static void assignToRightHemisphere(Tree tree)
      Assigns a tree to the right hemisphere by mirroring it if necessary.
      Parameters:
      tree - the tree to assign to the right hemisphere
    • isLeftHemisphere

      public static boolean isLeftHemisphere(Tree tree)
      Checks the hemisphere a neuron belongs to.
      Parameters:
      tree - the Tree to be tested
      Returns:
      true, if soma (or root node) is in the left hemisphere, false otherwise
    • getHemisphere

      public static String getHemisphere(Tree tree)
      Checks the hemisphere a neuron belongs to.
      Parameters:
      tree - the Tree to be tested
      Returns:
      the hemisphere label: either "left", or "right"
    • assignHemisphereTags

      public static void assignHemisphereTags(DirectedWeightedGraph graph)
      Assigns hemisphere tags to all nodes in a graph.
      Parameters:
      graph - the DirectedWeightedGraph to tag
    • getAxisDefiningSagittalPlane

      public static int getAxisDefiningSagittalPlane()
      Gets the axis defining the sagittal plane.
      Returns:
      the axis defining the sagittal plane where X=0; Y=1; Z=2;
    • assignHemisphereTags

      public static void assignHemisphereTags(Tree tree)
    • splitByHemisphere

      public static List<DirectedWeightedSubgraph> splitByHemisphere(DirectedWeightedGraph graph)
    • isLeftHemisphere

      public static boolean isLeftHemisphere(SNTPoint point)
      Checks the hemisphere a reconstruction node belongs to.
      Parameters:
      point - the point
      Returns:
      true, if is left hemisphere, false otherwise
    • isLeftHemisphere

      public static boolean isLeftHemisphere(double x, double y, double z)
    • brainCenter

      public static SNTPoint brainCenter()
      Returns the spatial centroid of the Allen CCF.
      Returns:
      the SNT point defining the (X,Y,Z) center of the ARA
    • getHighestOntologyDepth

      public static int getHighestOntologyDepth()
      Gets the maximum number of ontology levels in the Allen CCF.
      Returns:
      the max number of ontology levels.
    • getTreeModel

      public static DefaultTreeModel getTreeModel(boolean meshesOnly)
      Retrieves the Allen CCF hierarchical tree data.
      Parameters:
      meshesOnly - Whether only compartments with known meshes should be included
      Returns:
      the Allen CCF tree data model
    • getOntologies

      public static List<AllenCompartment> getOntologies()
      Gets the Allen CCF as a flat (non-hierarchical) collection of ontologies.
      Returns:
      the "flattened" ontologies list
    • getOntologies

      public static List<AllenCompartment> getOntologies(int depth, boolean meshes)
      Gets a flat (non-hierarchical) list of all the compartments of the specified ontology depth.
      Parameters:
      depth - the ontology depth
      meshes - If true, only compartments with known meshes are retrieved
      Returns:
      the "flattened" list of compartment
    • getRootMesh

      public static OBJMesh getRootMesh(org.scijava.util.ColorRGB color)
      Retrieves the surface contours for the Allen Mouse Brain Atlas (CCF), bundled with SNT.
      Parameters:
      color - the color to be assigned to the mesh
      Returns:
      a reference to the retrieved mesh
    • getXYZLabels

      public static String[] getXYZLabels()
      Returns:
      the anatomical descriptions associated with the Cartesian X,Y,Z axes
    • getCartesianPlane

      public static String getCartesianPlane(String anatomicalPlane)
      Retrieves the Cartesian plane matching the specified anatomical plane.
      Parameters:
      anatomicalPlane - either "sagittal", "coronal", or "transverse"
      Returns:
      the cartesian plane. Either "xy", "yz", "xz", or null if anatomicalPlane was not recognized.
    • getAnatomicalPlane

      public static String getAnatomicalPlane(String cartesianPlane)
      Retrieves the anatomical plane matching the specified cartesian plane.
      Parameters:
      cartesianPlane - either "xy", "yz", or "xz"
      Returns:
      the cartesian plane. Either "coronal", "sagittal", "transverse", or null if cartesianPlane was not recognized.
    • transferAnnotationIdsToNodeValues

      public static void transferAnnotationIdsToNodeValues(Tree tree)
      Transfers brain annotation IDs to node values for all paths in a Tree.

      This is useful for preserving annotation information when saving data to TRACES files. Note that this method overwrites any existing node values. Nodes without annotations (null) are assigned BRAIN_ROOT_ID.

      Parameters:
      tree - the Tree containing paths with brain annotations to be transferred. Must not be null and must contain valid annotations.
      Throws:
      IllegalArgumentException - if the tree contains no brain annotations
      See Also:
    • assignAnnotationsFromNodeValues

      public static void assignAnnotationsFromNodeValues(Tree tree)
      Assigns brain annotations (interpreted as CCF IDs) to node values for all paths in a Tree.

      This method is the inverse operation of transferAnnotationIdsToNodeValues(Tree).

      Parameters:
      tree - the Tree containing paths with node values to be converted to annotations. Must not be null. Paths without node values are skipped. Invalid node values result in null annotations.
      See Also:
    • main

      public static void main(String[] args)