forgotten changes

This commit is contained in:
Jan Grewe 2015-10-05 10:58:22 +02:00
parent 38d384896d
commit 02bbb62e4d
3 changed files with 35 additions and 16 deletions

View File

@ -1,16 +1,15 @@
load('ampullary.mat')
load('electroreceptor_stimulus.mat')
sample_rate = 20000; % Hz
max_time = 0;
for i = 1:size(times,2)
max_time = max([max_time, max(times{i})]);
end
%% create PSTH on the basis of the interspike intervals
max_time = 10;
%% create instantaneous firing rate on the basis of the interspike intervals
t = times{1};
firing_rate = [0 1./diff(t)];
start = 1;
resp = zeros(1, round(max_time * sample_rate));
response = zeros(1, round(max_time * sample_rate));
for i = 1:length(t)
resp(1,start:round(t(i) * sample_rate)) = firing_rate(i);
response(1,start:round(t(i) * sample_rate)) = firing_rate(i);
start = round(t(i) * sample_rate);
end
fig = figure();
@ -18,7 +17,7 @@ set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperSize', [11.7 9.0]);
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
set(gcf,'Color', 'white')
plot((1/sample_rate:1/sample_rate:max_time), resp)
plot((1/sample_rate:1/sample_rate:max_time), response)
xlabel('time [s]')
ylabel('firing rate [Hz]')
ylim([0 300])
@ -26,6 +25,7 @@ xlim([0 1])
title('instanataneous firing rate')
saveas(fig, 'isi.pdf','pdf')
%% create PSTH using the binning method
bin_width = 0.0125; % s
edges = 0:bin_width:max_time;
@ -39,22 +39,33 @@ for i = 1:size(times,2)
firing_rate = firing_rate + (n / bin_width / size(times,2));
end
end
response = zeros(1, round(max_time * sample_rate));
start_index = 1;
for i = 1:length(edges)
end_index = round(edges(i) * sample_rate);
response(start_index:end_index) = firing_rate(i);
start_index = end_index +1;
end
fig = figure();
set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperSize', [11.7 9.0]);
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
set(gcf,'Color', 'white')
plot(time, firing_rate)
plot(0:1/sample_rate:max_time-1/sample_rate, response)
ylim([0 300])
xlim([0 1])
xlabel('time [s]')
ylabel('firing rate [Hz]')
title('binning method')
saveas(fig, 'binning.pdf', 'pdf')
%% create PSTH using the kernel-convolution method
kernel_width = 0.0125; %s
binary_spikes = zeros(size(times,2), round(max_time*sample_rate));
resps = zeros(size(binary_spikes));
responses = zeros(size(binary_spikes));
window = hann(kernel_width*sample_rate,'symmetric');
window = window/sum(window);
@ -65,16 +76,25 @@ for i = 1:size(times,2)
temp(1) = 1;
end
binary_spikes(i, temp) = 1;
resps(i,:) = conv(binary_spikes(i,:), window, 'same')*sample_rate;
responses(i,:) = conv(binary_spikes(i,:), window, 'same')*sample_rate;
end
fig = figure();
set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperSize', [11.7 9.0]);
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
set(gcf,'Color', 'white')
plot((1/sample_rate:1/sample_rate:max_time), mean(resps,1))
subplot(2,1,1)
plot((1/sample_rate:1/sample_rate:max_time), mean(responses,1))
ylim([0 300])
xlim([0 1])
xlabel('time [s]')
ylabel('firing rate [Hz]')
title('convolution method')
subplot(2,1,2)
plot(stimulus_strong(:,1), stimulus_strong(:,2))
ylim([-1 1])
xlim([0 1])
xlabel('time [s]')
ylabel('stimulus intensity [arb. units]')

View File

@ -76,7 +76,7 @@ def load_spike_data(cell, max_time):
if data[0][2][-1]/1000 < max_time:
return None
else:
return data[0][2][data[0][2] <= max_time*1000]
return data[0][2][data[0][2] <= max_time*1000]/1000
if __name__ == '__main__':
@ -103,12 +103,11 @@ if __name__ == '__main__':
index += 1
continue
spikes = load_spike_data(cell, 20)
if spikes is None:
print 'not enough baseline spikes'
index += 1
continue
eod_data = load_eod_data(cell, 20, 200000)
eod_data = load_eod_data(cell, 20, 20000)
name = cell.split('/')[-1] + '_baseline.mat'
sp.savemat(name, {'spike_times':spikes, 'eod':eod_data})
found += 1

View File

@ -38,7 +38,7 @@ plot(x,y,'ok');
%%
t = linspace(-5,5,100);
param0 = [0,0];
param0 = [1,1];
step = 0.01;
param = param0;