Functions module

Contains all the mathematical helper functions used throughout the scaffold. Differs from helpers.py only categorically. Helpers.py contains functions, classes and general logic that supports the scaffold, while functions.py contains a collection of mathematical functions.

bsb.functions.add_y_axis(points, min, max)[source]

Add random values to the 2nd column of a matrix of 2D points.

bsb.functions.apply_2d_bounds(possible_points, cell_bounds)[source]

Compare a 2xN matrix of XZ coordinates to a matrix 2x3 with a minimum column and maximum column of XYZ coordinates.

bsb.functions.compute_circle(center, radius, n_samples=50)[source]

Create n_samples points on a circle based on given center and radius.

Parameters
  • center (array-like) – XYZ vector of the circle center

  • radius (scalar value) – Radius of the circle

  • n_samples (int) – Amount of points on the circle.

bsb.functions.compute_intersection_slice(l1, l2)[source]

Returns the indices of elements in l1 that intersect with l2.

bsb.functions.exclude_index(arr, index)[source]

Return a new list with the element at index removed.

bsb.functions.get_candidate_points(center, radius, bounds, min_ε, max_ε, return_ε=False)[source]

Returns a list of points that are suited next candidates in a random walk.

Computes a circle of points between 2r + ϵ distance away from the center and removes any points that lie outside of the given bounds.

Parameters
  • center (list) – 2D position of the starting point.

  • radius (float) – Unit distance radius of the particle at the center point.

  • bounds (ndarray) – A 2x3 matrix where the first column are the minimum XYZ and the last column the maximum XYZ.

  • min_ϵ (float) – Lower bound of epsilon used to calculate random distance.

  • max_ϵ (float) – Upper bound of epsilon used to calculate random distance.

  • return_ϵ – If True the candidates and ϵ used to calculate them will be returned as a tuple.

bsb.functions.get_distances(candidates, point)[source]

Return the distances of a list of points to a common point

bsb.functions.poisson_train(frequency, duration, start_time=0, seed=None)[source]

Generator function for a Homogeneous Poisson train.

Parameters
  • frequency – The mean spiking frequency.

  • duration – Maximum duration.

  • start_time – Timestamp.

  • seed – Seed for the random number generator. If None, this will be decided by numpy, which chooses the system time.

Returns

A relative spike time from t=start_time, in seconds (not ms).

EXAMPLE:

# Make a list of spikes at 20 Hz for 3 seconds
spikes = [i for i in poisson_train(20, 3)]