FB_FIGURES.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. %% Generate the FEEDBACK MS figure panels ===============================
  2. fprintf('== GENERATING FEEDBACK MS EFFECT FIGURES ==================\n')
  3. % Effect Windows
  4. EffWin.V1toV4.Exc = [0 0.050];
  5. EffWin.V1toV4.Sup = [0.050 0.120];
  6. EffWin.V4toV1.Exc = [0 0.030];
  7. EffWin.V4toV1.Sup = [0.030 0.150];
  8. % FEEDBACK V4 to V1
  9. EffectWindow.exc = EffWin.V4toV1.Exc;
  10. EffectWindow.sup = EffWin.V4toV1.Sup;
  11. fprintf(['Calculating V1 effect sizes in the following post-stimulation windows:\n'...
  12. 'Excitation: ' num2str(EffectWindow.exc(1)*1e3) ' to ' num2str(EffectWindow.exc(2)*1e3) ' ms\n'...
  13. 'Suppression: ' num2str(EffectWindow.sup(1)*1e3) ' to ' num2str(EffectWindow.sup(2)*1e3) ' ms\n']);
  14. V4MS = preProcessV4MS(V4MS,EffectWindow);
  15. %% FIGURE 6C - EXAMPLE UNIT V1 ==========================================
  16. fprintf('\n -- FIGURE 6C ----------\n');
  17. INDS = find(V4MS.RFDATA(:,5)>-1);
  18. indCH = 36;
  19. V4MS.META.S = 1;
  20. soa = 3;
  21. S = 8;
  22. BL_EX = smooth(V4MS.CLEAN.UNITS(:,INDS(indCH),1),S );
  23. MAX = nanmax(BL_EX); BL_EX = BL_EX/MAX;
  24. MS_EX = smooth(V4MS.CLEAN.UNITS(:,INDS(indCH),soa+1),S )/MAX;
  25. FSZ = 12;
  26. figure (44);clf; hold all;
  27. set(gca,'FontSize',FSZ)
  28. xlim([-0.1 0.35])
  29. ylim([-0.15 1.05])
  30. YL = ylim;p = patch([0.15 0.15 0.15+0.025 0.15+0.025],...
  31. [YL(1) YL(2) YL(2) YL(1)],0.8*[1 1 1],'EdgeColor','none',...
  32. 'FaceColor',[230 220 110]/255);
  33. hms = plot(V4MS.TIME,smooth(MS_EX,1),'Color',...
  34. V4MS.META.COLS(soa+1,:),'LineWidth',2);
  35. hbl = plot(V4MS.TIME,smooth(BL_EX,1),'Color',...
  36. 0*V4MS.META.COLS(1,:),'LineWidth',2);
  37. legend([hbl hms],{'no MS' 'MS'})
  38. xlabel('Time [s]'); ylabel('MUA')
  39. print_figure('figure6C',[0 0 7 7],fullfile(fld.figs,'FIG_6'),save_figs)
  40. cd(fld.scripts);
  41. %% FIGURE 6B - Make RF figure FB ========================================
  42. fprintf('\n -- FIGURE 6B ----------\n');
  43. load(fullfile(fld.data,'MAPPINGS','RF_B.mat'));
  44. figure(17);
  45. set(gca,'FontSize',FSZ)
  46. V4Lims=[0 9; -9 0];
  47. NV1RFs=[3]; % Say how many V1 RF there are.
  48. v1ch = 3; % Say which one do you want to plot
  49. % (if you want only RF 1 and 3 for example you can use v1ch=[1 3] )
  50. NV4CH=19; % Set the V4 channel that you want to plot.
  51. YTicks=[-9:2:0];
  52. XTicks=[0:2:9];
  53. [X,Y]=meshgrid(V4Lims(1,1):V4Lims(1,2),V4Lims(2,1):V4Lims(2,2));
  54. ST=0.01;
  55. [XI,YI]=meshgrid([V4Lims(1,1):ST:V4Lims(1,2)],[V4Lims(2,1):ST:V4Lims(2,2)]);
  56. SM=3; count=0;
  57. wh=[0.5 0.5];
  58. POS=[0.5 1; 1 1; 0.5 0.5; 1 0.5];
  59. count=count+1;
  60. TEMP=squeeze(RESPMATV4(NV4CH,:,:));
  61. if SM~=0
  62. TEMP3=TEMP;
  63. for j=1:size(TEMP,1)
  64. TEMP3(j,:)=smooth(TEMP(j,:),SM);
  65. end
  66. for i=1:size(TEMP3,2)
  67. TEMP3(:,i)=smooth(TEMP3(:,i),SM);
  68. end
  69. else
  70. TEMP3=TEMP;
  71. end
  72. Z=interp2(X,Y,TEMP3,XI,YI);
  73. colormap('default')
  74. imagesc(V4Lims(1,:),V4Lims(2,:),Z/max(max(Z)));
  75. set(gca,'YDir','normal')
  76. hold on
  77. axis('square')
  78. COLORS=[159/255, 29/255, 53/255; 0 128/255 0; ...
  79. 125/255, 249/255, 1; 244/255, 196/255, 48/255];
  80. for v1=v1ch
  81. TEMP=DATAV1(v1);
  82. DAT=TEMP.DAT;
  83. sampf=TEMP.Sampf;
  84. MP=TEMP.MP;
  85. DegperS=TEMP.DegperS;
  86. OFF.rho=TEMP.RFPecc;
  87. OFF.angle=TEMP.RFPangle;
  88. RF_INFO(v1)= RFpos(DAT, sampf, MP, DegperS, OFF);
  89. Mid=RF_INFO(v1).Mid;
  90. WH=RF_INFO(v1).WH;
  91. clr=RF_INFO(v1).clr;
  92. Ic=RF_INFO(v1).Ic;
  93. if v1==1;channs=[2 3 4 7 10 11 12 14];
  94. elseif v1==2;channs=[1 2 3 4 6 11 12 14 15];
  95. elseif v1==3;channs=[2];
  96. end
  97. for chan = channs
  98. M = [Mid.x(chan) Mid.y(chan)];
  99. P = patch([Mid.x(chan)-WH(chan).w2 Mid.x(chan)+WH(chan).w2 Mid.x(chan)+WH(chan).w2 Mid.x(chan)-WH(chan).w2], ...
  100. [Mid.y(chan)-WH(chan).h2 Mid.y(chan)-WH(chan).h2 Mid.y(chan)+WH(chan).h2 Mid.y(chan)+WH(chan).h2],COLORS(v1,:), ...
  101. 'EdgeColor', 'w','LineWidth',4); % COLORS(v1,1:3)
  102. set(P,'FaceColor','none')
  103. end
  104. end
  105. plot(xlim,[0 0],'w:')
  106. plot([0 0], ylim,'w:')
  107. scatter(0,0,[],[0 0 0],'Filled')
  108. set(gca,'XAxisLocation','top')
  109. set(gca,'Color',[0 0 1])
  110. xlabel('Horizontal Position [deg]')
  111. ylabel('Vertical Position [deg]')
  112. print_figure('figure6B',[0 0 7 7],fullfile(fld.figs,'FIG_6'),save_figs)
  113. cd(fld.scripts);
  114. %% FIGURE 4C - RF overlap vs Supp effect ================================
  115. fprintf('\n -- FIGURE 4C ----------\n');
  116. OVER = V4MS.RFDATA(:,5);
  117. EFFE = 50*V4MS.EFFECT(3,:);
  118. AMP = V4MS.RFDATA(:,12);
  119. OVER_SIG = OVER(logical(V4MS.CLEAN.UNITSIND) & ~isnan(OVER));
  120. EFFE_SIG = EFFE(logical(V4MS.CLEAN.UNITSIND) & ~isnan(OVER));
  121. AMP_SIG = AMP(logical(V4MS.CLEAN.UNITSIND) & ~isnan(OVER));
  122. OVER = OVER(~isnan(OVER));
  123. EFFE = EFFE(~isnan(OVER));
  124. AMP = AMP(~isnan(OVER));
  125. eff = EFFE./AMP';
  126. over = OVER;
  127. iNAN = isnan(eff);
  128. eff(iNAN) = [];
  129. over(iNAN) = [];
  130. X = [ones(length(eff),1) over];
  131. y = eff';
  132. [b,bint,r,rint,stats] = regress(y,X);
  133. [r,n,p,t] = regressionTTest(y,stats);
  134. disp(['R = ' num2str(r)])
  135. disp(['N = ' num2str(n)])
  136. disp(['P = ' num2str(p)])
  137. disp(['T = ' num2str(t)])
  138. figure(100);clf;hold all
  139. set(gca,'FontSize',10)
  140. scatter(OVER,EFFE./AMP',60,[0.75 0.75 0.9],'filled','LineWidth',1)
  141. scatter(OVER_SIG,EFFE_SIG./AMP_SIG',60,V4MS.META.COLS(4,:),'filled','LineWidth',1)
  142. plot([0.1 0.95],b(2)*[0.15 0.99]+b(1),'Color',0*V4MS.META.COLS(2,:))
  143. xlim([0 1])
  144. ylabel('Effect Size')
  145. set(gca,'XTick',[0 0.5 1])
  146. plot(xlim,[0 0],'k:','LineWidth',2)
  147. xlabel('RFs Overlap')
  148. print_figure('figure4C',[0 0 7 7],fullfile(fld.figs,'FIG_4'),save_figs)
  149. cd(fld.scripts);
  150. %% FIGURE 6D SOA both monkeys ===========================================
  151. fprintf('\n -- FIGURE 6D ----------\n');
  152. S = 10;
  153. SS = [-0.02 0.05 .15];
  154. figure;clf;
  155. for soa = 1:3
  156. subplot(1,3,soa);hold all;
  157. set(gca,'FontSize',FSZ)
  158. xlim([-0.1 0.35]); ylim([-0.15 1.05]); YL = ylim;
  159. p = patch([SS(soa) SS(soa) SS(soa)+0.025 SS(soa)+0.025],...
  160. [YL(1) YL(2) YL(2) YL(1)],0.8*[1 1 1],...
  161. 'EdgeColor','none','FaceColor',[230 220 110]/255);
  162. hms = plot(V4MS.TIME,smooth(V4MS.CLEAN.AVE(:,soa+1)/...
  163. nanmax(smooth(V4MS.CLEAN.AVE(:,1),S)),S),...
  164. 'Color',V4MS.META.COLS(soa+1,:), 'LineWidth',1);
  165. hbl = plot(V4MS.TIME,smooth(V4MS.CLEAN.AVE(:,1),S)/...
  166. nanmax(smooth(V4MS.CLEAN.AVE(:,1),S)),...
  167. 'Color',0*V4MS.META.COLS(1,:),'LineWidth',1);
  168. legend([hbl hms],{'no MS' 'MS'})
  169. xlabel('Time [s]')
  170. title(['SOA ' num2str(SS(soa)*1000) ' ms']);
  171. end
  172. fprintf(['N = ' num2str(sum(V4MS.CLEAN.UNITSIND)) '\n']);
  173. print_figure('figure6D',[0 0 21 7],fullfile(fld.figs,'FIG_6'),save_figs)
  174. cd(fld.scripts);
  175. %% FIGURE S3B SOA per MONKEY ============================================
  176. fprintf('\n -- SUPP FIGURE 3B ----------\n');
  177. MS = {'B' 'C'};
  178. for m = 1:2
  179. S = 10;
  180. SS = [-0.02 0.05 .15];
  181. temp = nanmean(nanmean(V4MS.CLEAN.UNITS(:,strcmp(V4MS.MONKEY,MS{m}),:),3),1);
  182. fprintf(['Monkey ' MS{m} ', n = ' num2str(sum(~isnan(temp))) '\n'])
  183. AVS = squeeze(nanmean(V4MS.CLEAN.UNITS(:,strcmp(V4MS.MONKEY,MS{m}),:),2));
  184. figure (m+400*m);clf;
  185. for soa = 1:3
  186. subplot(1,3,soa);hold all;
  187. set(gca,'FontSize',FSZ)
  188. xlim([-0.1 0.35])
  189. ylim([-0.2 1.05])
  190. YL = ylim;p = patch([SS(soa) SS(soa) SS(soa)+0.025 SS(soa)+0.025],...
  191. [YL(1) YL(2) YL(2) YL(1)],0.8*[1 1 1],'EdgeColor','none',...
  192. 'FaceColor',[230 220 110]/255);
  193. hms = plot(V4MS.TIME,smooth(AVS(:,soa+1)/nanmax(smooth(AVS(:,1),S)),S),...
  194. 'Color',V4MS.META.COLS(soa+1,:), 'LineWidth',1);
  195. hbl = plot(V4MS.TIME,smooth(AVS(:,1),S)/nanmax(smooth(AVS(:,1),S)),...
  196. 'Color',V4MS.META.COLS(1,:)*0,'LineWidth',1);
  197. legend([hbl hms],{'no MS' 'MS'})
  198. xlabel('Time [s]')
  199. end
  200. print_figure(['suppfigure3B_Monkey' MS{m}],[0 0 21 7],...
  201. fullfile(fld.figs,'SUPPFIG_3'),save_figs);
  202. cd(fld.scripts);
  203. end
  204. %% FIGURE 6E - Diff MUA by SOA, triggered on MS =========================
  205. fprintf('\n -- FIGURE 6E ----------\n');
  206. figure (8);clf;hold all;
  207. set(gca,'FontSize',FSZ)
  208. ylim([-0.15 0.06])
  209. YL = ylim;p = patch([0 0 0.025 0.025],[YL(1) YL(2) YL(2) YL(1)],...
  210. 0.8*[1 1 1],'EdgeColor','none','FaceColor',[230 220 110]/255);
  211. S = 10;
  212. SAOS = [-0.02 0.05 0.15];
  213. hds = [];
  214. for soa = 1:3
  215. hds(end+1) = plot(V4MS.TIME-SAOS(soa),...
  216. smooth(-V4MS.CLEAN.AVE(:,1)+V4MS.CLEAN.AVE(:,soa+1),S)/...
  217. nanmax(smooth(V4MS.CLEAN.AVE(:,1),S)),...
  218. 'Color',V4MS.META.COLS(soa+1,:),'LineWidth',1);
  219. xlim([-0.1 0.2])
  220. end
  221. plot(xlim,[0 0],'k:')
  222. set(gca,'YTick',[-0.1:0.05:0.05]);
  223. set(gca,'XTick',[-0.1:0.1:0.1]);
  224. legend(hds,{'-20ms' '50ms' '150ms'},'Location','SouthWest')
  225. ylabel('MS - no MS');
  226. xlabel('Time [s]')
  227. print_figure('figure6E',[0 0 13 5.5],fullfile(fld.figs,'FIG_6'),save_figs)
  228. cd(fld.scripts);
  229. %% FIGURE S3C - Supressive effect per monkey ============================
  230. fprintf('\n -- SUPP FIGURE 3C ----------\n');
  231. for m = 1:2
  232. figure (856+m);clf;hold all;
  233. set(gca,'FontSize',FSZ)
  234. ylim([-0.2 0.1])
  235. YL = ylim;p = patch([0 0 0.025 0.025],[YL(1) YL(2) YL(2) YL(1)],...
  236. 0.8*[1 1 1],'EdgeColor','none','FaceColor',[230 220 110]/255);
  237. S = 10;
  238. SAOS = [-0.02 0.05 0.15];
  239. AVS = squeeze(nanmean(V4MS.CLEAN.UNITS(:,strcmp(V4MS.MONKEY,MS{m}),:),2));
  240. hds = [];
  241. for soa = 1:3
  242. hds(end+1) = plot(V4MS.TIME-SAOS(soa),smooth(-AVS(:,1)+AVS(:,soa+1),S)/...
  243. nanmax(smooth(AVS(:,1),S)),'Color',V4MS.META.COLS(soa+1,:),'LineWidth',1);
  244. xlim([-0.1 0.2])
  245. end
  246. plot(xlim,[0 0],'k:')
  247. legend(hds,{'-20ms' '50ms' '150ms'},'Location','SouthWest')
  248. ylabel('MS - no MS'); xlabel('Time [s]');
  249. print_figure(['suppfigure3C_Monkey' MS{m}],[0 0 7 7],...
  250. fullfile(fld.figs,'SUPPFIG_3'),save_figs);
  251. cd(fld.scripts);
  252. end
  253. %% FIGURE 6F - Average Effect Sizes per SOA =============================
  254. fprintf('\n -- FIGURE 6F ----------\n');
  255. ANOVA_DATA= [];ANOVA_DATA2= [];
  256. OVER = V4MS.RFDATA(:,5);
  257. figure(103);clf;hold all
  258. subplot(1,2,2);hold on;
  259. set(gca,'FontSize',FSZ)
  260. for soa = 1:3
  261. EFFE = V4MS.EFFECT(soa,:);
  262. EFFE_SIG = EFFE(~isnan(nanmean(V4MS.CLEAN.UNITS(:,:,1),1)))/...
  263. nanmax(smooth(V4MS.CLEAN.AVE(:,1),10));;
  264. mEFF = nanmean(EFFE_SIG);
  265. sEFF = nanstd(EFFE_SIG)/sqrt(sum(~isnan(EFFE_SIG)));
  266. errorbar(soa,mEFF,sEFF,'sk','LineWidth',2);
  267. bar(soa,mEFF,'FaceColor',V4MS.META.COLS(soa+1,:))
  268. ANOVA_DATA = [ANOVA_DATA EFFE_SIG'];
  269. end
  270. ylim([-0.07 0.032])
  271. xlim([0.5 3.5])
  272. set(gca,'XTick',[1 2 3],'XTickLabel',{'-20' '50' '150'})
  273. ylabel('Mean Difference')
  274. % plot(xlim,[0 0],'k:','LineWidth',2)
  275. xlabel('SOA [ms]')
  276. title('Suppression')
  277. subplot(1,2,1);hold on;
  278. set(gca,'FontSize',FSZ)
  279. for soa = 1:3
  280. EFFE2 = V4MS.EXCIT_EFFECT(soa,:);
  281. EFFE_SIG2 = EFFE2(~isnan(nanmean(V4MS.CLEAN.UNITS(:,:,1),1)))/...
  282. nanmax(smooth(V4MS.CLEAN.AVE(:,1),10));;
  283. mEFF2 = nanmean(EFFE_SIG2);
  284. sEFF2 = nanstd(EFFE_SIG2)/sqrt(sum(~isnan(EFFE_SIG2)));
  285. errorbar(soa,mEFF2,sEFF2,'sk','LineWidth',2);
  286. bar(soa,mEFF2,'FaceColor',V4MS.META.COLS(soa+1,:))
  287. ANOVA_DATA2 = [ANOVA_DATA2 EFFE_SIG2'];
  288. end
  289. ylim([-0.07 0.032])
  290. xlim([0.5 3.5])
  291. set(gca,'XTick',[1 2 3],'XTickLabel',{'-20' '50' '150'})
  292. ylabel('Mean Difference')
  293. % plot(xlim,[0 0],'k:','LineWidth',2)
  294. xlabel('SOA [ms]')
  295. title('Excitation')
  296. print_figure('figure6F',[0 0 7 7],fullfile(fld.figs,'FIG_6'),save_figs)
  297. cd(fld.scripts);
  298. %% STATS for FiG 6F =====================================================
  299. fprintf('Statistics for FIG 6F\n');
  300. fprintf('- Excitation -\n');
  301. anova_data2 = ANOVA_DATA2;
  302. anova_data2(isnan(ANOVA_DATA2(:,1)),:) = [];
  303. [P2,ANOVATAB2,STATS2] = anova1(anova_data2);
  304. [c2,m2,h2,names2] = multcompare(STATS2,'Alpha',10^-15,'CType','tukey-kramer');
  305. for s=1:3
  306. [h_soa{s},p_soa{s}] = ttest(anova_data2(:,s));
  307. fprintf(['SOA ' num2str(c2(s,1)) ' vs ' num2str(c2(s,2)) ': p = ' ...
  308. num2str(c2(s,6)) '\n']);
  309. end
  310. fprintf('- Suppression -\n');
  311. anova_data = ANOVA_DATA;
  312. anova_data(isnan(ANOVA_DATA(:,1)),:) = [];
  313. [P,ANOVATAB,STATS] = anova1(anova_data);
  314. [c,m,h,names] = multcompare(STATS,'Alpha',10^-15,'CType','tukey-kramer');
  315. for i=1:3
  316. fprintf(['SOA ' num2str(c(i,1)) ' vs ' num2str(c(i,2)) ': p = ' ...
  317. num2str(c(i,6)) '\n']);
  318. end
  319. %% FIGURE 4D - Suppression effect size vs MUA ===========================
  320. fprintf('\n -- FIGURE 4D ----------\n');
  321. S = 10; SS = [-0.05 0.05 .15];
  322. % Compute activity during blank trials.
  323. BASES = nan(size(V4MS.CLEAN.UNITS,2),3);
  324. for soa = 1:3
  325. indT = V4MS.TIME > (SS(soa)+0.025) & V4MS.TIME < (SS(soa)+0.125);
  326. BASES(:,soa) = squeeze(nanmean(V4MS.UNITS(indT,:,1),1));
  327. end
  328. EFFS = nan(size(V4MS.CLEAN.UNITS,2),3);
  329. for soa = 1:3
  330. EFFE = V4MS.EFFECT(soa,:);
  331. EFFS(:,soa) = EFFE;
  332. end
  333. figure(105);clf;hold on
  334. set(gca,'FontSize',FSZ)
  335. xlim([-0.45 0.45])
  336. for soa = 3 % only the 150 ms SOA
  337. scatter(BASES(:,soa),EFFS(:,soa),60,[0.75 0.75 0.9],'filled','LineWidth',1),
  338. scatter(BASES(logical(V4MS.CLEAN.UNITSIND),soa),...
  339. EFFS(logical(V4MS.CLEAN.UNITSIND),soa),60,...
  340. V4MS.META.COLS(soa+1,:),'filled','LineWidth',1);
  341. % compute regressions
  342. indM = logical(V4MS.CLEAN.UNITSIND);
  343. eff = EFFS(indM,soa);
  344. over = BASES(indM,soa);
  345. iNAN = isnan(mean([eff over],2));
  346. eff(iNAN) = [];
  347. over(iNAN) = [];
  348. X = [ones(length(eff),1) over];
  349. y = eff';
  350. [b,bint,r,rint,stats] = regress(y',X);
  351. [r,n,p,t] = regressionTTest(y,stats);
  352. disp(['R = ' num2str(r)])
  353. disp(['N = ' num2str(n)])
  354. disp(['P = ' num2str(p)])
  355. disp(['T = ' num2str(t)])
  356. end
  357. h = lsline;
  358. xlim([-0.45 0.4])
  359. set(h(1),'Color','k','LineStyle','--')
  360. set(h(2),'LineStyle','none');
  361. xlabel('Average MUA')
  362. ylabel('Effect Size')
  363. print_figure('figure4D' ,[0 0 7 7],fullfile(fld.figs,'FIG_4'),save_figs);
  364. cd(fld.scripts);