-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFigureBatGrid.m
319 lines (255 loc) · 12.2 KB
/
FigureBatGrid.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
% bat-grid--like grid cell activity from oscillatory interference models
% eric zilli - 20111108 - v1.0
% Columns: Burgess et al. 2007 Burgess 2008 Hasselmo 2008
% Rows:
% Baseline = 5 [rate map] [ISIs]
% Baseline = 0.5
% Baseline = 0
caption = {'With a 5 Hz baseline, most',...
'(but not all) temporal',...
'interference models show grid',...
'cell firing rate modulation at 5 Hz.',...
'With the precession mechanisms',...
'described in these papers, the',...
'baseline can go low enough that',...
'theta modulation disappears while',...
'baseline modulation remains.',...
'These even work with a baseline',...
'of 0 Hz, which turns them into',...
'spatial interference models.'};
methods = {'200 s simulations. Hafting et al. 2005 trajectory. Unbiased autocorrelations. Gaussian smoothed rate maps, \sigma = 3.3 cm. For code/comments/questions: [email protected]. Eric Zilli.'};
% Create the figure we're making
widthOnPaper = 9;
heightOnPaper = 5;
% figure options:
set(0,'defaultAxesFontName', 'Arial')
set(0,'defaultTextFontName', 'Arial')
figure('units','inches','position',[1 1 widthOnPaper heightOnPaper],'color','w');
set(gcf, 'renderer', 'painter')
set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperSize', [widthOnPaper heightOnPaper]);
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperPosition', [0 0 widthOnPaper heightOnPaper]);
% Variables for positioning plots
leftMargin = 0.25;
bottomMargin = 0.1;
nCols = 6;
nRows = 3;
lefts = leftMargin + 0.77*(0:nCols-1)/nCols;
bottoms = bottomMargin + .8*(0:nRows-1)/nRows;
bottoms2 = 0.01 + bottomMargin + .8*(0:nRows-1)/nRows;
width = 0.55/nCols;
height = .7/nRows;
height2 = 0.2/nRows;
% figure options:
set(0,'defaultAxesFontName', 'Arial')
set(0,'defaultTextFontName', 'Arial')
% kernel to smooth rate maps:
gaussian = fspecial('gaussian',[5 5],1);
% length simulations will run (set separately inside each)
simdur = 200; % s
% X axis width for the autocorrelations
xcorrWidth = 0.5; % s
xcorrWidth2 = 5; % s
% Position (m) corresponding to each spatial bin of the rate map
posBins = linspace(-1,1,60);
% line spacing of caption text
linespacing = .33;
% Relative (to rows) y position of caption text
captionY = 0.7;
captionY2 = 0.8;
captionY3 = 0.65;
% Relative (to rate maps) position of reference names over top row of plots
referenceTextX = 1.2;
referenceTextY = -0.7;
%% Run Burgess et al. 2007 script, not bat mode, hide figures
[dt spikes occupancy spikeTimes] = BurgessEtAl2007_bat(0,0);
% Calculate and plot smoothed rate map
axes('position',[lefts(1) bottoms(3) width height]);
imagesc(posBins,posBins,conv2(gaussian,spikes./(occupancy+eps)));
axis square;
title('Rate map')
% Add labels
text(-0.85*diff(get(gca,'xlim'))+min(get(gca,'xlim')),0.5*diff(get(gca,'ylim'))+min(get(gca,'ylim')),{'Rodent','f = 5 Hz'},'fontsize',12,'horizontalalignment','right')
text(referenceTextX*diff(get(gca,'xlim'))+min(get(gca,'xlim')),referenceTextY*diff(get(gca,'ylim'))+min(get(gca,'ylim')),{'Burgess et al. 2007'},'fontsize',11,'horizontalalignment','center','verticalalignment','middle')
% Add caption
for ind=1:4
text(-0.25*diff(get(gca,'xlim'))+min(get(gca,'xlim')),linespacing*ind-captionY*diff(get(gca,'ylim'))+min(get(gca,'ylim')),caption{ind},'fontsize',9,'horizontalalignment','right')
end
% Calculate and plot first autocorrelation
axes('position',[lefts(2) bottoms2(3)+height2*2 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth:dt:xcorrWidth,xcorr(spikes,xcorrWidth/dt,'unbiased'))
title({'Grid cell spike','train autocorrelation'})
% Calculate and plot second autocorrelation
axes('position',[lefts(2) bottoms2(3)+height2/5 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth2:dt:xcorrWidth2,xcorr(spikes,xcorrWidth2/dt,'unbiased'))
%% Run Burgess et al. 2007 script, bat mode 1 (0.5 Hz baseline), hide figures
[dt spikes occupancy spikeTimes] = BurgessEtAl2007_bat(0,0,0.5);
% Calculate and plot smoothed rate map
axes('position',[lefts(1) bottoms(2) width height]);
imagesc(posBins,posBins,conv2(gaussian,spikes./(occupancy+eps)));
axis square;
% title('Rate map')
% Add caption
for ind=5:9
text(-0.25*diff(get(gca,'xlim'))+min(get(gca,'xlim')),linespacing*(ind-4)-captionY2*diff(get(gca,'ylim'))+min(get(gca,'ylim')),caption{ind},'fontsize',9,'horizontalalignment','right')
end
% Add labels
text(-0.85*diff(get(gca,'xlim'))+min(get(gca,'xlim')),0.5*diff(get(gca,'ylim'))+min(get(gca,'ylim')),{'Bat?','f = 0.5 Hz'},'fontsize',12,'horizontalalignment','right')
% Calculate and plot first autocorrelation
axes('position',[lefts(2) bottoms2(2)+height2*2 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth:dt:xcorrWidth,xcorr(spikes,xcorrWidth/dt,'unbiased'))
% title({'Grid cell spike','train autocorrelation'})
% Calculate and plot second autocorrelation
axes('position',[lefts(2) bottoms2(2)+height2/5 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth2:dt:xcorrWidth2,xcorr(spikes,xcorrWidth2/dt,'unbiased'))
% title({'Grid cell spike','train autocorrelation'})
%% Run Burgess et al. 2007 script, bat mode 2, hide figures
[dt spikes occupancy spikeTimes] = BurgessEtAl2007_bat(1,0);
% Calculate and plot smoothed rate map
axes('position',[lefts(1) bottoms(1) width height]);
imagesc(posBins,posBins,conv2(gaussian,spikes./(occupancy+eps)));
axis square;
xlabel('Position (m)')
% Add caption
for ind=10:12
text(-0.25*diff(get(gca,'xlim'))+min(get(gca,'xlim')),linespacing*(ind-9)-captionY3*diff(get(gca,'ylim'))+min(get(gca,'ylim')),caption{ind},'fontsize',9,'horizontalalignment','right')
end
% Add labels
text(-0.85*diff(get(gca,'xlim'))+min(get(gca,'xlim')),0.5*diff(get(gca,'ylim'))+min(get(gca,'ylim')),{'Bat?','f = 0 Hz'},'fontsize',12,'horizontalalignment','right')
% Calculate and plot first autocorrelation
axes('position',[lefts(2) bottoms2(1)+height2*2 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth:dt:xcorrWidth,xcorr(spikes,xcorrWidth/dt,'unbiased'))
% title({'Grid cell spike','train autocorrelation'})
% Calculate and plot second autocorrelation
axes('position',[lefts(2) bottoms2(1)+height2/5 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth2:dt:xcorrWidth2,xcorr(spikes,xcorrWidth2/dt,'unbiased'))
xlabel('Time (s)')
% "Methods" text
text(-4.1*diff(get(gca,'xlim'))+min(get(gca,'xlim')),-1.45*diff(get(gca,'ylim'))+min(get(gca,'ylim')),methods{1},'fontsize',8,'horizontalalignment','left')
%% Run Burgess 2008 script, not bat mode, hide figures
[dt spikes occupancy spikeTimes] = Burgess2008_bat(0,0);
% Calculate and plot smoothed rate map
axes('position',[lefts(3) bottoms(3) width height]);
imagesc(posBins,posBins,conv2(gaussian,spikes./(occupancy+eps)));
axis square;
title('Rate map')
% Add labels
text(referenceTextX*diff(get(gca,'xlim'))+min(get(gca,'xlim')),referenceTextY*diff(get(gca,'ylim'))+min(get(gca,'ylim')),{'Burgess 2008'},'fontsize',11,'horizontalalignment','center','verticalalignment','middle')
% Calculate and plot first autocorrelation
axes('position',[lefts(4) bottoms2(3)+height2*2 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth:dt:xcorrWidth,xcorr(spikes,xcorrWidth/dt,'unbiased'))
title({'Grid cell spike','train autocorrelation'})
% Calculate and plot second autocorrelation
axes('position',[lefts(4) bottoms2(3)+height2/5 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth2:dt:xcorrWidth2,xcorr(spikes,xcorrWidth2/dt,'unbiased'))
%% Run Burgess 2008 script, bat mode 1 (0.5 Hz baseline), hide figures
[dt spikes occupancy spikeTimes] = Burgess2008_bat(0,0,0.5);
% Calculate and plot smoothed rate map
axes('position',[lefts(3) bottoms(2) width height]);
imagesc(posBins,posBins,conv2(gaussian,spikes./(occupancy+eps)));
axis square;
% title('Rate map')
% Calculate and plot first autocorrelation
axes('position',[lefts(4) bottoms2(2)+height2*2 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth:dt:xcorrWidth,xcorr(spikes,xcorrWidth/dt,'unbiased'))
% title({'Grid cell spike','train autocorrelation'})
% Calculate and plot second autocorrelation
axes('position',[lefts(4) bottoms2(2)+height2/5 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth2:dt:xcorrWidth2,xcorr(spikes,xcorrWidth2/dt,'unbiased'))
%% Run Burgess 2008 script, bat mode 2, hide figures
[dt spikes occupancy spikeTimes] = Burgess2008_bat(1,0);
% Calculate and plot smoothed rate map
axes('position',[lefts(3) bottoms(1) width height]);
imagesc(posBins,posBins,conv2(gaussian,spikes./(occupancy+eps)));
axis square;
xlabel('Position (m)')
% Calculate and plot first autocorrelation
axes('position',[lefts(4) bottoms2(1)+height2*2 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth:dt:xcorrWidth,xcorr(spikes,xcorrWidth/dt,'unbiased'))
% title({'Grid cell spike','train autocorrelation'})
% Calculate and plot second autocorrelation
axes('position',[lefts(4) bottoms2(1)+height2/5 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth2:dt:xcorrWidth2,xcorr(spikes,xcorrWidth2/dt,'unbiased'))
xlabel('Time (s)')
%% Run Hasselmo 2008 script, not bat mode, hide figures
[dt spikes occupancy spikeTimes] = Hasselmo2008_bat(0,0);
% Calculate and plot smoothed rate map
axes('position',[lefts(5) bottoms(3) width height]);
imagesc(posBins,posBins,conv2(gaussian,spikes./(occupancy+eps)));
axis square;
title('Rate map')
% Add labels
text(referenceTextX*diff(get(gca,'xlim'))+min(get(gca,'xlim')),referenceTextY*diff(get(gca,'ylim'))+min(get(gca,'ylim')),{'Hasselmo 2008'},'fontsize',11,'horizontalalignment','center','verticalalignment','middle')
% Calculate and plot first autocorrelation
axes('position',[lefts(6) bottoms2(3)+height2*2 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth:dt:xcorrWidth,xcorr(spikes,xcorrWidth/dt,'unbiased'))
title({'Grid cell spike','train autocorrelation'})
% Calculate and plot second autocorrelation
axes('position',[lefts(6) bottoms2(3)+height2/5 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth2:dt:xcorrWidth2,xcorr(spikes,xcorrWidth2/dt,'unbiased'))
%% Run Hasselmo 2008 script, bat mode 1 (0.5 Hz baseline), hide figures
[dt spikes occupancy spikeTimes] = Hasselmo2008_bat(0,0,0.5);
% Calculate and plot smoothed rate map
axes('position',[lefts(5) bottoms(2) width height]);
imagesc(posBins,posBins,conv2(gaussian,spikes./(occupancy+eps)));
axis square;
% title('Rate map')
% Calculate and plot first autocorrelation
axes('position',[lefts(6) bottoms2(2)+height2*2 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth:dt:xcorrWidth,xcorr(spikes,xcorrWidth/dt,'unbiased'))
% title({'Grid cell spike','train autocorrelation'})
% Calculate and plot second autocorrelation
axes('position',[lefts(6) bottoms2(2)+height2/5 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth2:dt:xcorrWidth2,xcorr(spikes,xcorrWidth2/dt,'unbiased'))
%% Run Hasselmo 2008 script, bat mode 2, hide figures
[dt spikes occupancy spikeTimes] = Hasselmo2008_bat(1,0);
% Calculate and plot smoothed rate map
axes('position',[lefts(5) bottoms(1) width height]);
imagesc(posBins,posBins,conv2(gaussian,spikes./(occupancy+eps)));
axis square;
xlabel('Position (m)')
% Calculate and plot first autocorrelation
axes('position',[lefts(6) bottoms2(1)+height2*2 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth:dt:xcorrWidth,xcorr(spikes,xcorrWidth/dt,'unbiased'))
% title({'Grid cell spike','train autocorrelation'})
% Calculate and plot second autocorrelation
axes('position',[lefts(6) bottoms2(1)+height2/5 width height2]);
spikes = zeros(1,ceil(simdur/dt));
spikes(round(spikeTimes/dt)) = 1;
plot(-xcorrWidth2:dt:xcorrWidth2,xcorr(spikes,xcorrWidth2/dt,'unbiased'))
xlabel('Time (s)')