Skip to content

Commit 0788c30

Browse files
committed
wo eye speed kernel
1 parent ad6d4d0 commit 0788c30

7 files changed

+217
-193
lines changed

mainScript.m

+157-167
Large diffs are not rendered by default.

mainScript_assembly.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[saveServer, rootFolder] = getReady();
2-
animal = 'hugo'; %'ollie';% %'andy';%
3-
for yy = 1:3
2+
animal = 'ollie';% %'andy';%
3+
for yy = 3
44
switch yy
55
case 1
66
year = '2021';
@@ -66,7 +66,7 @@
6666
clear mFiringRate
6767
end
6868

69-
save(fullfile(saveFolder, 'assembly20241212.mat'),...
69+
save(fullfile(saveFolder, 'assembly20250128.mat'),...
7070
'id_pop','expval_tgt_pop','corr_tgt_pop','corr_tgt_rel_pop',...
7171
'latency_r_pop','avgAmp_hm_pop','p_hm_pop','spkOk_th_pop',...
7272
'spkOkTrials_pop','spkOkUCueTrials_pop','mFiringRate_pop',...

populationAnalysis.m

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
%16/12/24 created from fitPSTH_pop.m
22
[saveServer, rootFolder] = getReady();
33

4-
saveSuffix_p = ['20241212'];
4+
saveSuffix_p = ['20250128'];
55
animals = {'hugo', 'ollie'};
66

7-
n=load(fullfile(saveServer,'param20241223.mat'),'param');
7+
n=load(fullfile(saveServer,'param20250128.mat'),'param');
88
param =n.param;
99

1010
%% load result of mainscript_assemble.m
@@ -85,9 +85,6 @@
8585

8686

8787
%% apply inclusion critetia
88-
% param.corr_tgtTh = 0.05;
89-
param.ptonsetRespTh=.2; %.1;
90-
% param.nLatencyTr_pref_th = 5;
9188
[okunits, corr_tgtOK, ntargetTrOK, ptonsetRespOK] ...
9289
= inclusionCriteria(corr_tgt_pop(1,:), ntargetTrials_pop, PtonsetResp_pop, param);
9390

@@ -117,9 +114,12 @@
117114

118115
%% selected units
119116
theseIDs = {'hugo/2021/08August/25/27',... %vision
120-
'hugo/2022/07July/26/19',... %eye speed
117+
'hugo/2021/03March/22/8',... %eye position
118+
'hugo/2022/08August/17/3',... %eye speed+position
121119
'hugo/2022/08August/15/4'}; %integrator new 2025
122120
[~, selectedIDs] = intersect(id_pop, theseIDs);
121+
122+
% 'hugo/2022/07July/26/19',... %eye speed
123123
%integrator candidates
124124
% 'hugo/2022/08August/05/2' 2023 JNS
125125
% 'hugo/2022/08August/23/7'
@@ -160,13 +160,13 @@
160160

161161
%% kernel avg across units (FIG2)
162162
%average kernel before centering
163-
[f, kernel_avg] = showKernel3(kernel_pop, tlags, param.cardinalDir, 0);
163+
[f, kernel_avg] = showKernel_pop(kernel_pop, tlags, param.cardinalDir, 0);
164164
savePaperFigure(f,fullfile(saveServer,saveSuffix_p,['avgKernel_' animals{:}]));
165165
close(f);
166166

167167
%centerring by preferred direction
168168
tgtRange = [0.05 0.15; 0.03 0.25; -0.1 0.1];
169-
[f, kernel_centered_avg] = showKernel3(kernel_pop, tlags, param.cardinalDir, 1, tgtRange);
169+
[f, kernel_centered_avg] = showKernel_pop(kernel_pop, tlags, param.cardinalDir, 1, tgtRange);
170170
savePaperFigure(f, fullfile(saveServer,saveSuffix_p,['avgKernel_centered_' animals{:}]));
171171
close(f);
172172

@@ -177,7 +177,6 @@
177177

178178

179179
%% cell type distibution (FIG3)
180-
181180
% correlation during target presentation
182181
fig_abs = showScatterTriplets(corr_tgt_pop, ...
183182
param.predictorNames, [-.2 1], selectedIDs,'linear',animalid_pop);
@@ -202,3 +201,6 @@
202201
%% hit v miss (FIG 5)
203202
f = showHMScatter(corr_tgt_rel_pop, p_hm_pop, selectedIDs_hm, animalid_pop);
204203
screen2png(fullfile(saveServer,saveSuffix_p,['p_hm' animals{:}]));close;
204+
disp(['The number of significant units before regression: ' num2str(sum(p_hm_pop_before<0.05))]);
205+
disp(['The number of significant units after regression: ' num2str(sum(p_hm_pop_after<0.05))]);
206+

showKernel.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
xlabel('time from eye movement [s]');
4444
mcolorbar(a3,.5);
4545

46-
if size(kernelInfo.kernel{3},2)>1
46+
if numel(kernelInfo.kernel)==2
47+
return;
48+
elseif size(kernelInfo.kernel{3},2)>1
4749
a4=subplot(4,2,6);
4850
thisIm = kernelInfo.kernel{3}';
4951
crange = prctile(abs(thisIm(:)),99);

showKernelPrefDirScatter.m

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
%tuned = amp>param.ampTh;
1212
%tuned = 1:numel(okunits);
1313

14-
f = figure('position',[ 680 485 1181 493]);
14+
f = figure('position',[ 680 485 800 1200]);
1515
for aa = 1:numel(unique(animalid_pop))
1616
if aa==1
1717
asymbol = 'o';
@@ -29,7 +29,9 @@
2929
v = [2 3];
3030
end
3131
%doubleTuned = find(tuned(:,v(1))+tuned(:,v(2))==2);
32-
subplot(2,3,ii);
32+
33+
%% scatter plot
34+
subplot(3,2,2*ii-1);
3335
plot(prefDir(animalid_pop==aa,v(1)), prefDir(animalid_pop==aa,v(2)), asymbol);hold on
3436
%plot(prefDir(doubleTuned,v(1)), prefDir(doubleTuned,v(2)), 'b.');
3537
squareplot;
@@ -40,7 +42,8 @@
4042
ylabel(param.predictorNames{v(2)});
4143
set(gca,'tickdir','out');
4244

43-
subplot(2,3,ii+3)
45+
%% histogram
46+
subplot(3,2,2*ii)
4447
histogram(prefDir(animalid_pop==aa,v(1)) - prefDir(animalid_pop==aa,v(2)),-180:5:180); hold on;
4548
%histogram(prefDir(doubleTuned,v(1)) - prefDir(doubleTuned,v(2)), -180:5:180, 'facecolor', 'b');
4649
if aa == numel(unique(animalid_pop))

showKernel3.m showKernel_pop.m

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
function [fig, kernel_avg,prefdir, prefdirPval] = showKernel3(kernel_pop, ...
1+
function [fig, kernel_avg,prefdir, prefdirPval] = showKernel_pop(kernel_pop, ...
22
tlags, cardinalDir, centering, tgtRange)
3-
% fig = showKernel3(kernel_pop, tlags, cardinalDir, centering)
3+
% fig = showKernel_pop(kernel_pop, tlags, cardinalDir, centering)
4+
5+
useSameYrange = true;
46

57
prefDirOption = 0;%
68
%very slow in option=1
@@ -35,18 +37,25 @@
3537
end
3638
end
3739

40+
if useSameYrange
41+
absMax = max(cellfun(@(x)abs(max(x(:))), kernel_avg));
42+
end
43+
3844
% created rom showKernel
3945
fig = figure('position',[1 41 1440 783]);
4046
a2=subplot(3,2,1);
4147
thisIm = kernel_avg{1}';
4248
crange = prctile(abs(thisIm(:)),99);
43-
%crange = prctile(thisIm(:),[1 99]);
49+
if useSameYrange
50+
crange = absMax;
51+
end
52+
4453
imagesc(tlags{1}(:,1), directions, thisIm);
4554
vline(0);
4655
if centering
4756
hline(0);
4857
end
49-
caxis([-crange crange]);
58+
clim([-crange crange]);
5059
set(gca,'ytick',directions);
5160
xlabel('time from targetOnset [s]');
5261
mcolorbar(a2,.5);
@@ -57,12 +66,15 @@
5766
thisIm = kernel_avg{2}';
5867
crange = prctile(abs(thisIm(:)),99);
5968
%crange = prctile(thisIm(:),[1 99]);
69+
if useSameYrange
70+
crange = absMax;
71+
end
6072
imagesc(tlags{2}(:,1),directions, thisIm);
6173
vline(0);
6274
if centering
6375
hline(0);
6476
end
65-
caxis([-crange crange]);
77+
clim([-crange crange]);
6678
set(gca,'ytick',directions);
6779
xlabel('time from eye movement [s]');
6880
mcolorbar(a3,.5);
@@ -73,6 +85,10 @@
7385
thisIm = kernel_avg{3}';
7486
crange = prctile(abs(thisIm(:)),99);
7587
%crange = prctile(thisIm(:),[1 99]);
88+
if useSameYrange
89+
crange = absMax;
90+
end
91+
7692
imagesc(tlags{3}(:,1),directions, thisIm);
7793
vline(0);
7894
if centering

showTonsetResp.m

+16-5
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@
205205
hold on;
206206
boundedline(winSamps, mtOnsetResp(allMdlIdx,:), setOnsetResp(allMdlIdx,:),'b', 'transparency', 0.5);
207207
boundedline(winSamps, mtOnsetResp(visionIdx,:), setOnsetResp(visionIdx,:),'m', 'transparency', 0.5);
208-
boundedline(winSamps, mtOnsetResp(eyevelIdx,:), setOnsetResp(eyevelIdx,:),'c', 'transparency', 0.5);
208+
if ~isempty(eyevelIdx)
209+
boundedline(winSamps, mtOnsetResp(eyevelIdx,:), setOnsetResp(eyevelIdx,:),'c', 'transparency', 0.5);
210+
end
209211
boundedline(winSamps, mtOnsetResp(eyeposIdx,:), setOnsetResp(eyeposIdx,:),'g', 'transparency', 0.5);
210212
%boundedline(winSamps, mtOnsetResp(5,:), setOnsetResp(5,:),'g', 'transparency', 0.5);
211213
%vbox(param.baseWin(1), param.baseWin(2))
@@ -227,7 +229,9 @@
227229
hold on;
228230
boundedline(winSamps, mtOnsetResp_v(allMdlIdx,:), setOnsetResp_v(allMdlIdx,:),'b', 'transparency', 0.5);
229231
boundedline(winSamps, mtOnsetResp_v(visionIdx,:), setOnsetResp_v(visionIdx,:),'m', 'transparency', 0.5);
230-
boundedline(winSamps, mtOnsetResp_v(eyevelIdx,:), setOnsetResp_v(eyevelIdx,:),'c', 'transparency', 0.5);
232+
if ~isempty(eyevelIdx)
233+
boundedline(winSamps, mtOnsetResp_v(eyevelIdx,:), setOnsetResp_v(eyevelIdx,:),'c', 'transparency', 0.5);
234+
end
231235
boundedline(winSamps, mtOnsetResp_v(eyeposIdx,:), setOnsetResp_v(eyeposIdx,:),'g', 'transparency', 0.5);
232236
%vbox(param.baseWin(1), param.baseWin(2))
233237
%vbox(param.tOnRespWin(1), param.tOnRespWin(2),[],[.7 1 .7]);
@@ -240,7 +244,9 @@
240244
hold on;
241245
boundedline(winSamps, mtOnsetResp_f(allMdlIdx,:), setOnsetResp_f(allMdlIdx,:),'b', 'transparency', 0.5);
242246
boundedline(winSamps, mtOnsetResp_f(visionIdx,:), setOnsetResp_f(visionIdx,:),'m', 'transparency', 0.5);
243-
boundedline(winSamps, mtOnsetResp_f(eyevelIdx,:), setOnsetResp_f(eyevelIdx,:),'c', 'transparency', 0.5);
247+
if ~isempty(eyevelIdx)
248+
boundedline(winSamps, mtOnsetResp_f(eyevelIdx,:), setOnsetResp_f(eyevelIdx,:),'c', 'transparency', 0.5);
249+
end
244250
boundedline(winSamps, mtOnsetResp_f(eyeposIdx,:), setOnsetResp_f(eyeposIdx,:),'g', 'transparency', 0.5);
245251
%vbox(param.baseWin(1), param.baseWin(2))
246252
%vbox(param.tOnRespWin(1), param.tOnRespWin(2),[],[.7 1 .7]);
@@ -255,7 +261,9 @@
255261
hold on;
256262
boundedline(winSamps, msaccResp(allMdlIdx,:), sesaccResp(allMdlIdx,:),'b', 'transparency', 0.5);
257263
boundedline(winSamps, msaccResp(visionIdx,:), sesaccResp(visionIdx,:),'m', 'transparency', 0.5);
258-
boundedline(winSamps, msaccResp(eyevelIdx,:), sesaccResp(eyevelIdx,:),'c', 'transparency', 0.5);
264+
if ~isempty(eyevelIdx)
265+
boundedline(winSamps, msaccResp(eyevelIdx,:), sesaccResp(eyevelIdx,:),'c', 'transparency', 0.5);
266+
end
259267
boundedline(winSamps, msaccResp(eyeposIdx,:), sesaccResp(eyeposIdx,:),'g', 'transparency', 0.5);
260268
axis tight;
261269
xlim([figTWin(1)-medianSaccDelay figTWin(end)-medianSaccDelay])
@@ -266,7 +274,9 @@
266274
hold on;
267275
boundedline(winSamps, mcOnsetResp(allMdlIdx,:), secOnsetResp(allMdlIdx,:),'b', 'transparency', 0.5);
268276
boundedline(winSamps, mcOnsetResp(visionIdx,:), secOnsetResp(visionIdx,:),'m', 'transparency', 0.5);
269-
boundedline(winSamps, mcOnsetResp(eyevelIdx,:), secOnsetResp(eyevelIdx,:),'c', 'transparency', 0.5);
277+
if ~isempty(eyevelIdx)
278+
boundedline(winSamps, mcOnsetResp(eyevelIdx,:), secOnsetResp(eyevelIdx,:),'c', 'transparency', 0.5);
279+
end
270280
boundedline(winSamps, mcOnsetResp(eyeposIdx,:), secOnsetResp(eyeposIdx,:),'g', 'transparency', 0.5);
271281
axis tight;
272282
xlim([figTWin(1)-medianSaccDelay figTWin(end)-medianSaccDelay])
@@ -286,6 +296,7 @@
286296

287297
ylabel(sprintf('cOnset (success)\nn=%d',numel(theseTrials)));
288298
legend('observed','all mdl','vision','eye velocity','eye position','location','northwest')
299+
%legend('observed','all mdl','vision','eye velocity','location','northwest')
289300

290301
end
291302

0 commit comments

Comments
 (0)