teili.tools package¶
Submodules¶
teili.tools.converter module¶
Function for external interfaces such as an event-based camera, e.g. DVS.
Functions in this module convert data from or to brian2 compatible formats. In particular, there are functions to convert data coming from DVS cameras.
-
teili.tools.converter.
aedat2numpy
(datafile, length=0, version='V2', debug=0, camera='DVS128', unit='ms')[source]¶ Loads AER data file and parses these properties of AE events.
- Properties:
timestamps (in us).
x,y-position [0..127]x[0..127] for DVS128 [0..239]x[0..127] for DAVIS240.
polarity (0/1).
- Parameters
datafile (str, optional) – Aedat recording as provided by jAER or cAER.
length (int, optional) – how many bytes(B) should be read; default 0=whole file.
version (str, optional) – which file format version is used: - “dat” = V1 (old) - “aedat” jAER AEDAT 2.0 = V2 - “aedat” cAER AEDAT 3.1 = V3. - “aedat” DV AEDAT 4.0 = V4
debug (int, optional) – Flag to provide more detailed report. 0 = silent, 1 (default) = print summary. >=2 = print all debug.
camera (str, optional) – Type of event-based camera.
unit – output unit of timestamps specified as a string: - ‘ms’ (default), ‘us’ or ‘sec’.
- Returns
(xpos, ypos, ts, pol) 2D numpy array containing data of all events.
- Return type
numpy.ndarray
- Raises
ValueError – Indicates that a camera was specified which is not supported or the AEDAT file version is not supported.
-
teili.tools.converter.
delete_doublets
(spiketimes, indices, verbose=False)[source]¶ Removes spikes that happen at the same time and at the same index. This happens when you donwnsample, but Brian2 cannot cope with more that 1 spike per ts. :param spiketimes: numpy array of spike times :param indices: numpy array of indices :return: same as input but with removed doublets
-
teili.tools.converter.
dvs2ind
(events=None, event_directory=None, resolution='DAVIS240', scale=True)[source]¶ Function which converts events extracted from an aedat file using aedat2numpy into 1D vectors of neuron indices and timestamps.
Function only returns index and timestamp list for existing types (e.g. On & Off events).
- Parameters
Events (None, optional) – 4D numpy.ndarray which contains pixel location (x,y), timestamps and polarity ((4,#events)).
event_directory (None, optional) – Path to stored events.
resolution (str/int, optional) – Resolution of the camera.
scale (bool, optional) – Flag to rescale the timestamps from microseconds to milliseconds.
- Returns
Unique indices which maps the pixel location of the camera to the 1D neuron indices of ON events. ts_on (1d numpy.array): Unique timestamps of active indices of ON events. indices_off (1d numpy.array): Unique indices which maps the pixel location of the camera to the 1D neuron indices of OFF events. ts_off (1d numpy.array): Unique timestamps of active indices of OFF events.
- Return type
indices_on (1d numpy.array)
-
teili.tools.converter.
dvs_csv2numpy
(datafile='tmp/aerout.csv', debug=False)[source]¶ Loads AER csv logfile and parses these properties of AE events
- Properties:
timestamps (in us).
x,y-position [0..127].
polarity (0/1).
- Parameters
datafile (str, optional) – path to the csv file to read.
debug (bool, optional) – Flag to print more details about conversion.
- Returns
(ts, xpos, ypos, pol) 4D numpy array containing data of all events.
- Return type
numpy.ndarray
teili.tools.cpptools module¶
Collection of tools to add some features to cpp standalone mode
-
teili.tools.cpptools.
activate_standalone
(directory='Brian2Network_standalone', build_on_run=False)[source]¶ Enables cpp standalone mode
- Parameters
directory (str, optional) – Standalone directory containing all compiled files
build_on_run (bool, optional) – Flag to (re-)build network before simulating
-
teili.tools.cpptools.
build_cpp_and_replace
(standalone_params, standalone_dir='/home/docs/Brian2Standalone', clean=True, do_compile=True, verbose=True)[source]¶ Builds cpp standalone network and replaces variables/parameters with standalone_params This does string replacement in the generated c++ code.
- Parameters
standalone_params (dict, required) – Dictionary containing all parameters which can be changed after building the network
standalone_dir (str, optional) – Directory containing output generated by network
clean (bool, optional) – Flag to clean build network
do_compile (bool, optional) – Flag to compile network
-
teili.tools.cpptools.
collect_standalone_params
(params={}, *building_blocks)[source]¶ This just collect the parameters of all buildingblocks and adds additional parameters (not from buildingblocks)
- Parameters
params (OrderedDict, optional) – Dictionary with parameters. Needs to be ordered.
*buildingBlocks – The network building block to assign standalone parameters to
- Returns
standalone parameters
- Return type
dict
-
teili.tools.cpptools.
params2run_args
(standalone_params)[source]¶ Add standalone parameter to run arguments
- Parameters
standalone_params (dict) – Dictionary containing standalone parameters to be added to run arguments
- Returns
run arguments
- Return type
list
-
teili.tools.cpptools.
print_dict
(pdict)[source]¶ Wrapper function to print dictionary
- Parameters
pdict (dictionary) – Dictionary to be printed
-
teili.tools.cpptools.
replace_variables_in_cpp_code
(replace_vars, replace_file_location, verbose=True)[source]¶ Replaces a list of variables in CPP code for standalone code generation with changeable parameters and it adds duration as a changeable parameter (it is always the first argument)
- Parameters
replace_vars (list, str) – List of strings, variables that are replaced
replace_file_location (str) – Location of the file in which the variables are replaced
teili.tools.distance module¶
Functions to compute distance (e.g. in 2D).
The suffix “_cpp” avoids variables being string-replaced by brian2 if the same name is used in the network.
teili.tools.indexing module¶
Collections of functions which convert indices to x, y coordinates and vice versa.
The suffix “_cpp” avoids variables being string-replaced by brian2 if the same name is used in the network.
Todo
- TODO: make ind2events consistent with the other functions
in this module! (or maybe it is not at the right place here).
teili.tools.math_functions module¶
teili.tools.misc module¶
A collection of helpful miscellaneous functions when working with brian2
-
teili.tools.misc.
neuron_group_from_spikes
(num_inputs, simulation_dt, duration, poisson_group=None, spike_indices=None, spike_times=None)[source]¶ Converts spike activity in a neuron poisson_group with the same activity.
- Parameters
num_inputs (int) – Number of input channels from source.
simulation_dt (brian2.unit.ms) – Time step of simulation.
duration (int) – Duration of simulation in brian2.ms.
poisson_group (brian2.poissonGroup) – Poisson poisson_group that is passed instead of spike times and indices.
spike_indices (numpy.array) – Indices of the original source.
spike_times (numpy.array) – Time stamps with unit of original spikes in ms.
- Returns
Neuron poisson_group with mimicked activity.
- Return type
neu_group (brian2 object)
-
teili.tools.misc.
print_states
(briangroup)[source]¶ Wrapper function to print states of a brian2 groups such as NeuronGroup or Synapses
- Parameters
briangroup (brian2.group) – Brain object/group which states/statevariables should be printed
-
teili.tools.misc.
spikemon2firing_rate
(spikemon, start_time=0.0 * second, end_time='max')[source]¶ Calculates the instantaneous firing rate within a window of interest from a SpikeMonitor
- Parameters
spikemon (brian2.SpikeMonitor) – Brian2 SpikeMoitor object
start_time (brain2.unit.ms, optional) – Starting point for window to calculate the firing rate. Must be provided as desired time in ms, e.g. 5 * ms
end_time (str, optional) – End point for window to calculate the firing rate. Must be provided as desired time in ms, e.g. 5 * ms
- Returns
Firing rate in Hz
- Return type
int
teili.tools.plotter2d module¶
Created on 28 Dec 2017
@author: Alpha Renner
This class is a 2d plotter and provides functionality for analysis of 2d neuron fields To be extended!
-
teili.tools.plotter2d.
CM_JET
¶ Description
- Type
TYPE
-
teili.tools.plotter2d.
CM_ONOFF
¶ Description
- Type
TYPE
-
class
teili.tools.plotter2d.
DVSmonitor
(xi, yi, t, pol, unit=None)[source]¶ Bases:
object
Summary
-
pol
¶ Description
- Type
TYPE
-
t
¶ Description
- Type
TYPE
-
xi
¶ Description
- Type
TYPE
-
yi
¶ Description
- Type
TYPE
-
-
class
teili.tools.plotter2d.
Plotter2d
(monitor, dims, plotrange=None)[source]¶ Bases:
object
- Plotter2d is a class that contains a number of functions to create 2d plots over time, in particular events/spikes
that are arranged in 2d such as DVS camera recordings or 2d neural fields. The class offers filtering, plotting and generation of gifs.
Data is passed into the plotter as a monitor (either from brian2 or using the DVSmonitor class)
-
dims
¶ the dimensions of the 2d data (number of rows and columns)
- Type
tuple
-
monitor
¶ A monitor to sparsely store event data (e.g. from brian2), it has a t (timestamps), xi (x event coordinates) and yi (y coordinates) property or an i property (flat coordinates that are reshaped to 2d)
- Type
TYPE
-
plotrange
¶ Masks the monitor outside of the given range (in units of t)
- Type
tuple
-
shape
¶ 3d shape of the data
- Type
tuple
-
rows
¶ number of rows (dims[0])
- Type
int
-
cols
¶ number of columns (dims[1])
- Type
int
-
mask
¶ mask that masks out part of the data
- Type
array
-
calculate_pop_vector_trajectory
(dt=50.0 * msecond, plot=False, frames_timestamps=None)[source]¶ Calculates the trajectory of the center of mass over time.
-
generate_movie
(filename, scale=None, speed=1, plotfunction='plot3d', plot_dt=10.0 * msecond, tempfolder='/home/docs', ffmpegoptions='', **plotkwargs)[source]¶ This exports a movie or gif from an imageview Existing outputfiles will be overwritten This needs ffmpeg wich is installed on most linux distributions and also available for windows and mac Have a loo here: https://ffmpeg.org/
- Parameters
filename (str) – The filename in which to store the generated movie. You can choose a format that can be generated with ffmpeg like ‘.gif’, ‘.mpg’, ‘.mp4’,…
scale (str, optional) – give pixel size as string e.g. ‘100x100’
speed (num, optional) – if the video should run faster, specify a multiplier
plot_dt (given in brian2 time units) – is passed to the plotfunction and determines the fps
tempfolder (str, optional) – the directory in which the temporary folder to store files created in the process. The temporary folder will be deleted afterwards. By default it will be created in your home directory
plotfunction (str or function, optional) – the function that should be used to create the gif. it has to be a function that returns a pyqtgraph imageview (or at least something similar that can export single images) like the methods of this class (plot3d, …). For the methods, you can also pass a string to identify the plotfunction. The plotfunction has to take plot_dt as an argument
ffmepgoptions (str, optional) –
kwargs – all other keyword agruments will be passed to the plotfunction
usage (Example) –
plotter2dobject.generate_gif ('~/gifname.gif', plotfunction = 'plot3d_on_off', filtersize=100 * ms, plot_dt=50 * ms) –
-
get_dense3d
(dt)[source]¶ Transforms the sparse spike time representation in a dense representation, where every spike is given as a 1 in a 3d matrix (time + 2 spatial dimensions) The data is binned using dt. If there is more than one spike in a bin, the bin will not have the value 1, but the number of spikes.
- Parameters
dt (TYPE) – Description
- Returns
- dense array of the data. E.g. if we have a single spike in the neuron at location (3, 5) at timestamp
10, in the dense array, all locations have a value of 0 at all timesteps apart from (10, 3, 5), where the value is 1.
- Return type
array
-
get_dense_ifr
(dt=50.0 * msecond, plot=False, frames_timestamps=None)[source]¶ calculates a vector of instantaneous frequencies for every timestep dt. IFRs on timesteps without a spike are interpolated between the last two spikes :return: matrix of IFRs for every neuron and every timestep
-
get_filtered
(dt, filtersize)[source]¶ applies a rectangular filter (convolution) of length filtersize over time (dimension 0). It returns a 3d matrix with the firing rate. Spiketimes will be binned with a step size of dt that means that the filtersize should always be a int multiple of dt
- Parameters
dt (brian2.Quantity) – the time step with which the spike times are binned
filtersize (brian2.Quantity) – length of the filter (in brian2 time units)
- Returns
Description
- Return type
TYPE
-
get_sparse3d
(dt, align_to_min_t=True)[source]¶ Using the package sparse (based of scipy sparse, but for 3d), the spiketimes are converted into a sparse matrix. This step is basically just for easy conversion into a dense matrix later, as you cannot do so many computations with the sparse representation. sparse documentation can be found here: http://sparse.pydata.org/en/latest/
- Parameters
dt (float) – the t dimension in the sparse representation is given in timesteps, so t is divided by dt
- Returns
Sparse representation of the data used to create the dense one efficiently.
- Return type
sparse.COO
-
property
i
¶ flattened indices (in 1d)
-
ifr_histogram
(filename=None, num_bins=50)[source]¶ histogram of instantaneous frequencies
- Parameters
filename (str) – filename to save the histogram
num_bins (int, optional) – number of bins of the histogram
-
classmethod
loaddvs
(eventsfile, dims=None)[source]¶ loads a dvs numpy (events file) from aedat2numpy and returns a SpikeMonitor2d object, you can also directly pass an events array
- usage:
spikemonObject = SpikeMonitor2d.loadz(myfilename) #e.g. spikemonObject.plot3d()
- Parameters
eventsfile (str) – filename from where to load the data of the plotter object
-
classmethod
loadz
(filename)[source]¶ loads a file that has previously been saved with savez and returns a SpikeMonitor2d object
- usage:
spikemonObject = SpikeMonitor2d.loadz(myfilename) #e.g. spikemonObject.plot3d()
- Parameters
filename (str) – filename from where to load the data of the plotter object
- Returns
Description
- Return type
TYPE
-
plot3d
(plot_dt=100.0 * usecond, filtersize=10.0 * msecond, colormap=pyqtgraph.colormap.ColorMap, levels=None, flipy=False)[source]¶ - Parameters
plot_dt (brian2.Quantity, optional) – timestep in which events are binned for plotting
filtersize (brian2.Quantity, optional) – filtersize of rectangular filter
colormap (pyqtgraph.colormap.ColorMap, optional) – colormap for on off plot
levels (tuple) – (min, max); the white and black level values to use (passed to pyqtgraph)
- Returns
ImageView object for usage in a larger pyqtgraph plot
- Return type
pyqtgraph.ImageView
-
plot3d_on_off
(plot_dt=100.0 * usecond, filtersize=10.0 * msecond, colormap=pyqtgraph.colormap.ColorMap, flipy=False)[source]¶ - Parameters
plot_dt (brian2.Quantity, optional) – timestep in which events are binned for plotting
filtersize (brian2.Quantity, optional) – filtersize of rectangular filter
colormap (pyqtgraph.colormap.ColorMap, optional) – colormap for on off plot
- Returns
ImageView object for usage in a larger pyqtgraph plot
- Return type
pyqtgraph.ImageView
-
plot_panes
(num_panes=None, timestep=None, filtersize=50. * msecond, num_rows=2, plotfunction='plot3d', filename=None, colormap=<matplotlib.colors.LinearSegmentedColormap object>, **plotkwargs)[source]¶ plots the 3d data as time slices (2d images at several timepoints) :param num_panes: number of panes to plot :type num_panes: int, optional :param timestep: timestep between panes :type timestep: TYPE, optional :param filtersize: filtersize at which the spikes are filtered to generate the images :type filtersize: TYPE, optional :param num_rows: number of rows of the pane plot :type num_rows: int, optional :param filename: location where to save the plot :type filename: str, optional
- Returns
Description
- Return type
TYPE
-
property
plotlength
¶ number of timesteps
-
property
plotrange
¶
-
plotshape
(dt)[source]¶ 3d shape of the data (num_timestamps, num_rows, num_cols)
- Parameters
dt (float) – timestep length
- Returns
(num_timestamps, num_rows, num_cols)
- Return type
tuple
-
property
pol
¶ polarity of DVS spikes
-
rate_histogram
(filename=None, filtersize=50.0 * msecond, plot_dt=10.0 * msecond, num_bins=50)[source]¶ plots a histogram of rates
- Parameters
filename (str) – filename to save the histogram
filtersize (brian2.Quantity, optional) – filtersize of the retangular filter to calculate the rate
plot_dt (brian2.Quantity, optional) – binsize in which the data is binned
num_bins (int, optional) – number of bins of the histogram
-
savez
(filename)[source]¶ saves the object in a sparse way. only i,t, rows and cols are saved to an npz
- Parameters
filename (str) – filename under which to save the data of the plotter object
-
set_range
(plotrange=None)[source]¶ set a range with unit that is applied for all computations with this monitor
- Parameters
plotrange (tuple) – (from, to))
-
property
t
¶ timestamps of events
-
property
t_
¶ unitless t in ms
-
property
xi
¶ row coordinates of events
-
property
yi
¶ columns coordinates of events
-
teili.tools.plotter2d.
create_panes
(video, num_rows, slice_indices=None, colormap=<matplotlib.colors.LinearSegmentedColormap object>)[source]¶ - Parameters
video – the 3d matrix that should be plotted
slice_indices – the indices of the plotted slices in the first dim of the 3d matrix
num_rows – the number of rows for the pane plot
- Returns
the GraphicsWindow object
-
teili.tools.plotter2d.
export_panes
(gw_paneplot, filename)[source]¶ generates a figure file from a GraphicsWindow object :param gw_paneplot: :param filename: :return:
teili.tools.plotting module¶
Summary
-
teili.tools.plotting.
colors
¶ Description
- Type
TYPE
-
teili.tools.plotting.
labelStyle
¶ Description
- Type
dict
-
teili.tools.plotting.
plot_spikemon
(start_time, end_time, monitor, num_neurons, ylab='ind')[source]¶ Summary
- Parameters
start_time (TYPE) – Time from which spikes should be visualized
end_time (TYPE) – Time until which spikes should be visualized
monitor (brian2.monitoritor) – Monitor which serve as basis for plotting
num_neurons (int) – Number of neurons to visualize
ylab (str, optional) – Description
-
teili.tools.plotting.
plot_spikemon_qt
(monitor, start_time=None, end_time=None, num_neurons=16, window=None, unit=None)[source]¶ Generic plotting function to plot spikemonitors using pyqtgraph
- Parameters
start_time (int, optional) – Time from which spikes should be visualized
end_time (int, optional) – Time until which spikes should be visualized
monitor (brian2.obj) – Monitor which serve as basis for plotting
num_neurons (int) – Number of neurons to be plotted
window (TYPE) – PyQtGraph window to which the plot should be added
- Raises
UserWarning – Description
-
teili.tools.plotting.
plot_statemon
(start_time, end_time, monitor, neuron_id, variable='Vm', unit=mvolt, name='')[source]¶ Summary
- Parameters
start_time (int, optional) – Time from which spikes should be visualized
end_time (int, optional) – Time until which spikes should be visualized
monitor (brian2.obj) – Monitor which serve as basis for plotting
neuron_id (int) – ID of neuron to be visualized
variable (str) – State variable to visualize
unit (brian2.unit, optional) – Unit of state variable
name (str, optional) – Description
-
teili.tools.plotting.
plot_statemon_qt
(start_time=None, end_time=None, monitor=None, neuron_id=True, variable='Imem', unit=pamp, window=None, name='')[source]¶ Generic plotting function to plot statemonitors using pyqtgraph
- Parameters
start_time (int, optional) – Time from which spikes should be visualized
end_time (int, optional) – Time until which spikes should be visualized
monitor (brian2.obj) – Monitor which serve as basis for plotting
neuron_id (int) – ID of neuron to be visualized
variable (str) – State variable to visualize
unit (brian2.unit, optional) – Unit of state variable
window (pyqtgraph.window) – PyQtGraph window to which the plot should be added
name (str, optional) – Name of window
- Raises
UserWarning – Description
-
teili.tools.plotting.
plot_weights_group2wta
(name, n_wta2d_neurons, syn_g_wta, n_col)[source]¶ Summary
- Parameters
name (str) – Name of the plot to be saved
n_wta2d_neurons (int) – Number of 2d WTA population
syn_g_wta (brian2.synapses) – Synapse group which weights should be plotted
n_col (int) – Number of column to visualize
-
teili.tools.plotting.
plot_weights_wta2group
(name, n_wta2d_neurons, syn_g_wta, n_col)[source]¶ Summary
- Parameters
name (str) – Name of the plot to be saved
n_wta2d_neurons (TYPE) – Number of 2d WTA population
syn_g_wta (TYPE) – Synapse group which weights should be plotted
n_col (TYPE) – Number of column to visualize
teili.tools.sorting module¶
To understand the structure of in the rasterplots but also in the learned weight matrices, we need to sort the weight matrices according to some similarity measure, such as euclidean and jaccard distance. However, the sorting algorithm is completely agnostic to the similarity measure. It connects each node with maximum two edges and constructs a directed graph. This is similar to the travelling salesman problem.
Example
In order to use this class you need to initialize it either without a filename:
>>> from teili.tools.sorting import SortMatrix
>>> import numpy as np
>>> matrix = np.random.randint((49, 49))
>>> obj = SortMatrix(nrows=49, matrix=matrix)
>>> print(obj.matrix)
>>> print(obj.permutation)
>>> print(ob.sorted_matrix)
or instead of using a matrix you can also specify a path to a stored matrix:
>>> filename = '/path/to/your/matrix.npy'
>>> obj = SortMatrix(nrows=49, filename=filename)
-
class
teili.tools.sorting.
SortMatrix
(nrows, ncols=None, filename=None, matrix=None, axis=0, target_indices=None, rec_matrix=False, similarity_metric='euclidean')[source]¶ Bases:
object
Class which can sort your matrix based on similarity
-
filename
¶ path/to/matrix/name.npy.
- Type
str, optional
-
matrix
¶ matrix as provided by load_matrix.
- Type
ndarray, optional
-
ncols
¶ number of columns of the 2d array.
- Type
int, optional
-
nrows
¶ number of rows of the 2d array.
- Type
int, required
-
permutation
¶ List of indices which are more similar to each other in (euclidean, jaccard) distance.
- Type
list
-
similarity_matrix
¶ Matrix containing similarities.
- Type
ndarray, optional
-
sorted_matrix
¶ Sorted matrix according to permutation.
- Type
TYPE
-
recurrent_matrix
¶ Indicates whether it is a recurrent matrix or not.
- Type
boolean, optional
-
similarity_metric
¶ Indicates metric for calculating similarity.
- Type
str, optional
-
max_val
¶ Maximum value of the provided matrix
- Type
float
-
compute_distance
(x, y, similarity_metric, threshold=0.8)[source]¶ This function returns the distance of any to vectors x and y
- Parameters
x (ndarray, required) – 1d vector.
y (ndarray, required) – 1d vector.
similarity_metric (str, required) – Metric used to measure similarity
- Returns
Element-wise distance of two 1d vectors.
- Return type
ndarray
-
get_permutation
(axis=0)[source]¶ To sort a given matrix according to its similarity we need to construct permutation indices, which are used to sort the matrix. First we find the most similar entry in the similarity matrix. This function allows each node in the similarity graph to be only used twice, i.e. each node has maximally two edges connected to it. The vector ‘degree’ keeps track of this. To prevent a loop closure in the similarity graph a proxy vector called ‘partner’ is used to set the distance between the two ends of the similarity graph to infinity.
- Parameters
axis (int, optional) – Axis along which similarity should be computed.
- Returns
Vector of permuted indices.
- Return type
list
-
get_similarity_matrix
(axis=0)[source]¶ This function computes a similarity matrix of a given matrix.
- Parameters
axis (int, optional) – Axis along which similarity should be computed.
- Returns
Matrix containing similarities.
- Return type
ndarray
-
teili.tools.stimulus_generators module¶
The idea is to generate inputs based on a function. This avoids having to read large datafiles and makes generation of input easier.
How to use them: See example below.
-
class
teili.tools.stimulus_generators.
StimulusSpikeGenerator
(*args, **kw)[source]¶ Bases:
teili.core.groups.TeiliGroup
,brian2.input.poissongroup.PoissonGroup
idea: add a run_regularly with dt, that dynamically changes the rates of a PoissonGroup or the input current of an IF neuron
The class is the neuron or the generator and can be added to a network
You can add equations that specify the trajectory of any pattern-variable. The two variables that are given by default are trajectory_x and trajectory_y But you can always specify the trajectory of any other variable in the trajectory_eq
trajectory_eq can either use a TimedArray that contains a prerecorded trajectory or you can also set an equation that describes the trajectory
The first 2 args of any pattern function must always be the x/y coordinates
Any user provided distance function has to have the brian2 decorators and take the following arguments: i, j, nrows, ncols (i and j are 1d indices in the 2d array)
please have a look at the example of a moving gaussian below (if __name__ == ‘__main__’:)
teili.tools.synaptic_kernel module¶
This module provides functions that can be used for synaptic connectivity kernels (generate weight matrices). In order to also use them with C++ code generation, all functions that are added here need to have a cpp implementation given by the @implementation decorator.
TODO: It would be good, if one could easily use different distance functions like on a ring or torus (1d/2d periodic boundary conditions). For numpy, this would be easy to implement by just using the respective function (from tools.distance) and add a selector as a parameter. For cpp, we would have to make sure that the functions used are known.