Reputation: 135
I have my data stored in structures regarding recording from neurons. Neuronal spikes are stored in a logical array where a spike is 1 and no spike is 0.
spike = <1x50 logical>
spike = [1 0 0 0 1 0 0 1 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 0 1 1 0 0 ...]
What I have to do is to convert these spikes into smooth curve signal using Gaussian filter.
I have the following function for smoothing:
function z = spikes(x, winWidth)
% places a Gaussian centered on every spike
% if x is matrix, then perform on the columns
winWidth = round(winWidth);
if winWidth == 0
y = [0 1 0];
w = 1;
else
w = winWidth * 5;
t = -w : w;
y = normpdf(t,0,winWidth);
end
if isvector(x)
z = conv(x,y);
z = z(w+1 : end);
z = z(1 : length(x));
else
z = zeros(size(x));
for i = 1 : size(x,2)
z1 = conv(x(:,i),y);
z1 = z1(w+1 : end);
z1 = z1(1 : length(x));
z(:,i) = z1;
end
end
end
I was just wondering how can I make nerve signals from spikes that are like the above logical array?
PS: I am very lost and my answers are not understandable to be posted here.
Upvotes: 1
Views: 126
Reputation: 109
If I understood correctly you just have to increase the sampling frequency and convolve. Since your original array corresponds to a signal with sampling frequency of one spike, if you want to increase the resolution of your spikes, you need to artificially introduce more data points between the spikes.
spike = [1 0 0 0 1 0 0 1 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 0 1 1 0 0];
![n_samples = numel(spike);
resampling_f = 50;
new_signal = zeros(n_samples*resampling_f,1);
spikes_ind = find(spike);
new_signal((spikes_ind-1)*50+round(resampling_f/2)) = 1;
%here you can use the spikes function you defined
winWidth = 10;
w = winWidth * 5;
t = -w : w;
kernel = normpdf(t,0,winWidth);
spikes_sample = conv(x,kernel);
figure, hold on
subplot(1,2,1), hold on
plot(new_signal)
subplot(1,2,2), hold on
plot(spikes_sample)][1]
Upvotes: 2