Database module#

NNGT provides a database to store NEST simulations. This database requires peewee>3 to work and can be switched on using:

nngt.set_config("use_database", True)

The commands are then used by calling nngt.database to access the database tools.

Functions#

nngt.database.get_results(self, table, column=None, value=None)#

Return the entries where the attribute column satisfies the required equality.

Parameters:
  • table (str) – Name of the table where the search should be performed (among 'simulation', 'computer', 'neuralnetwork', 'activity', 'synapse', 'neuron', or 'connection').
  • column (str, optional (default: None)) – Name of the variable of interest (a column on the table). If None, the whole table is returned.
  • value (column corresponding type, optional (default: None)) – Specific value for the variable of interest. If None, the whole column is returned.
Returns:

peewee.SelectQuery with entries matching the request.

nngt.database.is_clear(self)#

Check that the logs are clear.

nngt.database.log_simulation_end(self, network=None, log_activity=True)#

Record the simulation completion and simulated times, save the data, then reset.

nngt.database.log_simulation_start(self, network, simulator)#

Record the simulation start time, all nodes, connections, network, and computer properties, as well as some of simulation’s.

Parameters:
  • network (Network or subclass) – Network used for the current simulation.
  • simulator (str) – Name of the simulator.
nngt.database.reset(self)#

Reset log status.

Recording a simulation#

nngt.database.log_simulation_start(net, "nest-2.14")
nest.Simulate(1000.)
nngt.database.log_simulation_end()

Checking results in the database#

The database contains the following tables, associated to their respective fields:

These tables are the first keyword passed to get_results(), you can find the existing columns for each of the tables in the following classes descriptions:

Store results into a database

class nngt.database.db_generation.Activity(*args, **kwargs)[source]#

Class detailing the network’s simulated activity.

DoesNotExist#

alias of ActivityDoesNotExist

id = <peewee.IntegerField object>#
raster = <nngt.database.pickle_field.PickledField object>#

Raster of the simulated activity.

simulations#
class nngt.database.db_generation.Computer(*args, **kwargs)[source]#

Class containing informations about the conputer.

DoesNotExist#

alias of ComputerDoesNotExist

cores = <peewee.IntegerField object>#

Number of cores returned by psutil.cpu_count() or -1

id = <peewee.IntegerField object>#
name = <peewee.TextField object>#

Name from platform.node() or "unknown"

platform = <peewee.TextField object>#

System information from platform.platform()

python = <peewee.TextField object>#

Python version given by platform.python_version()

ram = <peewee.IntegerField object>#

Total memory given by psutil.virtual_memory().total (long) or -1

simulations#
class nngt.database.db_generation.Connection(*args, **kwargs)[source]#

Class detailing the existing connections in the network: a couple of pre- and post-synaptic neurons and a synapse.

DoesNotExist#

alias of ConnectionDoesNotExist

id = <peewee.IntegerField object>#
post = <ForeignKeyField: "connection"."post">#
post_id = <ForeignKeyField: "connection"."post">#
pre = <ForeignKeyField: "connection"."pre">#
pre_id = <ForeignKeyField: "connection"."pre">#
simulations#
synapse = <ForeignKeyField: "connection"."synapse">#
synapse_id = <ForeignKeyField: "connection"."synapse">#
nngt.database.db_generation.migrate(*operations, **kwargs)[source]#
class nngt.database.db_generation.NeuralNetwork(*args, **kwargs)[source]#

Class containing informations about the neural network.

DoesNotExist#

alias of NeuralNetworkDoesNotExist

compressed_file = <nngt.database.db_generation.LongCompressedField object>#

Compressed (bz2) string of the graph from str(graph); once uncompressed, can be loaded using Graph.from_file(name, from_string=True).

directed = <peewee.IntegerField object>#

Whether the graph is directed or not

edges = <peewee.IntegerField object>#

Number of edges.

id = <peewee.IntegerField object>#
network_type = <peewee.TextField object>#

Type of the network from Graph.type

nodes = <peewee.IntegerField object>#

Number of nodes.

simulations#
weight_distribution = <peewee.TextField object>#

Name of the weight_distribution used.

weighted = <peewee.IntegerField object>#

Whether the graph is weighted or not.

class nngt.database.db_generation.Neuron(*args, **kwargs)[source]#

Base class that will be modified to contain all the properties of the neurons used during a simulation.

DoesNotExist#

alias of NeuronDoesNotExist

id = <peewee.IntegerField object>#
int_connections#
out_connections#
class nngt.database.db_generation.Simulation(*args, **kwargs)[source]#

Class containing all informations about the simulation properties.

DoesNotExist#

alias of SimulationDoesNotExist

activity = <ForeignKeyField: "simulation"."activity">#

Activity table entry where the simulated activity is described.

activity_id = <ForeignKeyField: "simulation"."activity">#
completion_time = <peewee.DateTimeField object>#

Date and time at which the simulation ended.

computer = <ForeignKeyField: "simulation"."computer">#

Computer table entry where the computer used is defined.

computer_id = <ForeignKeyField: "simulation"."computer">#
connections = <ForeignKeyField: "simulation"."connections">#

Connection table entry where the connections are described.

connections_id = <ForeignKeyField: "simulation"."connections">#
grnd_seed = <peewee.IntegerField object>#

Master seed of the simulation.

id = <peewee.IntegerField object>#
local_seeds = <nngt.database.pickle_field.PickledField object>#

List of the local threads seeds.

network = <ForeignKeyField: "simulation"."network">#

Network table entry where the simulated network is described.

network_id = <ForeignKeyField: "simulation"."network">#
pop_sizes = <nngt.database.pickle_field.PickledField object>#

Pickled list containing the group sizes.

population = <nngt.database.pickle_field.PickledField object>#

Pickled list containing the neural group names.

resolution = <peewee.FloatField object>#

Timestep used to simulate the components of the neural network

simulated_time = <peewee.FloatField object>#

Virtual time that was simulated for the neural network.

simulator = <peewee.TextField object>#

Name of the neural simulator used (NEST, Brian…)

start_time = <peewee.DateTimeField object>#

Date and time at which the simulation started.

class nngt.database.db_generation.Synapse(*args, **kwargs)[source]#

Base class that will be modified to contain all the properties of the synapses used during a simulation.

DoesNotExist#

alias of SynapseDoesNotExist

connections#
id = <peewee.IntegerField object>#