skneuromsi.utils.neural_tools module
Tools for scikit-neuromsi neural models.
- skneuromsi.utils.neural_tools.calculate_neural_distance(neurons, position_j, position_k)[source]
Computes the distance between the pre-synaptic and post-synaptic neurons.
Designed for neurons encoding an external 1D space. It assumes that neurons are connected in a circular structure so that every neuron receives the same number of lateral connections.
- Parameters:
neurons (int) – The number of neurons.
position_j (float) – Position of the post-synaptic neuron
position_k (float) – Position of the pre-synaptic neuron
- Returns:
Distance between the two neurons in model units.
- Return type:
numpy.float64
- skneuromsi.utils.neural_tools.calculate_lateral_synapses(neurons, excitation_loc, inhibition_loc, excitation_scale, inhibition_scale, dtype=<class 'numpy.float32'>)[source]
Computes the values of lateral synapses.
Designed for a group of recurrently connected neurons following a “Mexican hat” distribution (a central excitatory zone surrounded by an inhibitory annulus) calculated as a substraction of two Gaussians.
- Parameters:
neurons (int) – The number of neurons.
excitation_loc (float) – Loc of the excitatory Gaussian function.
inhibition_loc (float) – Loc of the inhibitory Gaussian function.
excitation_scale (float) – Scale of the excitatory Gaussian function.
inhibition_scale (float) – Scale of the excitatory Gaussian function.
dtype (numpy class) – Type of the array to store the values.
- Returns:
The values of lateral synapses.
- Return type:
numpy.array
- skneuromsi.utils.neural_tools.calculate_inter_areal_synapses(neurons, weight, sigma, dtype=<class 'numpy.float32'>)[source]
Computes the values of inter-areal synapses.
Designed for two connected group of neurons following a Gaussian function. It assumes symmetrical connectivity and the same number of neurons in both groups.
- Parameters:
neurons (int) – The number of neurons in each group.
weight (float) – The highest level of synaptic efficacy.
sigma (float) – The width of the Gaussian function.
dtype (numpy class) – Type of the array to store the values.
- Returns:
The value of inter-areal synapses.
- Return type:
numpy.array
- skneuromsi.utils.neural_tools.prune_synapses(synapses_weight_matrix, pruning_threshold)[source]
Prunes neural connections.
Pruning is implemented by assigning zero to those synapses values below a given threshold.
- Parameters:
synapses_weight_matrix (numpy.array) – Array containing the values of the synapses.
pruning_threshold (float) – Threshold value of the pruning procedure.
- Returns:
The value of the external stimuli for each neuron.
- Return type:
numpy.array
- skneuromsi.utils.neural_tools.calculate_stimuli_input(neurons, intensity, *, scale, loc, dtype=<class 'numpy.float32'>)[source]
Computes the values of stimuli as a spatial Gaussian function.
The Gaussian accounts for the uncertainty in the detection of stimuli.
- Parameters:
neurons (int) – The number of neurons to be stimulated.
intensity (float) – The strength of the external stimulus.
scale (float) – Scale of the Gaussian function.
loc (float) – Loc of the Gaussian function.
dtype (numpy class) – Type of the array to store the values.
- Returns:
The value of the external stimuli for each neuron.
- Return type:
numpy.array
- skneuromsi.utils.neural_tools.create_unimodal_stimuli_matrix(neurons, stimuli, stimuli_duration, onset, simulation_length, time_res, dt, stimuli_n=1, soa=None, dtype=<class 'numpy.float32'>)[source]
Creates the matrix of a unimodal stimuli for each neuron at each timepoint.
Supports multiple stimuli.
- Parameters:
neurons (int) – The number of neurons to be stimulated.
stimuli (numpy.array) – Array with the values of the stimuli for each neuron.
stimuli_duration (float) – Duration of the stimuli in model time units.
onset (float) – Onset of the unimodal stimuli in model time units.
simulation_length (float) – Total duration of the model run in model time units.
time_res (float) – Temporal resolution of the model.
dt (float) – Model integrator dt.
stimuli_n (int) – Number of unimodal stimuli.
soa (int) – Stimuli onset asynchrony. Relevant for more than 1 stimuli. Must be higher than stimulus_duration.
dtype (numpy class) – Type of the array to store the values.
- Returns:
The value of the external stimuli for each neuron.
- Return type:
numpy.array
- Raises:
ValueError – If the total duration of all stimuli plus the total duration of the inter-stimulus intervals (i.e., stimuli_duration * stimuli_n + soa * (stimuli_n - 1)) exceeds the simulation_length.
- skneuromsi.utils.neural_tools.compute_latency(time, latency)[source]
Computes the latency-adjusted time in the simulation.
Latency is computed by subtracting the given latency from the current time, ensuring that the result is not negative.
- Parameters:
time (float) – The current time in the simulation.
latency (float) – The latency to subtract from the current time.
- Returns:
The latency-adjusted time. If the result of the subtraction is negative, returns 0 instead.
- Return type:
float
Notes
This method is used to adjust the time for processing delays in the simulation. It ensures that the computed latency does not result in a negative time value, which could be invalid for certain operations.