figS6CDEF.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. %% fig. S6C-F - Correlation histogram and cumulatiive density function
  2. % Load necessary data for fig.S6C-D
  3. clear all
  4. close all
  5. % =========================================================================
  6. %% Load data
  7. % =========================================================================
  8. %Prepare variables
  9. %load('figS6CE.mat'); %For locomotion
  10. load('figS6DF.mat'); %For pupil
  11. % =========================================================================
  12. %% r value distribution - fig. S6C
  13. % =========================================================================
  14. fig1 = figure('Name', 'Hit_CorrelationHistogram');
  15. fig1.Position = [680 500 375 450];
  16. BinSize = 0.05;
  17. Edges = -1:BinSize:1;%BinSize
  18. for iPhase = 1:4
  19. %Stim------------------------------------------------------------------
  20. switch iPhase
  21. case 1
  22. subplot(3, 2, iPhase);
  23. histogram(StimCorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', 'none');
  24. case 2
  25. subplot(3, 2, iPhase-1);
  26. histogram(StimCorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', [1 0 0], 'EdgeColor', 'none');
  27. case 3
  28. subplot(3, 2, iPhase-1);
  29. histogram(StimCorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', 'none');
  30. case 4
  31. subplot(3, 2, iPhase-2);
  32. histogram(StimCorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', [1 0 0], 'EdgeColor', 'none');
  33. end
  34. xlim([-1 1]);
  35. xticks([-1 -0.5 0 0.5 1]);
  36. ylim([0 0.5]);
  37. yticks([0 0.2 0.4]);
  38. ytix = get(gca, 'YTick');
  39. set(gca, 'YTick',ytix, 'YTickLabel',ytix*100)
  40. ylabel('Proportion of cell (%)')
  41. box off
  42. hold on
  43. switch iPhase
  44. case 1
  45. title('Stimulus Corr.')
  46. case 3
  47. title('REV-Stimulus Corr.')
  48. end
  49. %Delay-----------------------------------------------------------------
  50. switch iPhase
  51. case 1
  52. subplot(3, 2, iPhase+2);
  53. histogram(DelayCorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', 'none');
  54. case 2
  55. subplot(3, 2, iPhase-1+2);
  56. histogram(DelayCorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', [0 1 0],'EdgeColor', 'none');
  57. case 3
  58. subplot(3, 2, iPhase-1+2);
  59. histogram(DelayCorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', 'none');
  60. case 4
  61. subplot(3, 2, iPhase-2+2);
  62. histogram(DelayCorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', [0 1 0], 'EdgeColor', 'none');
  63. end
  64. xlim([-1 1]);
  65. xticks([-1 -0.5 0 0.5 1]);
  66. ylim([0 0.5]);
  67. yticks([0 0.2 0.4]);
  68. ytix = get(gca, 'YTick');
  69. set(gca, 'YTick',ytix, 'YTickLabel',ytix*100)
  70. ylabel('Proportion of cell (%)')
  71. box off
  72. hold on
  73. switch iPhase
  74. case 1
  75. title('Delay Corr.')
  76. case 3
  77. title('REV-Delay Corr.')
  78. end
  79. %ITI-------------------------------------------------------------------
  80. switch iPhase
  81. case 1
  82. subplot(3, 2, iPhase+4);
  83. histogram(ITICorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', 'none');
  84. case 2
  85. subplot(3, 2, iPhase-1+4);
  86. histogram(ITICorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', [0 0 1], 'EdgeColor', 'none');
  87. case 3
  88. subplot(3, 2, iPhase-1+4);
  89. histogram(ITICorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', 'none');
  90. case 4
  91. subplot(3, 2, iPhase-2+4);
  92. histogram(ITICorrHit_RVal(:,iPhase), Edges, 'Normalization', 'Probability', 'FaceColor', [0 0 1], 'EdgeColor', 'none');
  93. end
  94. xlim([-1 1]);
  95. xticks([-1 -0.5 0 0.5 1]);
  96. ylim([0 0.5]);
  97. yticks([0 0.2 0.4]);
  98. ytix = get(gca, 'YTick');
  99. set(gca, 'YTick',ytix, 'YTickLabel',ytix*100)
  100. ylabel('Proportion of cell (%)')
  101. xlabel('Corrlation coefficient')
  102. box off
  103. hold on
  104. switch iPhase
  105. case 1
  106. title('ITI Corr.')
  107. case 3
  108. title('REV-ITI Corr.')
  109. end
  110. end%iPhase
  111. suptitle('Hit trial correlation-Edgeblack = Naive')
  112. % =================================================================
  113. %% cdf plot - fig. S6C
  114. % =================================================================
  115. fig2 = figure('Name', 'HitCDF');
  116. fig2.Position = [680 500 375 450];
  117. for iPhase = 1:4
  118. %Stim------------------------------------------------------------------
  119. switch iPhase
  120. case 1
  121. subplot(3, 2, iPhase);
  122. h1 = cdfplot(abs(StimCorrHit_RVal(:,iPhase)));
  123. set(h1, 'Color', 'k', 'LineWidth', 1.0, 'LineStyle', '-');
  124. case 2
  125. sub1 = subplot(3, 2, iPhase-1); %To remove XLabel, handle is necessary
  126. h2 = cdfplot(abs(StimCorrHit_RVal(:,iPhase)));
  127. set(h2, 'Color', [1 0 0], 'LineWidth', 1.5, 'LineStyle', '-');
  128. sub1.XLabel.String = [];
  129. case 3
  130. subplot(3, 2, iPhase-1);
  131. h1 = cdfplot(abs(StimCorrHit_RVal(:,iPhase)));
  132. set(h1, 'Color', 'k', 'LineWidth', 1.0,'LineStyle', '-');
  133. case 4
  134. sub2 = subplot(3, 2, iPhase-2);
  135. h2 = cdfplot(abs(StimCorrHit_RVal(:,iPhase)));
  136. set(h2, 'Color', [1 0 0], 'LineWidth', 1.5, 'LineStyle', '-');
  137. sub2.XLabel.String = [];
  138. end
  139. xlim([0 1]);
  140. xticks([0 0.5 1]);
  141. ylim([0 1.0]);
  142. yticks([0 0.5 1.0]);
  143. ytix = get(gca, 'YTick');
  144. set(gca, 'YTick',ytix, 'YTickLabel',ytix*100)
  145. ylabel('Proportion of cell (%)')
  146. box off
  147. hold on
  148. %Due to cdfplot, use case 2 and case 4 to add the tile
  149. switch iPhase
  150. case 2
  151. title('Stim Corr')
  152. case 4
  153. title('Stim Corr')
  154. end
  155. %Delay-----------------------------------------------------------------
  156. switch iPhase
  157. case 1
  158. subplot(3, 2, iPhase+2);
  159. h1 = cdfplot(abs(DelayCorrHit_RVal(:,iPhase)));
  160. set(h1, 'Color', 'k', 'LineWidth', 1.0, 'LineStyle', '-');
  161. case 2
  162. sub1 = subplot(3, 2, iPhase-1+2);
  163. h2 = cdfplot(abs(DelayCorrHit_RVal(:,iPhase)));
  164. set(h2, 'Color', [0 1 0], 'LineWidth', 1.5, 'LineStyle', '-');
  165. sub1.XLabel.String = [];
  166. case 3
  167. subplot(3, 2, iPhase-1+2);
  168. h1 = cdfplot(abs(DelayCorrHit_RVal(:,iPhase)));
  169. set(h1, 'Color', 'k', 'LineWidth', 1.0,'LineStyle', '-');
  170. case 4
  171. sub2 = subplot(3, 2, iPhase-2+2);
  172. h2 = cdfplot(abs(DelayCorrHit_RVal(:,iPhase)));
  173. set(h2, 'Color', [0 1 0], 'LineWidth', 1.5, 'LineStyle', '-');
  174. sub2.XLabel.String = [];
  175. end
  176. xlim([0 1]);
  177. xticks([0 0.5 1]);
  178. ylim([0 1.0]);
  179. yticks([0 0.5 1.0]);
  180. ytix = get(gca, 'YTick');
  181. set(gca, 'YTick',ytix, 'YTickLabel',ytix*100)
  182. ylabel('Proportion of cell (%)')
  183. box off
  184. hold on
  185. %Due to cdfplot, use case 2 and case 4 to add the tile
  186. switch iPhase
  187. case 2
  188. title('Delay Corr')
  189. case 4
  190. title('REV-Delay Corr')
  191. end
  192. %ITI-------------------------------------------------------------------
  193. switch iPhase
  194. case 1
  195. subplot(3, 2, iPhase+4);
  196. h1 = cdfplot(abs(ITICorrHit_RVal(:,iPhase)));
  197. set(h1, 'Color', 'k', 'LineWidth', 1.0, 'LineStyle', '-');
  198. case 2
  199. sub1 = subplot(3, 2, iPhase-1+4);
  200. h2 = cdfplot(abs(ITICorrHit_RVal(:,iPhase)));
  201. set(h2, 'Color', [0 0 1], 'LineWidth', 1.5, 'LineStyle', '-');
  202. sub1.XLabel.String = 'Absolute r value';
  203. case 3
  204. subplot(3, 2, iPhase-1+4);
  205. h1 = cdfplot(abs(ITICorrHit_RVal(:,iPhase)));
  206. set(h1, 'Color', 'k', 'LineWidth', 1.0,'LineStyle', '-');
  207. case 4
  208. sub2 = subplot(3, 2, iPhase-2+4);
  209. h2 = cdfplot(abs(ITICorrHit_RVal(:,iPhase)));
  210. set(h2, 'Color', [0 0 1], 'LineWidth', 1.5, 'LineStyle', '-');
  211. sub2.XLabel.String = 'Absolute r value';
  212. end
  213. xlim([0 1]);
  214. xticks([0 0.5 1]);
  215. ylim([0 1.0]);
  216. yticks([0 0.5 1.0]);
  217. ytix = get(gca, 'YTick');
  218. set(gca, 'YTick',ytix, 'YTickLabel',ytix*100)
  219. ylabel('Proportion of cell (%)')
  220. box off
  221. hold on
  222. %Due to cdfplot, use case 2 and case 4 to add the tile
  223. switch iPhase
  224. case 2
  225. title('ITI Corr')
  226. case 4
  227. title('Rev-ITI Corr')
  228. end
  229. end%iPhase
  230. suptitle('Hit trial correlation CDF -Edgeblack = Naive')
  231. % =================================================================
  232. %% Bar plot - fig. S6E, Mean+/-SEM for delta abs-Expert - abs-Naive
  233. % =================================================================
  234. NofCell = 210;
  235. catNames = {'Stimulus', 'Delay', 'ITI'};
  236. DeltaStim = [];
  237. DeltaDelay = [];
  238. DeltaITI = [];
  239. MeanDeltaStim = [];
  240. SEM4Stim = [];
  241. %Absolute R value in Expert - abs R in Naive for all matched cells
  242. for iPhase = [1 3] %1: Initial, 3: Reversal
  243. DeltaStim = abs(StimCorrHit_RVal(:, iPhase+1))-abs(StimCorrHit_RVal(:, iPhase));
  244. MeanDeltaStim = mean(DeltaStim, 1);
  245. SEM4Stim = std(DeltaStim, 1)/sqrt(NofCell);
  246. DeltaDelay = abs(DelayCorrHit_RVal(:, iPhase+1))-abs(DelayCorrHit_RVal(:, iPhase));
  247. MeanDeltaDelay = mean(DeltaDelay, 1);
  248. SEM4Delay = std(DeltaDelay, 1)/sqrt(NofCell);
  249. DeltaITI = abs(ITICorrHit_RVal(:, iPhase+1))-abs(ITICorrHit_RVal(:, iPhase));
  250. MeanDeltaITI = mean(DeltaITI, 1);
  251. SEM4ITI = std(DeltaITI, 1)/sqrt(NofCell);
  252. %Bar chart-----------------------------------------------------------------
  253. switch iPhase
  254. case 1
  255. FigTitle = 'Initial-delta bar chart';
  256. Figtitle_Inside = 'Initial - Delta r value';
  257. case 3
  258. FigTitle = 'Reversal-delta bar chart';
  259. Figtitle_Inside = 'Reversal - Delta r value';
  260. end
  261. fig = figure('Name', FigTitle);
  262. fig.Position = [410 278 300 125];
  263. Mean4Bar = [MeanDeltaStim MeanDeltaDelay MeanDeltaITI];
  264. SEM4Bar = [SEM4Stim SEM4Delay SEM4ITI];
  265. bar(1:size(catNames,2), Mean4Bar, 'FaceColor', 'none', 'EdgeColor', 'k');
  266. hold on;
  267. er = errorbar(1:size(catNames,2), Mean4Bar, SEM4Bar);
  268. er.Color = [0 0 0];
  269. er.LineStyle = 'none';
  270. er.MarkerEdgeColor = 'none';
  271. xticks([1 2 3 4]);
  272. xticklabels(catNames);
  273. ylim([-0.1 0.05]);
  274. ylabel('delta r value')
  275. box off
  276. title(Figtitle_Inside);
  277. end %iPhase