Package sc.fiji.snt.io
Class MouseLightLoader
java.lang.Object
sc.fiji.snt.io.MouseLightLoader
Methods for retrieving reconstructions from MouseLight's online database at
ml-neuronbrowser.janelia.org *
- Author:
- Tiago Ferreira
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a collection of four demo reconstructions NB: Data is cached locally.extractNodes(File jsonFile, String compartment) Extracts reconstruction(s) from a JSON file.extractNodes(InputStream stream, String compartment) extractTrees(File jsonFile, String compartment) Extracts reconstruction(s) from a JSON file.extractTrees(InputStream stream, String compartment) static List<MouseLightLoader> Gets the loaders for all the cells publicly available in the MouseLight database.getDOI()Gets the DOI for this neuron.getID()Gets the neuron ID for this loader.org.json.JSONObjectgetJSON()Gets all the data associated with this reconstruction as a JSON object.static intGets the number of cells publicly available in the MouseLight database.getNodes()Extracts the nodes (single-point soma, axonal and dendritic arbor) of the loaded neuron.Script-friendly method to extract the nodes of a cellular compartment.Gets sample information for this neuron.Gets the brain compartment containing the soma.Gets the soma location for this neuron.getSWC()Gets all the data associated with this reconstruction in the SWC format.getTree()Script-friendly method to extract the entire neuron as a collection of Paths.Script-friendly method to extract a compartment as a collection of Paths.Extracts a cell compartment as a collection of Paths.booleanidExists()Checks if the neuron ID exists in the database.static booleanChecks whether a connection to the MouseLight database can be established.static voidbooleanConvenience method to save JSON data.booleanConvenience method to save JSON data.booleansaveAsJSON(String outputDirectory) Convenience method to save JSON data to a local directory.booleanConvenience method to save SWC data to a local directory.
-
Field Details
-
AXON
The Constant AXON.- See Also:
-
DENDRITE
The Constant DENDRITE.- See Also:
-
SOMA
The Constant SOMA.- See Also:
-
-
Constructor Details
-
MouseLightLoader
Instantiates a new loader.- Parameters:
id- the neuron id (e.g., "AA0001"). Note that DOIs are not allowed
-
-
Method Details
-
getID
Gets the neuron ID for this loader.- Returns:
- the neuron ID
-
getDOI
Gets the DOI for this neuron.- Returns:
- the DOI string, or null if not available
-
getSampleInfo
Gets sample information for this neuron.- Returns:
- the sample information as a JSON string, or null if not available
-
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
Script-friendly method to extract the nodes of a cellular compartment.- Parameters:
compartment- 'soma', 'axon', 'dendrite', 'all' (case insensitive). All nodes are retrieved ifcompartmentis not recognized- Returns:
- the set of nodes of the neuron as
SWCPoints.
-
getSomaLocation
Gets the soma location for this neuron.- Returns:
- the SWCPoint representing the soma location
-
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 parsedcompartment- 'soma', 'axon', 'dendrite', 'all' (case insensitive). All nodes are retrieved ifcompartmentis not recognized- Returns:
- the map containing the reconstruction nodes as
Trees - Throws:
IOException- if file could not be loadedorg.json.JSONException- if file is malformed- See Also:
-
extractTrees
-
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 parsedcompartment- 'soma', 'axon', 'dendrite', 'all' (case insensitive). All nodes are retrieved ifcompartmentis not recognized- Returns:
- the map containing the reconstruction nodes as
SWCPoints - Throws:
org.json.JSONException- if file is malformedIOException- 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
Convenience method to save JSON data.- Parameters:
path- the absolute path to output directory/file- Returns:
- true, if successful
- See Also:
-
save
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
Gets all the data associated with this reconstruction in the SWC format.- Returns:
- the SWC data (null if data could not be retrieved).
-
saveAsSWC
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
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
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
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
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
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
- Throws:
IOException
-