Class MouseLightLoader

java.lang.Object
sc.fiji.snt.io.MouseLightLoader

public class MouseLightLoader extends Object
Methods for retrieving reconstructions from MouseLight's online database at ml-neuronbrowser.janelia.org *
Author:
Tiago Ferreira
  • Field Details

  • Constructor Details

    • MouseLightLoader

      public MouseLightLoader(String id)
      Instantiates a new loader.
      Parameters:
      id - the neuron id (e.g., "AA0001"). Note that DOIs are not allowed
  • Method Details

    • getID

      public String getID()
      Gets the neuron ID for this loader.
      Returns:
      the neuron ID
    • getDOI

      public String getDOI()
      Gets the DOI for this neuron.
      Returns:
      the DOI string, or null if not available
    • getSampleInfo

      public String getSampleInfo()
      Gets sample information for this neuron.
      Returns:
      the sample information as a JSON string, or null if not available
    • getNodes

      public TreeSet<SWCPoint> getNodes()
      Extracts the nodes (single-point soma, axonal and dendritic arbor) of the loaded neuron.
      Returns:
      the set of nodes of the neuron as SWCPoints.
    • getNodes

      public TreeSet<SWCPoint> getNodes(String compartment)
      Script-friendly method to extract the nodes of a cellular compartment.
      Parameters:
      compartment - 'soma', 'axon', 'dendrite', 'all' (case insensitive). All nodes are retrieved if compartment is not recognized
      Returns:
      the set of nodes of the neuron as SWCPoints.
    • getSomaLocation

      public SWCPoint getSomaLocation()
      Gets the soma location for this neuron.
      Returns:
      the SWCPoint representing the soma location
    • getSomaCompartment

      public AllenCompartment getSomaCompartment()
      Gets the brain compartment containing the soma.
      Returns:
      the AllenCompartment containing the soma
    • extractTrees

      public static Map<String,Tree> extractTrees(File jsonFile, String compartment) throws org.json.JSONException, IOException
      Extracts reconstruction(s) from a JSON file.
      Parameters:
      jsonFile - the JSON file to be parsed
      compartment - 'soma', 'axon', 'dendrite', 'all' (case insensitive). All nodes are retrieved if compartment is not recognized
      Returns:
      the map containing the reconstruction nodes as Trees
      Throws:
      IOException - if file could not be loaded
      org.json.JSONException - if file is malformed
      See Also:
      • extractNodesFromJSONObject(String, JSONObject)
    • extractTrees

      public static Map<String,Tree> extractTrees(InputStream stream, String compartment)
    • extractNodes

      public static Map<String,TreeSet<SWCPoint>> extractNodes(File jsonFile, String compartment) throws org.json.JSONException, IOException
      Extracts reconstruction(s) from a JSON file.
      Parameters:
      jsonFile - the JSON file to be parsed
      compartment - 'soma', 'axon', 'dendrite', 'all' (case insensitive). All nodes are retrieved if compartment is not recognized
      Returns:
      the map containing the reconstruction nodes as SWCPoints
      Throws:
      org.json.JSONException - if file is malformed
      IOException - if file could not be loaded
      See Also:
    • extractNodes

      public static Map<String,TreeSet<SWCPoint>> extractNodes(InputStream stream, String compartment) throws org.json.JSONException
      Throws:
      org.json.JSONException
    • getJSON

      public org.json.JSONObject getJSON()
      Gets all the data associated with this reconstruction as a JSON object.
      Returns:
      the JSON data (null if data could not be retrieved).
    • save

      public boolean save(String path)
      Convenience method to save JSON data.
      Parameters:
      path - the absolute path to output directory/file
      Returns:
      true, if successful
      See Also:
    • save

      public boolean save(File file)
      Convenience method to save JSON data.
      Parameters:
      file - the output directory or the output file
      Returns:
      true, if successful
      See Also:
    • idExists

      public boolean idExists()
      Checks if the neuron ID exists in the database.
      Returns:
      true if the ID exists, false otherwise
    • getSWC

      public String getSWC()
      Gets all the data associated with this reconstruction in the SWC format.
      Returns:
      the SWC data (null if data could not be retrieved).
    • saveAsSWC

      public boolean saveAsSWC(String outputDirectory) throws IOException
      Convenience method to save SWC data to a local directory.
      Parameters:
      outputDirectory - the output directory
      Returns:
      true, if successful
      Throws:
      IOException - if an I/O exception occurred during saving
    • saveAsJSON

      public boolean saveAsJSON(String outputDirectory) throws IOException
      Convenience method to save JSON data to a local directory.
      Parameters:
      outputDirectory - the output directory
      Returns:
      true, if successful
      Throws:
      IOException - if an I/O exception occurred during saving
    • getTree

      public Tree getTree(String compartment, org.scijava.util.ColorRGB color) throws IllegalArgumentException
      Extracts a cell compartment as a collection of Paths.
      Parameters:
      compartment - 'soma', 'axon', 'dendrite', 'all' (case insensitive)
      color - the color to be applied to the Tree. Null not expected.
      Returns:
      the compartment as a Tree, or null if data could not be retrieved
      Throws:
      IllegalArgumentException - if compartment is not recognized or retrieval of data for this neuron is not possible
    • getTree

      public Tree getTree(String compartment) throws IllegalArgumentException
      Script-friendly method to extract a compartment as a collection of Paths.
      Parameters:
      compartment - 'soma', 'axon', 'dendrite', 'all' (case insensitive)
      Returns:
      the compartment as a Tree, or null if data could not be retrieved
      Throws:
      IllegalArgumentException - if compartment is not recognized or retrieval of data for this neuron is not possible
    • getTree

      public Tree getTree() throws IllegalArgumentException
      Script-friendly method to extract the entire neuron as a collection of Paths.
      Returns:
      the neuron as a Tree, or null if data could not be retrieved
      Throws:
      IllegalArgumentException - if retrieval of data for this neuron is not possible
    • isDatabaseAvailable

      public static boolean isDatabaseAvailable()
      Checks whether a connection to the MouseLight database can be established.
      Returns:
      true, if an HHTP connection could be established
    • getNeuronCount

      public static int getNeuronCount()
      Gets the number of cells publicly available in the MouseLight database.
      Returns:
      the number of available cells, or -1 if the database could not be reached.
    • getAllLoaders

      public static List<MouseLightLoader> getAllLoaders() throws IllegalArgumentException
      Gets the loaders for all the cells publicly available in the MouseLight database.
      Returns:
      the list of loaders
      Throws:
      IllegalArgumentException - if the ML database could not be reached.
    • demoTrees

      public static List<Tree> demoTrees()
      Returns a collection of four demo reconstructions 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"
    • main

      public static void main(String... args) throws IOException
      Throws:
      IOException