Distance dependent structural plasticity
Description
This pull request introduces new functionality to handle distance-dependent connection probabilities in the SPManager class. The following methods have been added or modified:
New Features
-
gather_global_positions_and_ids()
Collects and verifies global neuron positions and IDs.
Ensures that neurons are spatially distributed, raising an error if positions are undefined while distance dependency is enabled. -
gaussian_kernel()
Computes a probability based on the Gaussian distance kernel between two neuron positions. -
build_probability_list()
Constructs a probability list for all neuron pairs based on their spatial positions.
Supports caching for efficient repeated lookups. -
get_neuron_pair_index()
Maps two neuron IDs to a unique index for accessing pair-specific probabilities in theprobability_list. -
global_shuffle_spatial()
Implements distance-dependent shuffling for pairing neurons based on spatial proximity and probability. -
roulette_wheel_selection()
Performs a weighted random selection of post-synaptic neurons based on precomputed probabilities.
Modified Methods
-
enable_structural_plasticity()
Integrates calls togather_global_positions_and_ids()andbuild_problist()when distance dependency is enabled.
Distance-Dependent Features
-
Enable Distance Dependency
Distance dependency can be enabled by settingstructural_plasticity_gaussian_kernel_sigmato a positive value. This parameter controls the width of the Gaussian kernel used for connection probabilities. Higher values result in reduced sensitivity to distance, making distant neurons more likely to connect. -
Caching Connection Probabilities
Ifstructural_plasticity_cache_probabilitiesis set totrue, connection probabilities will be precomputed and cached. This can improve performance, particularly in long-running simulations.
Testing
The following tests have been added to validate the new functionality:
C++ Tests:
-
test_gaussian_kernel
Tests Gaussian kernel computations for various distances and sigma values. -
test_get_neuron_pair_index
Confirms correct mapping of neuron pairs to unique indices. -
test_global_shuffle_spatial
Validates spatially aware shuffling logic.
Ensures connections favor spatial proximity and prevent self-connections.
Python Tests:
-
test_distance_dependent_without_positions()
Ensures an error is raised when distance dependency is enabled, but positions are not provided. -
test_gaussian_kernel()
Tests probability computation using Gaussian distance dependency. -
test_probability_list_building()
Verifies the correct initialization and population of the probability list. -
test_roulette_wheel_selection()
Confirms that weighted random selection behaves as expected. -
test_structural_plasticity_with_positions()
Ensures structural plasticity works correctly when neuron positions are defined. -
test_synapse_creation_distance_dependent()
Validates distance-dependent synapse formation using position data.
Related Issue:
Incorporate Distance-Dependent Connection Probability in Structural Plasticity Module #3209
Looks good. We might reduce some overhead by passing a pointer to the relevant element in the global_position vector along with its dimension directly to the gaussianKernel function instead of creating and passing subvectors on each iteration, but for a small number of neurons it would not be noticeable
@alpinangu ,@jhnnsnk Thank you so much for your feedback! I'm working on the suggested changes and the performance comparisons.
@FinnBurkhardt could you have a quick look at the CI messages, probably it's only merge master…
I’ve removed the caching for now. It needs more work and benchmarking, so I think it should go in a separate PR. I’ll provide a performance comparison with and without the Gaussian kernel shortly.