Skip to content

Commit a49e9b0

Browse files
committed
adding matlab files
1 parent 9173c8a commit a49e9b0

5 files changed

+604
-7
lines changed

README.md

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
1-
# spikeNetwork
2-
Network reconstruction from spiking events
1+
# Data-driven Perception of Neuron Point Process with Unknown Unknowns
32

4-
For using the code, cite the following paper:
5-
Ruochen Yang, Gaurav Gupta, and Paul Bogdan, "Data-driven Perception of Neuron Point Process with Unknown Unknowns", arXiv:1811.00688
3+
Ruochen Yang<sup>&#42;</sup>, Gaurav Gupta<sup>&#42;</sup>, and Paul Bogdan. In ICCPS 2019. [arXiv:1811.00688](https://arxiv.org/abs/1811.00688)
64

7-
Bibtex:
8-
@article{DBLP:journals/corr/abs-1811-00688,
5+
(<sup>&#42;</sup> equal contribution authors)
6+
7+
**Network reconstruction from spiking events**
8+
9+
![Image](http://scf.usc.edu/~ggaurav/pics/spikeNet.png)
10+
11+
**Language:** The code package is available in Python and Matlab
12+
13+
## Citation
14+
For using the code in your work, please consider citing
15+
```
16+
@article{YangGuptaSpike2019,
917
author = {Ruochen Yang and
1018
Gaurav Gupta and
1119
Paul Bogdan},
12-
title = {Data-driven Perception of Neuron Point Process with Unknown Unknowns},
20+
title = {Data-driven Perception of Neuron Point
21+
Process with Unknown Unknowns},
1322
journal = {CoRR},
1423
volume = {abs/1811.00688},
1524
year = {2018},
1625
archivePrefix = {arXiv},
1726
eprint = {1811.00688},
1827
}
28+
```

matlab/getSimulatedSpikeData.m

+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
clear
2+
% network size
3+
C = 6; % known neuron num
4+
I = 2; % unknown neuron num
5+
Q = 50; % intrinsic history length (autoregression)
6+
R = 5; % extrinsic history length
7+
M = 5; % unknown history length
8+
K = 10000; % spiking activity total time length
9+
tau = 0.05; % time interval
10+
11+
% assign parameters
12+
% alpha = [2,1,3,2,2,1]*2; % baseline
13+
alpha = [3.5,2.4,2,3,2.8,2.5]; % baseline: spontaneous spiking rate
14+
epsi = zeros(C,Q); % intrinsic paramter
15+
beta = zeros(C,C,R); % extrinsic paramter
16+
gammaUU = zeros(C,I,M); % unknown paramter
17+
18+
19+
% intrinsic para
20+
x = 1:Q;
21+
z_epsi = [2,1.9,2.5,1.5,2,1.8];
22+
for c=1:C
23+
epsi(c,:) = -sin(x/z_epsi(c))./(x/z_epsi(c));
24+
end
25+
% % figure;
26+
% % for c = 1:C
27+
% % subplot(6,1,c);
28+
% % stem(epsi(c,:));
29+
% % end
30+
31+
% extrinsic para
32+
pos_beta = [0,0,0,0,0,0;
33+
1,0,1,0,0,0;
34+
-1,0,0,0,0,0;
35+
1,0,0,0,1,-1;
36+
1,0,0,-1,0,1;
37+
-1,0,0,1,-1,0];
38+
z_beta = [0,0,0,0,0,0;
39+
1,0,0.9,0,0,0;
40+
0.8,0,0,0,0,0;
41+
0.9,0,0,0,0.7,0.6;
42+
0.8,0,0,0.5,0,0.7;
43+
0.9,0,0,0.6,0.5,0];
44+
for c = 1:C
45+
for c1 = 1:C
46+
for r = 1:R
47+
beta(c,c1,r) = pos_beta(c,c1)*exp((-z_beta(c,c1))*(r));
48+
end
49+
end
50+
end
51+
52+
% unknown para
53+
pos_gamma = [1,1,1,1;
54+
0,1,0,0;
55+
1,0,1,0;
56+
1,1,1,0;
57+
0,1,0,1;
58+
1,0,1,1];
59+
z_gamma = [0.3,0.5,0.6,0.2;
60+
0,1,0,0;
61+
0.8,0,0.4,0;
62+
0,0,0.9,0;
63+
0,0.8,0,0.6;
64+
0.2,0,0.8,0.4];
65+
for c = 1:C
66+
for i = 1:I
67+
for m = 1:M
68+
gammaUU(c,i,m) = pos_gamma(c,i)*exp((-z_gamma(c,i))*(m));
69+
end
70+
end
71+
end
72+
% % figure;
73+
% % for c=1:C
74+
% % subplot(C,1,c);
75+
% % stem(reshape((squeeze(gammaUU(c,:,:))).',[I*M,1]));
76+
% % end
77+
78+
% generate the spikes
79+
80+
loggamma_a = 1;
81+
loggamma_b = 50;
82+
shiftLogGamma = -3.9;
83+
84+
% x=-5:0.05:5;
85+
% shift mean by 2 to have distribution centered at 0
86+
flg = @(x) (exp(loggamma_b*(x-shiftLogGamma)).*exp(-exp(x-shiftLogGamma)/loggamma_a))/(loggamma_a^loggamma_b*gamma(loggamma_b));
87+
% int = integral(flg, -10, 10);
88+
89+
nsamples = K*I;
90+
delta = .5;
91+
proppdf = @(x,y) unifpdf(y-x,-delta,delta);
92+
proprnd = @(x) x + rand*2*delta - delta;
93+
dU = mhsample(1, nsamples, 'pdf', flg, 'proprnd',proprnd, 'proppdf',proppdf);
94+
dU = reshape(dU, I, K);
95+
96+
% U=gamrnd(dU_alpha,1/dU_beta,[I,K+1]);
97+
% dU = (diff(U'))';
98+
% log-gamma distribution
99+
%%% ????
100+
101+
102+
dN = zeros(C,K); % dN is a binary sequence
103+
dN(:,1) = [0,1,0,0,1,0];
104+
105+
lambda = zeros(C,K); % conditional intensity function
106+
107+
for k = 2:K
108+
for c = 1:C
109+
110+
in = dot(epsi(c,1:min(k-1,Q)),fliplr(dN(c,k-min(k-1,Q):k-1)));
111+
if(k==2)
112+
ex = sum(dot(squeeze(beta(:,c,1:min(k-1,R))),fliplr(dN(:,k-min(k-1,R):k-1))));%%%%
113+
un = sum(dot(squeeze(gammaUU(c,:,1:min(k-1,M))),fliplr(dU(:,k-min(k-1,M):k-1))));%%%%
114+
else
115+
ex = sum(dot(squeeze(beta(:,c,1:min(k-1,R))),fliplr(dN(:,k-min(k-1,R):k-1)),2));%%%%
116+
un = sum(dot(squeeze(gammaUU(c,:,1:min(k-1,M))),fliplr(dU(:,k-min(k-1,M):k-1))),2);%%%%
117+
end
118+
119+
lambda(c,k) = exp(alpha(c) + in + ex + un);
120+
121+
end
122+
123+
for i=1:C
124+
u = rand(1);
125+
if(u<=lambda(i,k)*tau)
126+
dN(i,k) = 1;
127+
else
128+
dN(i,k) = 0;
129+
end
130+
end
131+
132+
end
133+
134+
% % % plot
135+
% figure;
136+
% for i=1:C
137+
% subplot(C,1,i);
138+
% plot(1:K,lambda(i,1:K));
139+
% end
140+
% figure;
141+
% for i=1:C
142+
% subplot(C,1,i);
143+
% spikeF = stem(1:K,dN(i,1:K));
144+
% set(spikeF, 'Marker', 'none');
145+
% end
146+
% figure;
147+
% for i=1:C
148+
% subplot(C,1,i);
149+
% hist(dN(i,1:K));
150+
% end
151+
saveStr = sprintf('neuronSpikeSim_wUU_logGamma_K_%d.mat', K);
152+
save(saveStr, 'dN', 'Q', 'R', 'M', 'I', 'tau', 'gammaUU');

0 commit comments

Comments
 (0)