OneAllenBrainOntology provides a set of convenience methods related to searching
and indexing mouse brain region from the 1.json
of the Allen Institute for Brain Science (AIBS).
It contains only static methods, thus no object needs to be
instantiated and methods can be called directly.
In addition, this library contains the listing of all the brain region computed volumes
from the volumetric files annotation_10.nrrd
and annotation_25.nrrd
for both ccfv2 (2014)
and ccfv3 (2017). The method getRegionVolume(...)
makes it easy to get the
volume of any given brain region (in cubic micrometer) and let you specify the version and
resolution of the atlas.
Example:
import oneallenbrainontology from 'oneallenbrainontology'
let allRegionNames = oneallenbrainontology.getAllRegionNames()
When querying a specific brain region, the returned value if found will be of the form:
{
"id": 567,
"atlas_id": 70,
"ontology_id": 1,
"acronym": "CH",
"name": "Cerebrum",
"color_hex_triplet": "B0F0FF",
"graph_order": 2,
"st_level": 2,
"hemisphere_id": 3,
"parent_structure_id": 8,
"children_structure_id": [
688,
623
],
"isLeaf": false,
"slug": "cerebrum"
}
Where
id
: number the identifier of the brain region (given by AIBS)acronym
: string is the short unique name for a region (given by AIBS)name
: string full name of the brain region (given by AIBS)color_hex_triplet
: string the color of the brain region in hexadecimal (given by AIBS)parent_structure_id
: number theid
of the parent brain structure (given by AIBS)children_structure_id
: [number] list of regionid
s this region is the parent of (AIBS gives a list of nodes instead of a list ofid
, but here the whole tree has been flattened)isLeaf
: boolean says if the brain region is a leaf of the tree (true
, it does not have child region) or if it has child brain region (false
). Not that this could easily be deduced from length of thechildren_structure_id
list.slug
: string a URL compatible nameatlas_id
: number some field given by AIBS (no more info about it)ontology_id
: number some field given by AIBS (no more info about it)graph_order
: number some field given by AIBS (no more info about it)st_level
: number some field given by the AIBS (no more info about it)hemisphere_id
: number some field given by the AIBS (no more info about it)
Get the raw data (1.json) that contains nested nodes
let rawData = oneallenbrainontology.getRawData()
Returns object the raw data
Get the root node, which is the most top level node and has no parent.
let rootNode = oneallenbrainontology.getRootNode()
Returns Object the node
Get the full list of region names (lowercase) as an array
let allRegionNames = oneallenbrainontology.getAllRegionNames()
Returns Array
Get the full list of region acronyms (lowercase) as an array
let allRegionAcronyms = oneallenbrainontology.getAllRegionAcronyms()
Returns Array
Get the full list of region ID (integers) as an array
let allBrainRegionId = oneallenbrainontology.getAllRegionId()
Returns Array
Get a region by its strict full name (case insensitive)
name
string full name of the brain region
let visa23 = oneallenbrainontology.getRegionByFullName('anterior area, layer 2/3')
Returns Object the brain region metadata
Get a region by its strict acronym (case insensitive)
ac
string acronym of the brain region
let visa23 = oneallenbrainontology.getRegionByAcronym('visa2/3')
Returns Object the brain region metadata
Get a region by its strict slug (case insensitive)
slug
string slug of the brain region
let orbL23 = oneallenbrainontology.getRegionBySlug('orbital_area_layer_2_3')
Returns Object the brain region metadata
Get a region by its id
id
number id of the brain region
let visa23 = oneallenbrainontology.getRegionById(312782554)
Returns Object the brain region metadata
Get the list of child regions given the ID of the parent region.
let children = oneallenbrainontology.getChildRegionsFromId(997)
Returns Array array of regions, alphabetically sorted by name. If the parentId does not exist or if it has no children, then an empty array is returned.
Get the parent region given the id of a child.
let parent = oneallenbrainontology.getParentRegionFromId(304325711)
Returns (Object | null) the parent region or null if no parent (aka. root node)
Get the list of IDs of all the brain regions that are at a higher level than the one given.
id
(number | string) id of the brain region to find the ancestors ofoptions
object the options object (optional, default{}
)
let ancestors = oneallenbrainontology.getAscendantsFromId(159, {
rootFirst: true,
omitChild: false
})
Returns array of region IDs in ascending order (default) or descending order
Get all the descendants from a given brain region. The descendants are the children and all the children of the children recursively until the leaf nodes are reached.
id
(number | string) id of the region to list the descendants ofoptions
opbject the option object (optional, default{}
)
let allChildren = oneallenbrainontology.getDescendantsFromId(997, { // 997 is the top region, the one that contains all the others
keepCurrent: true, // this one will actually not apply as 997 is not a leaf
leafOnly: true // and here we want only the leaf
})
Returns array the descendants
Gives the volume in um^3 (cubic micro-meter) of the given brain region, using some builtin atlas data. Pro-tip: divide by 1E9 to get the volume in mm^3 and again by 1E3 for cm^3.
id
(number | string) the id of the brain region to get the volume ofoptions
object the option object (optional, default{}
)
let volume = oneallenbrainontology.getRegionVolume(997, {
atlas: 'ccfv3',
resolution: '10um'
})
console.log(`The whole mouse brain has a volume of ${volume/1E12} cm^3`)
Returns number the volume of the brain region in cubic micro-meter
Search a region using multiple words. There is possibly multiple matches when all the words of the query are found in the [full name + acronym + id] of a brain region
query
string possibly multiple words
let cerebellumRelated = oneallenbrainontology.findRegion('cerebel')
let layer23Related = oneallenbrainontology.findRegion('layer 2/3')
Returns array brain regions or empty if not found
Rebuild the tree with nested objects (non-flat) from the list of nodes. Internally, the path to the root is found for each node and children list of ids are replaced with child nodes. The tree is built bottom-up, meaning all the node that match the query willl be added to the tree as well as their parent, up to the root node.
nodes
array list of nodes to build the partial tree on
let partialTree = oneallenbrainontology.buildNestedTree(oneallenbrainontology.getRegionById(140)))
Returns Object the tree starting with the root node
Build a tree in a nested way, based on the query. The tree is built bottom-up, meaning all the node that match the query willl be added to the tree as well as their parent, up to the root node.
q
string query, a substring of the region name, not case sensitive. (optional, default''
)
let partialTree = oneallenbrainontology.buildNestedTreeFromQuery('layer')
Returns Object the tree starting with the root node