api.CRI_network

api.CRI_network(self, axons, connections, config, outputs, target=None, simDump=False, coreID=0, perturbMag=None, leak=0)

This class represents a CRI network which initializes the network, checks hardware, generates connectome, formats input, reads and writes synapse, and runs simulation steps.

Attributes

Name Type Description
userAxons dict A copy of the axons dictionary provided by the user.
userConnections dict A copy of the connections dictionary provided by the user.
config dict The configuration parameters for the network.
perturb bool A boolean value indicating whether to perturb the network.
perturbMag int The magnitude of perturbation.
simpleSim str A string representing the simple simulation.
key2index dict A dictionary mapping keys to indices.
simDump bool A boolean value indicating whether to dump simulation results.
connectome str A string representing the connectome of the network.
axons dict The formatted axons dictionary.
connections dict The formatted connections dictionary.

Examples

>>> axons = {'axon1': [('neuron1', 1), ('neuron2', 2)]}
>>> connections = {'neuron1': [('axon1', 1)], 'neuron2': [('axon1', 2)]}
>>> config = {'neuron_type': 'type1', 'global_neuron_params': {'v_thr': 1.0}}
>>> outputs = ['output1', 'output2']
>>> network = CRI_network(axons, connections, config, outputs)

Methods

Name Description
checkHw Checks if the magic file exists to demark that we’re running on a system with CRI hardware accessible.
gen_connectome Generates a connectome for the CRI network.
read_synapse Reads a synapse from the connectome.
run_cont Runs a continuous simulation.
sim_flush Flushes the simulation results to a file.
step Runs a step of the simulation.
write_listofSynapses Writes a list of synapses to the connectome.
write_synapse Writes a synapse to the connectome.

checkHw

api.CRI_network.checkHw(self)

Checks if the magic file exists to demark that we’re running on a system with CRI hardware accessible.

Returns

Type Description
bool True if the magic file exists, False otherwise.

Examples

>>> network = CRI_network(axons, connections, config, outputs)
>>> network.checkHw()
True

gen_connectome

api.CRI_network.gen_connectome(self)

Notes

The function resets the count of neurons and creates a new connectome. It then adds neurons/axons and assigns synapses to them.

Examples

>>> network = CRI_network(axons, connections, config, outputs)
>>> network.gen_connectome()

read_synapse

api.CRI_network.read_synapse(self, preKey, postKey)

Reads a synapse from the connectome.

Parameters

Name Type Description Default
preKey str A string representing the key of the presynaptic neuron. required
postKey str A string representing the key of the postsynaptic neuron. required

Returns

Type Description
int The weight of the synapse.

Raises

Type Description
Exception If the target is not valid (“simpleSim” or “CRI”).

Examples

>>> network = CRI_network(axons, connections, config, outputs)
>>> network.read_synapse('axon1', 'neuron1')
1

run_cont

api.CRI_network.run_cont(self, inputs)

Runs a continuous simulation.

Parameters

Name Type Description Default
inputs list of list A list of lists of inputs for the simulation. required

Returns

Type Description
tuple A tuple containing the spike list, a boolean indicating whether a break occurred, and the execution counter.

Raises

Type Description
Exception If the simulation dump flag is False and an error occurs during the conversion of neuron indices to user keys.

Examples

>>> network = CRI_network(axons, connections, config, outputs)
>>> network.run_cont([['input1', 'input2'], ['input3', 'input4']])

sim_flush

api.CRI_network.sim_flush(self, file)

Flushes the simulation results to a file.

Parameters

Name Type Description Default
file str A string representing the file to which to flush the simulation results. required

Returns

Type Description
None

Raises

Type Description
Exception If the target is not “CRI” or if the target is invalid.

Examples

>>> network = CRI_network(axons, connections, config, outputs)
>>> network.sim_flush('results.txt')

step

api.CRI_network.step(self, inputs, target='simpleSim', membranePotential=False)

Runs a step of the simulation.

Parameters

Name Type Description Default
inputs list A list of inputs for the simulation. required
target str A string representing the target for the simulation. Default is “simpleSim”. 'simpleSim'
membranePotential bool A boolean value indicating whether to return the membrane potential. Default is False. False

Returns

Type Description
list or tuple The simulation outputs or a tuple containing the simulation outputs and spike outputs.

Raises

Type Description
Exception If the target is invalid.

Examples

>>> network = CRI_network(axons, connections, config, outputs)
>>> network.step(['input1', 'input2'])

write_listofSynapses

api.CRI_network.write_listofSynapses(self, preKeys, postKeys, weights)

Writes a list of synapses to the connectome.

Parameters

Name Type Description Default
preKeys list of str A list of strings representing the keys of the presynaptic neurons. required
postKeys list of str A list of strings representing the keys of the postsynaptic neurons. required
weights list of int A list of integers representing the weights of the synapses. required

Examples

>>> network = CRI_network(axons, connections, config, outputs)
>>> preKeys = ['axon1', 'axon2']
>>> postKeys = ['neuron1', 'neuron2']
>>> weights = [1, 2]
>>> network.write_listofSynapses(preKeys, postKeys, weights)

write_synapse

api.CRI_network.write_synapse(self, preKey, postKey, weight)

Writes a synapse to the connectome.

Parameters

Name Type Description Default
preKey str A string representing the key of the presynaptic neuron. required
postKey str A string representing the key of the postsynaptic neuron. required
weight int An integer representing the weight of the synapse. required

Raises

Type Description
Exception If the target is not valid (“simpleSim” or “CRI”).

Examples

>>> network = CRI_network(axons, connections, config, outputs)
>>> network.write_synapse('axon1', 'neuron1', 1)