-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoffsetnew.m
More file actions
80 lines (64 loc) · 3.41 KB
/
Copy pathoffsetnew.m
File metadata and controls
80 lines (64 loc) · 3.41 KB
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
function offsetfiring = offsetnew(AN, channel)
% offsetfiring: creates a 2d array of offset firing times in a singl channel
% new version of offset - and perhaps onset later as well.
% LSS 6 April 2014.
%
% The times below should depend partly on the period of the channel.
period = 1.0/AN.cf(channel) ;
exc_risetime = 0.01 ;
exc_staytime = max(0.005, 2* period) ;
exc_falltime = 0.001 ;
excmaxvalue = 1.0 ;
inh_risetime = 0.0005 ;
inh_staytime = max(0.004, 2 * period) ;
inh_falltime = 0.001 ;
inhmaxvalue = 0 ;
excactivitylimiter = 2.0 ;
% channel =42 ;
% offset synaptic responses.
% shape for excitatory signal
excduration = ceil(exc_risetime* AN.Fs) + ceil(exc_staytime * AN.Fs) + ceil(exc_falltime * AN.Fs );
excvector = zeros(1, excduration) ;
% fill excvector
excvector(1:ceil(exc_risetime *AN.Fs)) = (1:ceil(exc_risetime *AN.Fs))/(ceil(exc_risetime *AN.Fs) * excmaxvalue) ;
excvector(ceil(exc_risetime *AN.Fs)+1 :ceil(exc_risetime *AN.Fs) + ceil(exc_staytime * AN.Fs) + 1) = excmaxvalue ;
excvector(ceil(exc_risetime *AN.Fs) + ceil(exc_staytime * AN.Fs) +1 : (ceil(exc_risetime * AN.Fs) + ceil(exc_staytime * AN.Fs) + ceil(exc_falltime * AN.Fs ))) = ...
(ceil(exc_falltime*AN.Fs):-1:1)/ ...
(ceil(exc_falltime*AN.Fs) * excmaxvalue);
% shape for inhibitory signal
inhduration = ceil(inh_risetime* AN.Fs) + ceil(inh_staytime * AN.Fs) + ceil(inh_falltime * AN.Fs );
inhvector = zeros(1, inhduration) ;
inhvector(1:ceil(inh_risetime *AN.Fs)) = ((ceil(inh_risetime *AN.Fs):-1:1)-1) /(ceil(inh_risetime *AN.Fs) * (1-inhmaxvalue)) ;
inhvector(ceil(inh_risetime *AN.Fs) +1 : ceil(inh_risetime *AN.Fs) + ceil(inh_staytime * AN.Fs)) = 0 ;
inhvector(ceil(inh_risetime *AN.Fs) + ceil(inh_staytime * AN.Fs)+ 1: (ceil(inh_risetime *AN.Fs) + ceil(inh_staytime * AN.Fs) + ceil(inh_falltime *AN.Fs))) = ...
(1:ceil(inh_falltime *AN.Fs)) /(ceil(inh_falltime *AN.Fs) *(1-inhmaxvalue)) ;
%offset calculation
% for each spike in channel, add the excvector in
% initialise first
activityexc = zeros(AN.iterations, AN.datalength+length(excvector)) ;
activityshunt = ones(AN.iterations, AN.datalength+length(inhvector)) ;
inspikes = zeros(AN.iterations, AN.datalength+length(excvector)) ;
% fill in for each spike
for spikeno = 1:length(AN.signal{channel})
% for debug really
for sno = 1:AN.signal{channel}(2, spikeno)
inspikes(sno, AN.signal{channel}(1,spikeno)) = 1 ;
activityexc(sno,AN.signal{channel}(1,spikeno) :AN.signal{channel}(1,spikeno) + excduration - 1) ...
= activityexc(sno,AN.signal{channel}(1,spikeno) :AN.signal{channel}(1,spikeno) + excduration - 1) + ...
excvector ;
activityshunt(sno,AN.signal{channel}(1,spikeno) :AN.signal{channel}(1,spikeno) + inhduration - 1) ...
= min(activityshunt(sno,AN.signal{channel}(1,spikeno) :AN.signal{channel}(1,spikeno) + inhduration - 1), inhvector) ;
% = activityshunt(sno,AN.signal{channel}(1,spikeno) :AN.signal{channel}(1,spikeno) + inhduration - 1) - ...
end
end
% nonlinear capping of values at each synapse
% make activityexc peak at 1, and activityshunt have lowest value of 0.
activityexc(activityexc > excactivitylimiter) = excactivitylimiter ;
activityshunt(activityshunt < 0) = 0 ;
% ensure that output has sampe length as input
activityexc = activityexc(:, 1:AN.datalength) ;
activityshunt = activityshunt(:, 1:AN.datalength) ;
% dot-product of shunt and excitation
activity = activityexc .* activityshunt ;
offsetfiring = (activity >= 1) ;
end