-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFigure8.m
More file actions
652 lines (532 loc) · 20.6 KB
/
Figure8.m
File metadata and controls
652 lines (532 loc) · 20.6 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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
baseDir = 'D:\TPM\JK\Pub_S1AngleCode\'; % The folder containing folders of data ('\Behavior', '\Calcium', '\Whisker') and dependent codes ('\MATLAB codes')
%% basic settings
calciumDir = [baseDir, 'Calcium\'];
whiskerModelDir = [baseDir, 'Whisker\Models\'];
colors = [248 171 66; 40 170 225] / 255;
featureNames = {'Push angle', 'Vertical displacement', 'Horizontal bending', 'Vertical bending', 'Slide distance', 'Touch duration', ...
'Horizontal angle', 'Vertical angle', 'Horizontal curvature', 'Vertical curvature', 'Arc length', 'Touch count'};
%%
%% Figure 8A - Training with 2 angles
%%
%%
%% Figure 8B - Whisker feature distribution depending on 2 object angles
%%
%% Naive (top row)
Xhow = 'Mean'; %'Individual' or 'Mean'
Yout = 'Touch'; % 'Touch' or 'Choice'
learned = 'Naive'; % 'Naive', 'Expert', or ''
task = 'Two'; % 'Two', 'Discrete', or 'RadialDistance'
timing = 'lick'; % 'lick' or 'answer'
fn = ['mdl', task, learned, Xhow, Yout, '_new_', timing];
load([whiskerModelDir, fn])
angles = sort(unique(groupMdl{1}.io.Y), 'descend');
features = cell(length(groupMdl), length(angles), size(groupMdl{1}.io.X,2));
for mi = 1 : length(groupMdl)
for ai = 1 : length(angles)
tempInd = find(groupMdl{mi}.io.Y == angles(ai));
for i = 1 : size(features,3)
features{mi,ai,i} = groupMdl{mi}.io.X(tempInd,i);
end
end
end
figure,
tempColorList = jet(7);
colorList = tempColorList([1,7],:);
index = [1,2,5,6,9,10,3,4,7,8,11,12];
for i = 1 : size(features,3)
subplot(3,4,index(i)), hold on
tempCellFeature = features(:,:,i);
histRange = -3:0.2:3.1; % standardized values
hist = zeros(length(groupMdl), length(histRange)-1, length(angles));
for ai = 1 : length(angles)
for mi = 1 : length(groupMdl)
hist(mi,:,ai) = histcounts(tempCellFeature{mi,ai}, histRange, 'normalization', 'probability');
end
tempMat = squeeze(hist(:,:,ai));
shadedErrorBar(histRange(1:end-1), mean(tempMat), std(tempMat)/sqrt(length(groupMdl)), 'lineprop', {'color', colorList(ai,:)})
end
ylim([0 0.3])
title(featureNames{i})
set(gca, 'fontname', 'Arial')
end
legend({'45\circ', '135\circ'})
sgtitle('Naive')
%% Expert (bottom row)
Xhow = 'Mean'; %'Individual' or 'Mean'
Yout = 'Touch'; % 'Touch' or 'Choice'
learned = 'Expert'; % 'Naive', 'Expert', or ''
task = 'Two'; % 'Two', 'Discrete', or 'RadialDistance'
timing = 'lick'; % 'lick' or 'answer'
fn = ['mdl', task, learned, Xhow, Yout, '_new_', timing];
load([whiskerModelDir, fn])
angles = sort(unique(groupMdl{1}.io.Y), 'descend');
features = cell(length(groupMdl), length(angles), size(groupMdl{1}.io.X,2));
for mi = 1 : length(groupMdl)
for ai = 1 : length(angles)
tempInd = find(groupMdl{mi}.io.Y == angles(ai));
for i = 1 : size(features,3)
features{mi,ai,i} = groupMdl{mi}.io.X(tempInd,i);
end
end
end
figure,
tempColorList = jet(7);
colorList = tempColorList([1,7],:);
index = [1,2,5,6,9,10,3,4,7,8,11,12];
for i = 1 : size(features,3)
subplot(3,4,index(i)), hold on
tempCellFeature = features(:,:,i);
histRange = -3:0.2:3.1; % standardized values
hist = zeros(length(groupMdl), length(histRange)-1, length(angles));
for ai = 1 : length(angles)
for mi = 1 : length(groupMdl)
hist(mi,:,ai) = histcounts(tempCellFeature{mi,ai}, histRange, 'normalization', 'probability');
end
tempMat = squeeze(hist(:,:,ai));
shadedErrorBar(histRange(1:end-1), mean(tempMat), std(tempMat)/sqrt(length(groupMdl)), 'lineprop', {'color', colorList(ai,:)})
end
ylim([0 0.3])
title(featureNames{i})
set(gca, 'fontname', 'Arial')
end
legend({'45\circ', '135\circ'})
sgtitle('Expert')
%%
%% 8C - Whisker feature distribution depending on 2 choices
%%
%% Naive (top row)
Xhow = 'Mean'; %'Individual' or 'Mean'
Yout = 'Choice'; % 'Touch' or 'Choice'
learned = 'Naive'; % 'Naive', 'Expert', or ''
task = 'Two'; % 'Two', 'Discrete', or 'RadialDistance'
timing = 'lick'; % 'lick' or 'answer'
fn = ['mdl', task, learned, Xhow, Yout, '_new_', timing];
load([whiskerModelDir, fn])
angles = sort(unique(groupMdl{1}.io.Y), 'descend');
features = cell(length(groupMdl), length(angles), size(groupMdl{1}.io.X,2));
for mi = 1 : length(groupMdl)
for ai = 1 : length(angles)
tempInd = find(groupMdl{mi}.io.Y == angles(ai));
for i = 1 : size(features,3)
features{mi,ai,i} = groupMdl{mi}.io.X(tempInd,i);
end
end
end
figure,
colorList = {'c','m'};
index = [1,2,5,6,9,10,3,4,7,8,11,12];
for i = 1 : size(features,3)
subplot(3,4,index(i)), hold on
tempCellFeature = features(:,:,i);
histRange = -3:0.2:3.1; % standardized values
hist = zeros(length(groupMdl), length(histRange)-1, length(angles));
for ai = 1 : length(angles)
for mi = 1 : length(groupMdl)
hist(mi,:,ai) = histcounts(tempCellFeature{mi,ai}, histRange, 'normalization', 'probability');
end
tempMat = squeeze(hist(:,:,ai));
shadedErrorBar(histRange(1:end-1), mean(tempMat), std(tempMat)/sqrt(length(groupMdl)), 'lineprop', {'color', colorList{ai}})
end
ylim([0 0.3])
title(featureNames{i})
set(gca, 'fontname', 'Arial')
end
legend({'45\circ', '135\circ'})
sgtitle('Naive')
%% Expert (bottom row)
Xhow = 'Mean'; %'Individual' or 'Mean'
Yout = 'Choice'; % 'Touch' or 'Choice'
learned = 'Expert'; % 'Naive', 'Expert', or ''
task = 'Two'; % 'Two', 'Discrete', or 'RadialDistance'
timing = 'lick'; % 'lick' or 'answer'
fn = ['mdl', task, learned, Xhow, Yout, '_new_', timing];
load([whiskerModelDir, fn])
angles = sort(unique(groupMdl{1}.io.Y), 'descend');
features = cell(length(groupMdl), length(angles), size(groupMdl{1}.io.X,2));
for mi = 1 : length(groupMdl)
for ai = 1 : length(angles)
tempInd = find(groupMdl{mi}.io.Y == angles(ai));
for i = 1 : size(features,3)
features{mi,ai,i} = groupMdl{mi}.io.X(tempInd,i);
end
end
end
figure,
colorList = {'c','m'};
index = [1,2,5,6,9,10,3,4,7,8,11,12];
for i = 1 : size(features,3)
subplot(3,4,index(i)), hold on
tempCellFeature = features(:,:,i);
histRange = -3:0.2:3.1; % standardized values
hist = zeros(length(groupMdl), length(histRange)-1, length(angles));
for ai = 1 : length(angles)
for mi = 1 : length(groupMdl)
hist(mi,:,ai) = histcounts(tempCellFeature{mi,ai}, histRange, 'normalization', 'probability');
end
tempMat = squeeze(hist(:,:,ai));
shadedErrorBar(histRange(1:end-1), mean(tempMat), std(tempMat)/sqrt(length(groupMdl)), 'lineprop', {'color', colorList{ai}})
end
ylim([0 0.3])
title(featureNames{i})
set(gca, 'fontname', 'Arial')
end
legend({'45\circ', '135\circ'})
sgtitle('Expert')
%%
%% 8D - Decoders performances
%%
Xhow = 'Mean'; %'Individual' or 'Mean'
timing = 'lick'; % 'lick' or 'answer'
learnedGroup = {'Naive', 'Expert'}; % 'Naive', 'Expert', or ''
taskGroup = {'Two', 'Two'}; % 'Two', 'Discrete', or 'RadialDistance'
choicePerformance = zeros(6,2);
Yout = 'Choice'; % 'Touch' or 'Choice'
for i = 1 : length(learnedGroup)
fn = ['mdl', taskGroup{i}, learnedGroup{i}, Xhow, Yout, '_new_', timing];
data = load([whiskerModelDir, fn]);
choicePerformance(:,i) = cellfun(@(x) mean(x.gof.mcc), data.groupMdl)';
end
anglePerformance = zeros(6,2);
Yout = 'Touch'; % 'Touch' or 'Choice'
for i = 1 : length(learnedGroup)
fn = ['mdl', taskGroup{i}, learnedGroup{i}, Xhow, Yout, '_new_', timing];
data = load([whiskerModelDir, fn]);
anglePerformance(:,i) = cellfun(@(x) mean(x.gof.mcc), data.groupMdl)';
end
figure
hold on
plot(mean(anglePerformance), 'ko--')
plot(mean(choicePerformance), 'ko-', 'markerfacecolor', 'k')
errorbar(mean(anglePerformance), std(anglePerformance)/sqrt(6), 'k.')
errorbar(mean(choicePerformance), std(choicePerformance)/sqrt(6), 'k.')
ylabel('Performance (MCC)')
legend({'Angle decoder', 'Choice decoder'}, 'location', 'southeast')
xlim([0.5 2.5])
xticks(1:2)
yticks(0:0.2:1)
xticklabels({'Naive', 'Expert'})
set(gca, 'fontsize', 12, 'fontName', 'Arial')
%%
%% 8E - Feature importance for choice prediction (Expert 2-angle)
%%
Xhow = 'Mean'; %'Individual' or 'Mean'
Yout = 'Choice'; % 'Touch' or 'Choice'
learned = 'Expert'; % 'Naive', 'Expert', or ''
task = 'Two'; % 'Two', 'Discrete', or 'RadialDistance'
timing = 'lick'; % 'lick' or 'answer'
fn = ['mdl', task, learned, Xhow, Yout, '_new_', timing];
load([whiskerModelDir, fn])
nGroup = length(groupMdl);
nFeatures = length(groupMdl{1}.fitCoeffsFields);
LL = zeros(nGroup, 1+nFeatures);
DE = zeros(nGroup, 1+nFeatures);
for gi = 1 : nGroup
dataX = [ones(size(groupMdl{gi}.io.X,1),1),groupMdl{gi}.io.X];
dataY = groupMdl{gi}.io.Y;
listOfY = unique(dataY);
coeffs = mean(groupMdl{gi}.fitCoeffs,2);
predMat = dataX * coeffs;
predY = exp(predMat)./(1+exp(predMat));
LL(gi,1) = sum(log(binopdf(dataY,1,predY)));
nuLL = sum(log(binopdf(dataY,1,0.5)));
satLL = 0;
DE(gi,1) = (LL(gi,1)-nuLL)/(satLL-nuLL);
for fi = 1 : nFeatures
tempDataX = dataX(:,setdiff(1:nFeatures+1, fi+1));
tempCoeffs = coeffs(setdiff(1:nFeatures+1, fi+1),:);
predMat = tempDataX * tempCoeffs;
predY = exp(predMat)./(1+exp(predMat));
LL(gi,fi+1) = sum(log(binopdf(dataY,1,predY)));
nuLL = sum(log(binopdf(dataY,1,0.5)));
satLL = 0;
DE(gi,fi+1) = (LL(gi,fi+1)-nuLL)/(satLL-nuLL);
end
end
orderInd = [1,8:13, 2:5,7,6];
figure,
tempMat = (DE(:,1) - DE(:,2:end)) ./ DE(:,1);
tempMat = tempMat(:,orderInd(2:length(orderInd))-1);
bar([1:6, 8:size(DE,2)], mean(tempMat), 'k'), hold on
errorbar([1:6, 8:size(DE,2)], mean(tempMat), std(tempMat)/sqrt(nGroup), 'k', 'linestyle', 'none')
xticklabels({featureNames{orderInd(2:length(orderInd))-1}})
xtickangle(45)
ylimVal = ylim();
ylim([0 ylimVal(2)])
ylabel('Feature importance for choice prediction')
box('off')
set(gca, 'fontsize', 12, 'fontname', 'Arial')
%%
%% S8A - Feature importance for choice prediction (Expert 7-angle)
%%
Xhow = 'Mean'; %'Individual' or 'Mean'
Yout = 'Choice'; % 'Touch' or 'Choice'
learned = 'Expert'; % 'Naive', 'Expert', or ''
task = 'Discrete'; % 'Two', 'Discrete', or 'RadialDistance'
timing = 'lick'; % 'lick' or 'answer'
fn = ['mdl', task, learned, Xhow, Yout, '_new_', timing];
load([whiskerModelDir, fn])
nGroup = length(groupMdl);
nFeatures = length(groupMdl{1}.fitCoeffsFields);
LL = zeros(nGroup, 1+nFeatures);
DE = zeros(nGroup, 1+nFeatures);
for gi = 1 : nGroup
dataX = [ones(size(groupMdl{gi}.io.X,1),1),groupMdl{gi}.io.X];
dataY = groupMdl{gi}.io.Y;
listOfY = unique(dataY);
coeffs = mean(groupMdl{gi}.fitCoeffs,2);
predMat = dataX * coeffs;
predY = exp(predMat)./(1+exp(predMat));
LL(gi,1) = sum(log(binopdf(dataY,1,predY)));
nuLL = sum(log(binopdf(dataY,1,0.5)));
satLL = 0;
DE(gi,1) = (LL(gi,1)-nuLL)/(satLL-nuLL);
for fi = 1 : nFeatures
tempDataX = dataX(:,setdiff(1:nFeatures+1, fi+1));
tempCoeffs = coeffs(setdiff(1:nFeatures+1, fi+1),:);
predMat = tempDataX * tempCoeffs;
predY = exp(predMat)./(1+exp(predMat));
LL(gi,fi+1) = sum(log(binopdf(dataY,1,predY)));
nuLL = sum(log(binopdf(dataY,1,0.5)));
satLL = 0;
DE(gi,fi+1) = (LL(gi,fi+1)-nuLL)/(satLL-nuLL);
end
end
orderInd = [1,8:13, 2:5,7,6];
figure,
tempMat = (DE(:,1) - DE(:,2:end)) ./ DE(:,1);
tempMat = tempMat(:,orderInd(2:length(orderInd))-1);
bar([1:6, 8:size(DE,2)], mean(tempMat), 'k'), hold on
errorbar([1:6, 8:size(DE,2)], mean(tempMat), std(tempMat)/sqrt(nGroup), 'k', 'linestyle', 'none')
xticklabels({featureNames{orderInd(2:length(orderInd))-1}})
xtickangle(45)
ylimVal = ylim();
ylim([0 ylimVal(2)])
ylabel('Feature importance for choice prediction')
box('off')
set(gca, 'fontsize', 12, 'fontname', 'Arial')
%%
%% Figure 8F - Testing angle tuning in 7 angle sessions, before and after learning
%%
%%
%% 8G
%%
load([calciumDir, 'cellID_match_persAT_v9'], 'match', 'cellIDpersATnaive', 'cellIDpersATexpert')
load([calciumDir, 'wkv_angle_tuning_model_v9'], 'expert', 'naive')
colorsTransient = [248 171 66; 40 170 225] / 255;
colorsPersistent = [1 0 0; 0 0 1];
angles = 45:15:135;
learnerInd = [1:4,7,9];
naiveLearner = naive(learnerInd);
jk027inds = find(naiveLearner(2).cIDAll > 5000);
jk027AllLength = length(naiveLearner(2).cIDAll);
fn = fieldnames(naiveLearner);
for i = 1 : length(fn)
if size(naiveLearner(2).(fn{i}),1) == jk027AllLength
naiveLearner(2).(fn{i}) = naiveLearner(2).(fn{i})(jk027inds,:);
elseif size(naiveLearner(2).(fn{i}),1) == jk027AllLength
naiveLearner(2).(fn{i}) = naiveLearner(2).(fn{i})(:,jk027inds);
end
end
numMice = length(learnerInd);
%%
%% Fig 8G
%%
%% change of feature encoding (angle-tuned neurons)
%% pooled neurons
encodingPop = cell(numMice,2);
for mi = 1 : numMice
% naive
indTuned = find(naiveLearner(mi).tuned);
encodingPop{mi,1} = naiveLearner(mi).deFull(indTuned) - naiveLearner(mi).deWhiskerFeatures(indTuned,:);
% expert
indTuned = find(expert(mi).tuned);
encodingPop{mi,2} = expert(mi).deFull(indTuned) - expert(mi).deWhiskerFeatures(indTuned,:);
end
wfEncodingNaive = cell2mat(encodingPop(:,1));
wfEncodingExpert = cell2mat(encodingPop(:,2));
wfEncodingExpert(isinf(wfEncodingExpert)) = nan;
barOffset = 0.2;
barWidth = 0.4;
xpos = [1,2,3,4,6,5];
figure,
hold on
bar(xpos - barOffset, nanmean(wfEncodingNaive(:,1:6)), barWidth, 'facecolor', colorsTransient(1,:))
bar(xpos + barOffset, nanmean(wfEncodingExpert(:,1:6)), barWidth, 'facecolor', colorsTransient(2,:))
legend({'Naive', 'Expert'}, 'autoupdate', false, 'box', 'off', 'location', 'northwest')
errorbar(xpos - barOffset, nanmean(wfEncodingNaive(:,1:6)), sem(wfEncodingNaive(:,1:6)), 'k', 'lines', 'no')
errorbar(xpos + barOffset, nanmean(wfEncodingExpert(:,1:6)), sem(wfEncodingExpert(:,1:6)), 'k', 'lines', 'no')
xticks(min(xpos):max(xpos))
xticklabels(featureNames(xpos))
xtickangle(45)
yticks(0:0.01:0.03)
ylabel({'Feature importance on fitting'; 'session-wide neuronal activity'})
title('Angle-tuned neurons')
p = nan(1,6);
m = cell(1,6);
for i = 1 : 6
[~, p(xpos(i))] = ttest2(wfEncodingNaive(:,i), wfEncodingExpert(:,i));
end
%%
%% S8B - Show animal-averaged
%%
wfEncodingNaive = cell2mat(cellfun(@mean, encodingPop(:,1), 'un', 0));
wfEncodingExpert = cell2mat(cellfun(@(x) mean(x(isfinite(sum(x,2)),:)), encodingPop(:,2), 'un', 0));
barOffset = 0.2;
barWidth = 0.4;
xpos = [1,2,3,4,6,5];
figure,
hold on
bar(xpos - barOffset, mean(wfEncodingNaive(:,1:6)), barWidth, 'facecolor', colorsTransient(1,:))
bar(xpos + barOffset, mean(wfEncodingExpert(:,1:6)), barWidth, 'facecolor', colorsTransient(2,:))
legend({'Naive', 'Expert'}, 'autoupdate', false, 'box', 'off', 'location', 'northwest')
errorbar(xpos - barOffset, mean(wfEncodingNaive(:,1:6)), sem(wfEncodingNaive(:,1:6)), 'k', 'lines', 'no')
errorbar(xpos + barOffset, mean(wfEncodingExpert(:,1:6)), sem(wfEncodingExpert(:,1:6)), 'k', 'lines', 'no')
xticks(min(xpos):max(xpos))
xticklabels(featureNames(xpos))
xtickangle(45)
ylabel({'Mean feature importance'; 'on fitting session-wide neuronal activity'})
title('Angle-tuned neurons')
xlim([0.5 6.5])
yticks(0:0.01:0.03)
p = nan(1,6);
m = cell(1,6);
for i = 1 : 6
[~, p(xpos(i))] = ttest2(wfEncodingNaive(:,i), wfEncodingExpert(:,i));
end
%%
%% 8H - Feature impact on tuning
%%
% pooled neurons
featImpact = cell(numMice, 2);
for mi = 1 : numMice
% naive
indTuned = find(naiveLearner(mi).tuned);
featImpact{mi,1} = cell2mat(cellfun(@(x) x(1) - x(2:end), naiveLearner(mi).atCorrWhisker(indTuned), 'un', 0));
% expert
indTuned = find(expert(mi).tuned);
featImpact{mi,2} = cell2mat(cellfun(@(x) x(1) - x(2:end), expert(mi).atCorrWhisker(indTuned), 'un', 0));
end
fiNaive = cell2mat(featImpact(:,1));
fiExpert = cell2mat(featImpact(:,2));
fiExpert(isinf(fiExpert)) = nan;
barOffset = 0.2;
barWidth = 0.4;
xpos = [1,2,3,4,6,5];
figure,
hold on
bar(xpos - barOffset, nanmean(fiNaive(:,1:6)), barWidth, 'facecolor', colorsTransient(1,:))
bar(xpos + barOffset, nanmean(fiExpert(:,1:6)), barWidth, 'facecolor', colorsTransient(2,:))
legend({'Naive', 'Expert'}, 'autoupdate', false, 'box', 'off', 'location', 'northwest')
errorbar(xpos - barOffset, nanmean(fiNaive(:,1:6)), sem(fiNaive(:,1:6)), 'k', 'lines', 'no')
errorbar(xpos + barOffset, nanmean(fiExpert(:,1:6)), sem(fiExpert(:,1:6)), 'k', 'lines', 'no')
xticks(min(xpos):max(xpos))
xticklabels(featureNames(xpos))
xtickangle(45)
yticks(-0.05:0.05:0.15)
ylabel({'Feature importance on fitting'; 'session-wide neuronal activity'})
title('Angle-tuned neurons')
p = nan(1,6);
m = cell(1,6);
for i = 1 : 6
[~, p(xpos(i))] = ttest2(fiNaive(:,i), fiExpert(:,i));
end
%%
%% S8C - Mean feature impact on tuning
%%
fiNaive = cell2mat(cellfun(@(x) mean(x(isfinite(sum(x,2)),:)), featImpact(:,1), 'un', 0));
fiExpert = cell2mat(cellfun(@(x) mean(x(isfinite(sum(x,2)),:)), featImpact(:,2), 'un', 0));
barOffset = 0.2;
barWidth = 0.4;
xpos = [1,2,3,4,6,5];
figure,
hold on
bar(xpos - barOffset, mean(fiNaive(:,1:6)), barWidth, 'facecolor', colorsTransient(1,:))
bar(xpos + barOffset, mean(fiExpert(:,1:6)), barWidth, 'facecolor', colorsTransient(2,:))
legend({'Naive', 'Expert'}, 'autoupdate', false, 'box', 'off', 'location', 'northwest')
errorbar(xpos - barOffset, mean(fiNaive(:,1:6)), sem(fiNaive(:,1:6)), 'k', 'lines', 'no')
errorbar(xpos + barOffset, mean(fiExpert(:,1:6)), sem(fiExpert(:,1:6)), 'k', 'lines', 'no')
xticks(min(xpos):max(xpos))
xticklabels(featureNames(xpos))
xtickangle(45)
ylabel({'Mean feature importance'; 'on fitting session-wide neuronal activity'})
title('Angle-tuned neurons')
xlim([0.5 6.5])
yticks(-0.05:0.05:0.15)
p = nan(1,6);
m = cell(1,6);
for i = 1 : 6
[~, p(xpos(i))] = ttest2(fiNaive(:,i), fiExpert(:,i));
end
%%
%% S8D - Proportion of maximally impacting whisker features
%%
maxImpact = cell(numMice, 2);
for mi = 1 : numMice
% naive
indTuned = find(naiveLearner(mi).tuned);
sigImpactFeat = cell2mat(cellfun(@(x) x(1)-x(2:end) == max(x(1)-x(2:end)), naiveLearner(mi).atCorrWhisker(indTuned), 'un', 0));
maxImpact{mi,1} = mean(sigImpactFeat);
% expert
indTuned = find(expert(mi).tuned);
sigImpactFeat = cell2mat(cellfun(@(x) x(1)-x(2:end) == max(x(1)-x(2:end)), expert(mi).atCorrWhisker(indTuned), 'un', 0));
maxImpact{mi,2} = mean(sigImpactFeat);
end
miNaive = cell2mat(maxImpact(:,1));
miExpert = cell2mat(maxImpact(:,2));
barOffset = 0.2;
barWidth = 0.4;
xpos = [1,2,3,4,6,5];
figure,
hold on
bar(xpos - barOffset, nanmean(miNaive(:,1:6)), barWidth, 'facecolor', colorsTransient(1,:))
bar(xpos + barOffset, nanmean(miExpert(:,1:6)), barWidth, 'facecolor', colorsTransient(2,:))
legend({'Naive', 'Expert'}, 'autoupdate', false, 'box', 'off', 'location', 'northwest')
errorbar(xpos - barOffset, nanmean(miNaive(:,1:6)), sem(miNaive(:,1:6)), 'k', 'lines', 'no')
errorbar(xpos + barOffset, nanmean(miExpert(:,1:6)), sem(miExpert(:,1:6)), 'k', 'lines', 'no')
xticks(min(xpos):max(xpos))
xticklabels(featureNames(xpos))
xtickangle(45)
yticks(0:0.1:0.5)
ylabel('Proportion of angle-tuned neurons')
title('Maximally impacting object-angle tuning')
p = nan(1,6);
for i = 1 : 6
[~, p(xpos(i))] = ttest2(miNaive(:,i), miExpert(:,i));
end
%%
%% S8E - Proportion of strongly impacting whisker features
%%
impactThreshold = 0.1;
sigImpactProp = cell(numMice, 2);
for mi = 1 : numMice
% naive
indTuned = find(naiveLearner(mi).tuned);
sigImpactFeat = cell2mat(cellfun(@(x) x(1)-x(2:end) > impactThreshold, naiveLearner(mi).atCorrWhisker(indTuned), 'un', 0));
sigImpactProp{mi,1} = mean(sigImpactFeat);
% expert
indTuned = find(expert(mi).tuned);
sigImpactFeat = cell2mat(cellfun(@(x) x(1)-x(2:end) > impactThreshold, expert(mi).atCorrWhisker(indTuned), 'un', 0));
sigImpactProp{mi,2} = mean(sigImpactFeat);
end
siNaive = cell2mat(sigImpactProp(:,1));
siExpert = cell2mat(sigImpactProp(:,2));
barOffset = 0.2;
barWidth = 0.4;
xpos = [1,2,3,4,6,5];
figure,
hold on
bar(xpos - barOffset, nanmean(siNaive(:,1:6)), barWidth, 'facecolor', colorsTransient(1,:))
bar(xpos + barOffset, nanmean(siExpert(:,1:6)), barWidth, 'facecolor', colorsTransient(2,:))
legend({'Naive', 'Expert'}, 'autoupdate', false, 'box', 'off', 'location', 'northwest')
errorbar(xpos - barOffset, nanmean(siNaive(:,1:6)), sem(siNaive(:,1:6)), 'k', 'lines', 'no')
errorbar(xpos + barOffset, nanmean(siExpert(:,1:6)), sem(siExpert(:,1:6)), 'k', 'lines', 'no')
xticks(min(xpos):max(xpos))
xticklabels(featureNames(xpos))
xtickangle(45)
yticks(0:0.1:0.4)
ylabel('Proportion of angle-tuned neurons')
title('Strongly impacting object-angle tuning')
p = nan(1,6);
for i = 1 : 6
[~, p(xpos(i))] = ttest2(siNaive(:,i), siExpert(:,i));
end