DistanceProfile#
- class braintools.init.DistanceProfile#
Base class for distance-dependent connectivity profiles.
Distance profiles define how connection probability and weight strength vary with spatial distance between neurons. DistanceProfile supports composition through arithmetic operations and functional transformations, enabling the creation of complex distance-dependent patterns from simple ones.
Supported Operations#
Arithmetic: +, -, *, / (element-wise operations with other profiles, scalars, or quantities)
Composition: | (pipe operator for chaining transformations)
Transformations: .clip(), .apply()
Examples
>>> import numpy as np >>> import brainunit as u >>> from braintools.init import DistanceProfile >>> >>> class LinearDecayProfile(DistanceProfile): ... def __init__(self, max_dist): ... self.max_dist = max_dist ... ... def probability(self, distances): ... return np.maximum(0, 1 - distances / self.max_dist) ... ... def weight_scaling(self, distances): ... return self.probability(distances)
Composition Examples#
>>> from braintools.init import GaussianProfile, ExponentialProfile >>> >>> # Scale a Gaussian profile >>> profile = GaussianProfile(50.0 * u.um) * 0.5 >>> >>> # Combine two profiles >>> combined = GaussianProfile(50.0 * u.um) + ExponentialProfile(100.0 * u.um) * 0.3 >>> >>> # Clip profile values >>> clipped_profile = GaussianProfile(50.0 * u.um).clip(0.1, 0.9) >>> >>> # Apply custom function >>> transformed = GaussianProfile(50.0 * u.um).apply(lambda x: x ** 2) >>> >>> # Chain transformations with pipe operator >>> chained = GaussianProfile(50.0 * u.um) | (lambda x: x * 2) | (lambda x: np.minimum(x, 1.0))