High Level API

NeuroArch Class

The NeuroArch class provides basic operations such as connecting to the OrientDB database, loading database, and queries.

class neuroarch.na.NeuroArch(db_name, host='localhost', port=2424, user='root', password='root', mode='r', storage='plocal', new_models=False, debug=False, serialization_type='Binary', version=None, maintainer_name='', maintainer_email='')[source]

Create or connect to a NeuroArch object for database access.

Parameters:
  • db_name (str) – name of the database to connect to or create

  • host (str (optional)) – IP of the host

  • port (int (optional)) – binary port of the OrientDB server

  • user (str (optional)) – user name to access the database

  • password (str (optional)) – password to access the database

  • mode (str (optional)) – ‘r’: read only ‘w’: read/write on existing database, if does not exist, one is created. ‘o’: read/write and overwrite any of the existing data in the database.

  • storage (str (optional)) – ‘plocal’: using disk-based storage for the database ‘memory’: memory storage

  • new_models (bool (optional)) – If true, recreate the ogm classes.

  • debug (bool (optional)) – Whether the queries are done in debug mode

  • serialization_type (str) – Either ‘Binary’ or ‘CSV’, specifying the seriailzation strategy of pyorient communication with OrientDB server.

  • version (str) – If a new database will be created, e.g., mode = ‘o’ or mode = ‘w’ and database does not exist, then version should be provided.

  • maintainer_name (str) – If a new database will be created, e.g., mode = ‘o’ or mode = ‘w’ and database does not exist, then maintainer of the author name should be provided.

  • maintainer_email (str) – Email of the maintainer, should be provided when maintainer_name is needed.

Methods for Connection

NeuroArch.connect([new_models])

Connect to the database specified during instantiation

NeuroArch.reconnect()

Reconnect to the database specified during instantiation

Methods for Queries

NeuroArch.sql_query(query_text[, edges])

Query NeuroArch database with a SQL query

Methods for Loading Biological Entities

NeuroArch.query_neuron([uname, referenceId])

Query neurons by unique name or referenceId

NeuroArch.query_celltype(celltype)

Query neurons by cell type.

NeuroArch.query_synapses(pre_name, post_name)

Query synapses by presynaptic and postsynaptic neuron unames

NeuroArch.query_neuropil(neuropil)

Query neuropil by name.

NeuroArch.query_subregion(subregion)

Query subregion by name.

NeuroArch.add_Species(name, stage, sex[, ...])

Add a Species.

NeuroArch.add_DataSource(name, version[, ...])

Add a DataSource.

NeuroArch.add_Subsystem(name[, synonyms, ...])

Create a Subsystem record and link it to related node types.

NeuroArch.add_Neuropil(name[, synonyms, ...])

Create a Neuropil record and link it to related node types.

NeuroArch.add_Subregion(name[, synonyms, ...])

Create a Subregion record and link it to related node types.

NeuroArch.add_Tract(name[, synonyms, ...])

Create a Subregion record and link it to related node types.

NeuroArch.add_Circuit(name, circuit_type[, ...])

Create a Subregion record and link it to related node types.

NeuroArch.add_Neuron(uname, name[, ...])

Create a Neuron Record and link it to the related node types.

NeuroArch.add_neurotransmitter(neuron, ...)

Add neurotransmitter data and link it to a neuron.

NeuroArch.add_morphology(obj, morphology[, ...])

Add a morphology to a node, e.g., a neuropil, or a neuron.

NeuroArch.add_neuron_arborization(neuron, ...)

Add arborization data of a neuron and link it to the neuron.

NeuroArch.add_Synapse(pre_neuron, post_neuron)

Add a Synapse from pre_neuron and post_neuron.

NeuroArch.add_synapse_arborization(synapse, ...)

Add data for the distribution of synapses within a Synapse node in Neuropils, Subregions and Tracts.

NeuroArch.add_InferredSynapse(pre_neuron, ...)

Add an InferredSynapse from pre_neuron and post_neuron.

NeuroArch.remove_Neurons(neurons[, ...])

Remove neurons

NeuroArch.remove_Synapses(synapses[, ...])

Remove synapses.

NeuroArch.remove_Synapses_between(...[, ...])

Remove synapses between a list of presynaptic neurons and a list of postsynaptic neurons.

NeuroArch.update_Neuron(neuron[, uname, ...])

Update any property/data of a neuron.

NeuroArch.update_Synapse(synapse[, N, NHP, ...])

Update any property/data of a synapse.

NeuroArch.create_model_from_circuit(...[, ...])

Create a model of a circuit.

NeuroArch.add_ExecutableCircuit(name[, ...])

Add an executable circuit.

NeuroArch.add_CircuitDiagram(name, diagrams)

Add circuit diagram.

NeuroArch.add_LPU(neuropil, circuit_model[, ...])

Add an LPU.

NeuroArch.add_NeuronModel(neuron, model_cls, ...)

Create a NeuronModel node.

NeuroArch.add_Port(neuron, lpu[, selector])

Create a Port node.

NeuroArch.add_SynapseModel(synapse, ...)

Create a NeuronModel node.

Auxilliary Methods

NeuroArch.get(cls, name, data_source, **attr)

Retrieve an object with name under data_source, either from cache or from database.

NeuroArch.set(cls, name, value, data_source)

Set an entry in the local database cache.

NeuroArch.exists(cls, **attr)

Check if data exists in the database.

NeuroArch.find(cls, **attr)

Find all instances in the database that meets the criteria.

NeuroArch.find_objs(cls, **attr)

Find all instances in the database that meets the criteria.

NeuroArch.link(node1, node2[, edge_type])

To create an edge between node1 and node2 with specified edge type.

NeuroArch.link_with_batch(batch, node1, ...)

To create an edge between node1 and node2 with specified edge type, when node1 and node2 are to be created in batch.

NeuroArch.export_tags(filename)

Export all the tags to a JSON file.

NeuroArch.import_tags(filename)

Import tags from a JSON file.

NeuroArch.remove_tag(tag_name)

Remove a tag.

NeuroArch.available_DataSources()

Retrieve all available DataSources.

High Level Query Functions

neuroarch.na.outgoing_synapses(q, N=None, rel='>', include_inferred=True)[source]

Get all the outgoing synapses from neurons in a QueryWrapper object.

Parameters:
  • q (query.QueryWrapper) – The query to search for outgoing synapses

  • N (int or None) – Filter for number of synapses (default: None, equivalent to 0)

  • rel (str) – Ralation operator to the number of synapses when applying the filter. (default: ‘>’)

  • include_inferred (bool) – Whether to include InferredSynapses (default: True)

Returns:

containing the outgoing synapses.

Return type:

query.QueryWrapper

Example

db = NeuroArch(‘hemibrain’) neurons = db.sql_query(“select from Neuron where name like ‘EPG’ “) q = outgoing_synapses(neurons) q.node_objs

neuroarch.na.incoming_synapses(q, N=None, rel='>', include_inferred=True)[source]

Get all the input synapses to neurons in a QueryWrapper object.

Parameters:
  • q (query.QueryWrapper) – The query to search for outgoing synapses

  • N (int or None) – Filter for number of synapses (default: None, equivalent to 0)

  • rel (str) – Ralation operator to the number of synapses when applying the filter. (default: ‘>’)

  • include_inferred (bool) – Whether to include InferredSynapses (default: True)

Returns:

containing the input synapses.

Return type:

query.QueryWrapper

Example

db = NeuroArch(‘hemibrain’) neurons = db.sql_query(“select from Neuron where name like ‘EPG’ “) q = incoming_synapses(neurons) q.node_objs

neuroarch.na.get_data(q, data_types=None)[source]

Get all the data associated with a QueryWrapper object.

Parameters:
  • q (query.QueryWrapper) – The query to search for outgoing synapses

  • data_types (list or None) – The types of data to be retrieved (default: None, equivalent to all data types)

Returns:

containing the data.

Return type:

query.QueryWrapper

Example

db = NeuroArch(‘hemibrain’) neurons = db.sql_query(“select from Neuron where name like ‘EPG’ “) q = get_data(neurons, ‘MorphologyData’) q.node_objs

Auxilliary Functions

neuroarch.na.load_swc(file_name)[source]

Load an SWC file into a DataFrame.

Parameters:

filename (str) – The name of the SWC file.

Returns:

a dataframe having the fields sample, identifier, x, y, z, r and parent.

Return type:

pandas.DataFrame

Exceptions and Warnings

NotWriteableError

NeuroArch not writeable error

DuplicateNodeError

NeuroArch got duplicate nodes

NodeAlreadyExistError

NeuroArch node with the same property already exsits

RecordNotFoundError

Cannot find the data in NeuroArch database

NodeAlreadyExistWarning

NeuroArch node with the same property already exsits

DuplicateNodeWarning

NeuroArch got duplicate nodes

DataSourceError

The node is not owned by a DataSource