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(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.SelectQuerywith entries matching the request.- table (str) – Name of the table where the search should be performed (among
-
nngt.database.is_clear()# Check that the logs are clear.
-
nngt.database.log_simulation_end(network=None, log_activity=True)# Record the simulation completion and simulated times, save the data, then reset.
-
nngt.database.log_simulation_start(network, simulator, save_network=True)# Record the simulation start time, all nodes, connections, network, and computer properties, as well as some of simulation’s.
Parameters: - network (
Networkor subclass) – Network used for the current simulation. - simulator (str) – Name of the simulator.
- save_network (bool, optional (default: True)) – Whether to save the network or not.
- network (
-
nngt.database.reset()# 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:
- ‘activity’:
Activity, - ‘computer’:
Computer, - ‘connection’:
Connection, - ‘neuralnetwork’:
NeuralNetwork, - ‘neuron’:
Neuron, - ‘simulation’:
Simulation, - ‘synapse’:
Synapse.
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= <IntegerField: Activity.id>#
-
raster= <PickledField: Activity.raster># 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= <IntegerField: Computer.cores># Number of cores returned by
psutil.cpu_count()or-1
-
id= <IntegerField: Computer.id>#
-
name= <TextField: Computer.name># Name from
platform.node()or"unknown"
-
platform= <TextField: Computer.platform># System information from
platform.platform()
-
python= <TextField: Computer.python># Python version given by
platform.python_version()
-
ram= <IntegerField: Computer.ram># 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= <IntegerField: Connection.id>#
-
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>#
-
-
class
nngt.database.db_generation.NeuralNetwork(*args, **kwargs)[source]# Class containing informations about the neural network.
-
DoesNotExist# alias of
NeuralNetworkDoesNotExist
-
compressed_file= <LongCompressedField: NeuralNetwork.compressed_file># Compressed (bz2) string of the graph from
str(graph); once uncompressed, can be loaded usingGraph.from_file(name, from_string=True).
-
directed= <IntegerField: NeuralNetwork.directed># Whether the graph is directed or not
-
edges= <IntegerField: NeuralNetwork.edges># Number of edges.
-
id= <IntegerField: NeuralNetwork.id>#
-
network_type= <TextField: NeuralNetwork.network_type># Type of the network from Graph.type
-
nodes= <IntegerField: NeuralNetwork.nodes># Number of nodes.
-
simulations#
-
weight_distribution= <TextField: NeuralNetwork.weight_distribution># Name of the weight_distribution used.
-
weighted= <IntegerField: NeuralNetwork.weighted># 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= <IntegerField: Neuron.id>#
-
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= <DateTimeField: Simulation.completion_time># 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= <IntegerField: Simulation.grnd_seed># Master seed of the simulation.
-
id= <IntegerField: Simulation.id>#
-
local_seeds= <PickledField: Simulation.local_seeds># 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= <PickledField: Simulation.pop_sizes># Pickled list containing the group sizes.
-
population= <PickledField: Simulation.population># Pickled list containing the neural group names.
-
resolution= <FloatField: Simulation.resolution># Timestep used to simulate the components of the neural network
-
simulated_time= <FloatField: Simulation.simulated_time># Virtual time that was simulated for the neural network.
-
simulator= <TextField: Simulation.simulator># Name of the neural simulator used (NEST, Brian…)
-
start_time= <DateTimeField: Simulation.start_time># Date and time at which the simulation started.
-