Synapses connect the neurons and can affect the neuron membrane voltages via current or voltage.
There are also some global synapse data dumping functions to save synapses to files.
These can either be saved as .txt files with each line a new value as a readable ASCII format.
Alternatively, they can be saved as binary files (.bin) which are faster to read and write. Binary files are stored such that each 32bits of data are a separate value in either int32 or float32 encoding.
To see examples of storing network connectivity and weights, see the Brunel network example.
To save the network structure (presynaptic IDs, postsynaptic IDs, synaptic weights, and synaptic delays), a number of methods exist.
These methods require as the first argument the path to the folder where the connectivity should be saved. The second parameter exists to allow you to customize the name of the saved files with a prefix. Finally, the third parameter allows you to only store data relevant to a specific synapse group. Whenever you create a synapse group, an ID is returned which you can use to save data relevant to those synapses. Note that if the ID is set to -1, all of the network synapses are saved to file.
Synapses::save_connectivity_as_txt(std::string path, std::string prefix="", int synapsegroupid=-1);
Synapses::save_connectivity_as_binary(std::string path, std::string prefix="", int synapsegroupid=-1);
We can alternatively only store the weight values rather than all of the connectivity information like so:
Synapses::save_weights_as_txt(std::string path, std::string prefix="", int synapsegroupid=-1);
Synapses::save_weights_as_binary(std::string path, std::string prefix="", int synapsegroupid=-1);
Loading weights is supported with the following set of methods. Note that you must first create a synapse group and then load weights to it.
For weight loading, the first parameter is the specific filepath + filename of the file from which you wish to load synapses. The second parameter (similar to the third parameter above) indicates the specific synapse group for which you wish to load synapse weights. If this parameter is -1, it attempts to load weight values for every synapse in the network.
Synapses::load_weights_from_txt(std::string filepath, int synapsegroupid=-1);
Synapses::load_weights_from_binary(std::string filepath, int synapsegroupid=-1);