-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_FR.m
85 lines (68 loc) · 1.97 KB
/
filter_FR.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function g = filter_FR(spk,type,sampling,param1,param2)
%function g = filter_FR(spk,type,sampling,param1,param2)
%
% type='gauss': smooth signal spk with gaussian of standard deviation sigma and remove
% spurious values at the borders
%
% type='epsp': use a model of epsp temporal dynamic to filter the spiking
% activity and avoid possible problem of non-causal filtering introduced by
% the gausian filtering.
%
% Corentin University of Pittsburgh, 11/12/2016
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
debug=0;
spk = spk(:);
if debug
figsig=figure;subplot(1,2,2);hold on
plot(spk*100)
end;
switch type
case 'gauss'
%gaussian filtering
%gaussian window
sigma=param1*sampling/1000;
len = 2*round(sigma*4);
f = gausswin(len,len/sigma);
f = f/sum(f);
if debug
figure(figsig);subplot(1,2,1);hold on
plot(f)
end
%other definition of gaussian window
%l=[-len/2+1:len/2];
%sigma=sigma/2;
%f = (1/(sigma*sqrt(2*pi)))*exp((-l.^2)/(2*sigma^2));
case 'epsp'
%epsp
%tau1 = 2;
%tau2 = 10/9;
%%epspf = exp(-f(f>=0)/tau1)-exp(-f(f>=0)/tau2);
t=[1:150];
tau_g=param1;
tau_d=param2;
f = (1-exp(-t/tau_g)).*exp(-t/tau_d);
f = f/sum(f);
%centering f
f2 = [zeros(1,floor(1*length(f))),f];
f=f2';
len=length(f);
if debug
figure(figsig);subplot(1,2,1);hold on;
plot(1:length(f),f)
end
end
%convolution
g = conv(spk,f);
% %taking care of borders %does not work
% c = cumsum(f);
% g(1:length(c)) = g(1:length(c))./c;
% g(end-length(c)+1:end) = g(end-length(c)+1:end) ./ flipud(c);
%taking central part of convolved signal
g = g(len/2+1:end-len/2+1);
%sampling
g=sampling * g;
if debug
figure(figsig);subplot(1,2,2);hold on;
plot(g)
pause
end