Connection functions

This section shows the functions implemented in sPyBlocks that are useful to interconnecting all neurons in the functional blocks at the lower level. Thus, these functions have not been implemented for the user, but to interconnect neurons in each of the implemented functional blocks.

sPyBlocks.connection_functions.create_connections(ini_pop, end_pop, sim, conn, conn_all=True, rcp_type='excitatory', ini_pop_indexes=None, end_pop_indexes=None)

Creates connections between ini_pop and end_pop objects.

Parameters
  • ini_pop (sim.Population, sim.PopulationView, sim.Assembly, list) – A PyNN object or a list of PyNN objects that serve as input population. Starting point of the connections.

  • end_pop (sim.Population, sim.PopulationView, sim.Assembly, list) – A PyNN object or a list of PyNN objects that serve as end population. End point of the connections.

  • sim – The simulator package.

  • conn (sim.StaticSynapse) – The connection to use.

  • conn_all (bool) – A boolean indicating whether or not all selected input objects should be connected to all selected output objects.

  • rcp_type (str) – A string indicating the receptor type of the connections (excitatory or inhibitory).

  • ini_pop_indexes (list) – A list of indices used to select objects from the input population.

  • end_pop_indexes (list) – A list of indices used to select objects from the output population.

Returns

The number of connections that have been created.

Return type

int

sPyBlocks.connection_functions.flatten(array)

Flats an array recursively.

Parameters

array (list) – An input array.

Returns

The flattened input array.

Return type

list

sPyBlocks.connection_functions.inverse_rcp_type(rcp_type)

Generates a string indicating the receiver type inverse to the one received in the input variable. Only the “excitatory” or “inhibitory” strings are allowed; any other string will throw an exception.

Parameters

rcp_type (str) – The original receptor type.

Returns

“Inhibitory” if rcp_type is “excitatory”. Otherwise, “excitatory”.

Return type

str

Raises

ValueError – If rcp_type is not “excitatory” or “inhibitory”.

sPyBlocks.connection_functions.is_pynn_object(obj, sim)

Checks if the object passed as a parameter belongs to a type of the PyNN library.

Parameters
  • obj – The object to check.

  • sim – The simulator package containing the defined classes.

Returns

True if the object is an instance of a PyNN class. Otherwise, false.

Return type

bool

sPyBlocks.connection_functions.list_element(array, index_array)

Returns the elements of the input list found at the positions indicated by the indices contained in index_array[ 0]. Accessing the first position of index_array allows to optimize the create_connections function, using a notation similar to that needed to use PyNN’s PopulationView function.

Parameters
  • array (list) – A list of generic elements.

  • index_array (list) – A list containing the positions of the elements to take in the input list.

Returns

A list containing the desired elements.

Return type

list

sPyBlocks.connection_functions.multiple_connect(function_name, population, components, conn, conn_all, rcp_type, ini_pop_indexes, end_pop_indexes, component_indexes)

Calls the function indicated by function_name for each component in components passing a population as input parameter.

Parameters
  • function_name (str) – The name of the function to call.

  • population (sim.Population, sim.PopulationView, sim.Assembly, list) – A PyNN object or a list of PyNN objects containing the population to be passed as input parameter.

  • components (list) – A list of spiking functional blocks defined by multiple type classes from this library.

  • conn (sim.StaticSynapse) – The connection to use.

  • conn_all (bool) – A boolean indicating whether or not all selected input objects should be connected to all selected output objects.

  • rcp_type (str) – A string indicating the receptor type of the connections (excitatory or inhibitory).

  • ini_pop_indexes (list) – A list of indices used to select objects from the input population.

  • end_pop_indexes (list) – A list of indices used to select objects from the output population.

  • component_indexes (list) – A list of indices used to select objects from the component list.

Returns

None

sPyBlocks.connection_functions.truth_table_column(n_values, n_var, select=1)

Generates the array of indices where the value indicated by the “select” parameter is found in the column indicated by the “n_var” parameter. “n_values” indicates the number of elements to consider in that column, commonly 2^n if n is the number of variables in the truth table (it is the number of all possible binary combinations of the input variables).

Parameters
  • n_values (int) – The number of elements of the column to consider.

  • n_var (int) – The index of the input variable or column. From 0 to n-1 if n is the number of variables in the truth table. Column 0 is the least significant column.

  • select (int) – Value to consider in the truth table column. There are only two possibilities: 0 or 1, since only binary values can be entered in a truth table.

Returns

If select = 0, it returns a list (zeros) containing the indexes of 0 values in the selected column. Otherwise, it returns a list (ones) containing the indexes of 1 values in the selected column.

Return type

list

Raises

ValueError – If select is not 0 or 1.