Connectivity Utilities

Utility functions for building connectivity matrices.

network_configs.connections.conn_utils.add_project_to_sys_path()

Adds the project’s root directory to the system path.

Python interpreter does not allow importing modules from parent directories. This function resolves the path of the current file, navigates two levels up to reach the project’s root directory, and inserts this directory at the beginning of the system path. This allows importing helper_functions, params, specs_file etc.

network_configs.connections.conn_utils.assign_positions_rect(N_per_axis)

Assigns positions in a rectangular grid centered at the origin.

This function generates a set of coordinates for a rectangular grid with N_per_axis points along each axis. The number of points along each axis must be odd.

Parameters:

N_per_axis (int) – The number of points along each axis. Must be an odd number.

Returns:

A 2D array of shape (N_per_axis\(^2\), 2) containing the

coordinates of the grid points.

Return type:

numpy.ndarray

Raises:

ValueError – If N_per_axis is not an odd number.

network_configs.connections.conn_utils.file_args()

Creates an argument parser for connectivity configuration.

Returns:

The argument parser with the following arguments:
  • -i, --sim_id (str, optional): Simulation ID.

  • -c, --conn_id (str, optional): Connection ID.

  • -t, --sim_type (str, optional): Simulation type. Default is “single”.

  • -n, --sim_num (int, optional): Simulation number. Default is 0.

  • -p, --specs_file (str, optional): Path to the specifications file.

Return type:

argparse.ArgumentParser

network_configs.connections.conn_utils.find_params(args: Namespace) dict

Finds and returns simulation parameters based on the provided arguments.

Parameters:

args (argparse.Namespace) – The arguments namespace containing either a simulation ID or a specifications file.

Returns:

A dictionary containing the simulation parameters.

Return type:

dict

Raises:

FileNotFoundError – If neither sim_id nor specs_file is provided, or if the specified files are not found.

Notes

Parameter dict is generated based on following order of precedence.

If sim_id is provided, it attempts to read the parameters from a JSON file in the cache directory. This is what occurs in a typical simulation run.

If the JSON file is not found, it loads the simulation parameters from data directories using the provided sim_id.

If specs_file is provided, it manually generates params dictionary.

network_configs.connections.conn_utils.gaussian(x, N, mean, stdv)

1D Gaussian function.

Parameters:
  • x (float) – The input value for which the Gaussian function is evaluated.

  • N (float) – The amplitude of the Gaussian function.

  • mean (float) – The mean (center) of the Gaussian function.

  • stdv (float) – The standard deviation (spread or width) of the Gaussian function.

Returns:

The value of the Gaussian function at x.

Return type:

float

network_configs.connections.conn_utils.gaussian_2D(x, y, x_mean, y_mean, stdev, N)

2D Gaussian function.

Parameters:
  • x (float) – The x-coordinate at which to evaluate the Gaussian.

  • y (float) – The y-coordinate at which to evaluate the Gaussian.

  • x_mean (float) – The mean of the Gaussian in the x-direction.

  • y_mean (float) – The mean of the Gaussian in the y-direction.

  • stdev (float) – The standard deviation of the Gaussian in both x and y directions.

  • N (float) – The amplitude of the Gaussian.

Returns:

The value of the 2D Gaussian function at the given (x, y) coordinates.

Return type:

float

network_configs.connections.conn_utils.signed_arc_length(angle1, angle2)

Compute the signed arc length between two angles.

Parameters:
  • angle1 (float) – The first angle (in degrees or radians).

  • angle2 (float) – The second angle (in degrees or radians).

  • radians (bool) – Set to True if the angles are in radians, False if in degrees.

Returns:

The signed arc length.

Return type:

float

network_configs.connections.conn_utils.unsigned_arc_length(angle1, angle2)

Compute the unsigned arc length between two angles.

Parameters:
  • angle1 (float) – The first angle (in degrees or radians).

  • angle2 (float) – The second angle (in degrees or radians).

  • radians (bool) – Set to True if the angles are in radians, False if in degrees.

Returns:

The unsigned arc length.

Return type:

float