A better method to implement the alpha synapse function in MATLAB

I have implemented a leaky integrate and fire neuron system that gives output in the form of an alpha function `alpha = t/tau * exp(1 - (t/tau))`. However, the piece of code that I use to implement it takes up atleast 80% of the runtime (approximately 4s out of the total 5s). During the course of the program this prt gets called at least 30000 times while the `computealphasynapseoutput` function gets called at least 1.5 million times. So I want to reduce the runtime of this part. I have tried using `arrayfun` to implement it but that takes up a lot more time than this.
Can anyone please suggest a more efficient implementation for this code??
To implement the alpha synapse I used the following piece of code:
% Get the identity of the currently active neurons
idAllActiveNeuron = idAllActiveNeuron > 0;
if any(idAllActiveNeuron) % Only run if atleast one neuron is active
for iActiveNeuron = find(idAllActiveNeuron).' % run for each active neuron
%%synapticOutputArray stores the synaptic output for each neuron for each time instant
%%iIntegration is the time instant
%%spikeTimesArray is a cell array that is composed of spike times for
% each neuron. So if I have 5 neurons and neuron 4 spikes twice
% while neuron 5 spikes once, spikeTimesArray would be something
% like {[], [], [], [0.0023, 0.0034], [0.0675]}
%%integrationInstant would be a time value like 0.0810
%%tau_syn stores the value of tau for each neuron
synapticOutputArray(iActiveNeuron, iIntegration) = computealphasynapseoutput(spikeTimesArray{iActiveNeuron}, integrationInstant, tau_syn(iActiveNeuron));
end % iActiveNeuron
end
The function `computealphasynapse` is implemented as follows:
function synapticOutput = computealphasynapseoutput(firingTime, integrationInstant, tauSyn)
%%COMPUTEALPHASYNAPSEOUTPUT Calculates the synaptic output over all
%previous spikes of the neuron at a particular time instant using the
%alpha synapse function
%
% Usage:
% synapticOutput = computealphasynapseoutput(firingTime, integrationInstant, tauSyn)
%
% Inputs:
% firingTime: vector of previous firing times (in seconds)
% integrationInstant: current integration time instant (in seconds)
% tauSyn: synaptic time constant of the neuron (in seconds)
%
% Output:
% synapticOutput: Synaptic output of the neuron at current time summed
% over all firing instances
%
% Calculate the time difference of firing from current time
timeDifference = (integrationInstant - firingTime) / tauSyn;
% Calculate and sum the synaptic output for each spike
synapticOutput = sum(timeDifference .* exp(1 - timeDifference));
end % computealphasynapseoutput

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Neural Simulation 的更多信息

提问:

2017-5-22

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by