G_generateFigure4.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. %% generate figure 4
  2. % Analysis of phasic Start and Stop neurons in the extended training dataset
  3. clc;clear;close all
  4. Task=1;
  5. load('table_OT.mat')
  6. load('Rextendedtraining.mat');
  7. load('RatID_extendedtraining.mat');
  8. load('Celltype_extendedTraining.mat');
  9. load('TRN_DT5_extendedtrain.mat')
  10. %% --- --- Plotting color-coded and average PSTHs --- ---
  11. Yaxis=[-2 6];
  12. Xaxis1=[-0.25 1];
  13. Xaxis2=[-2 0.25];
  14. Ishow1=find(R.Param.Tm>=Xaxis1(1) & R.Param.Tm<=Xaxis1(2));
  15. Ishow2=find(R.Param.Tm>=Xaxis2(1) & R.Param.Tm<=Xaxis2(2));
  16. Eventnames={'';'LI';'';'LP1';'';'LP2';'';'LP3';'';'LP4';'';'LP5';'';'PE'};
  17. namebars=categorical({'All START','EXC pre-LP1'});
  18. labelxaxis={'time from LI','time from LP1'};
  19. % ----------- COLORS ---------
  20. myblue=[0 113/255 188/255];
  21. mypurple=[200/255 0 255/255];
  22. mydarkblue=[0 0/255 255/255];
  23. TickSize=[0.015 0.02];
  24. time1=-0.25:0.01:1;
  25. time2=-2:0.01:0.25;
  26. %% Pie Plot
  27. %proportion of start neurons responding before the 1st lever press
  28. DLSselectionPRELP_start=R.Coord(:,4)==10 & Celltype(:,1)==1 & TRNmatrice(:,1)==1 & table_OT(:,5)==2 & table_OT(:,6)==1;
  29. DLSselectionSTART=R.Coord(:,4)==10 & Celltype(:,1)==1 & table_OT(:,5)==2 & table_OT(:,6)==1;
  30. DMSselectionPRELP_start=R.Coord(:,4)==20 & Celltype(:,1)==1 & TRNmatrice(:,1)==1 & table_OT(:,5)==2 & table_OT(:,6)==1;
  31. DMSselectionSTART=R.Coord(:,4)==20 & Celltype(:,1)==1 & table_OT(:,5)==2 & table_OT(:,6)==1;
  32. DSselectionPRELP_start=R.Coord(:,4)~=0 & Celltype(:,1)==1 & TRNmatrice(:,1)==1 & table_OT(:,5)==2 & table_OT(:,6)==1;
  33. DLS_X(1)=sum(DLSselectionSTART);
  34. DMS_X(1)=sum(DMSselectionSTART);
  35. DLS_X(2)=sum(DLSselectionPRELP_start);
  36. DMS_X(2)=sum(DMSselectionPRELP_start);
  37. DS_X=sum(DSselectionPRELP_start);
  38. DLS_tot(1)=sum(R.Coord(:,4)==10 & Celltype(:,1)==1 & table_OT(:,6)==1);
  39. DMS_tot(1)=sum(R.Coord(:,4)==20 & Celltype(:,1)==1 & table_OT(:,6)==1);
  40. DS_tot=sum(R.Coord(:,4)~=0 & Celltype(:,1)==1 & table_OT(:,6)==1);
  41. DS_Percent(1,:)=DS_X*100./DS_tot;
  42. DS_Percent(2,:)=100-DS_Percent(1,:);
  43. figure
  44. subplot(2,4,1)
  45. pie(DS_Percent)
  46. title('Phasic Start');
  47. legend({'EXC pre-LP1','All Start'})
  48. %% Average PSTH start neurons
  49. nplot=0;
  50. for i=1:2 %loop thru event
  51. nplot=nplot+1;
  52. selectionDLS=R.Coord(:,4)==10 & Celltype(:,1)==1 & table_OT(:,6)==1;
  53. selectionDMS=R.Coord(:,4)==20 & Celltype(:,1)==1 & table_OT(:,6)==1;
  54. if i==1
  55. DSconcat_OTz = R.Ev(7).PSTHz(:,Ishow1);
  56. Xaxis=Xaxis1;time=time1;
  57. tickdist=0.25;
  58. else
  59. DSconcat_OTz = R.Ev(1).PSTHz(:,Ishow2);
  60. Xaxis=Xaxis2;time=time2;
  61. tickdist=0.5;
  62. end
  63. subplot(2,4,[3+(nplot-1)])
  64. DLSconcat_OT=DSconcat_OTz(selectionDLS,:);
  65. DMSconcat_OT=DSconcat_OTz(selectionDMS,:);
  66. DLSpsth=nanmean(DLSconcat_OT,1);
  67. DLSsem=nanste(DLSconcat_OT,1);
  68. DLSup=DLSpsth+DLSsem;
  69. DLSdown=DLSpsth-DLSsem;
  70. hold on;
  71. patch([time,time(end:-1:1)],[DLSup,DLSdown(end:-1:1)],myblue,'EdgeColor','none');alpha(0.5);
  72. plot(time,DLSpsth,'Color',myblue,'linewidth',1.5);
  73. DMSpsth=nanmean(DMSconcat_OT,1);
  74. DMSsem=nanste(DMSconcat_OT,1);
  75. DMSup=DMSpsth+DMSsem;
  76. DMSdown=DMSpsth-DMSsem;
  77. patch([time,time(end:-1:1)],[DMSup,DMSdown(end:-1:1)],'r','EdgeColor','none');alpha(0.5);
  78. plot(time,DMSpsth,'r','linewidth',1.5);
  79. plot([Xaxis(1) Xaxis(end)], [0 0],'LineStyle',':','Color','k');
  80. plot([0 0], [Yaxis(1) Yaxis(end)],'LineStyle',':','Color','k');
  81. axis([Xaxis,Yaxis]);
  82. set(gca,'XTick',[Xaxis(1):tickdist:Xaxis(end)]);
  83. title('START neurons');
  84. ylabel('z-score');
  85. xlabel(labelxaxis(i));
  86. end
  87. %% Average PSTH stop neurons
  88. Xaxis2=[-1 1];
  89. Ishow2=find(R.Param.Tm>=Xaxis2(1) & R.Param.Tm<=Xaxis2(2));
  90. time1=-0.25:0.01:1;
  91. time2=-1:0.01:1;
  92. labelxaxis={'time from LLP','time from PE'};
  93. nplot=0;
  94. for i=1:2 %loop thru event
  95. nplot=nplot+1;
  96. selectionDLS=R.Coord(:,4)==10 & Celltype(:,1)==1 & table_OT(:,6)==2;
  97. selectionDMS=R.Coord(:,4)==20 & Celltype(:,1)==1 & table_OT(:,6)==2;
  98. if i==1
  99. DSconcat_OTz = R.Ev(5).PSTHz(:,Ishow1);
  100. Xaxis=Xaxis1;time=time1;
  101. tickdist=0.25;
  102. else
  103. DSconcat_OTz = R.Ev(6).PSTHz(:,Ishow2);
  104. Xaxis=Xaxis2;time=time2;
  105. tickdist=0.5;
  106. end
  107. subplot(2,4,[5+(nplot-1)])
  108. DLSconcat_OT=DSconcat_OTz(selectionDLS,:);
  109. DMSconcat_OT=DSconcat_OTz(selectionDMS,:);
  110. DLSpsth=nanmean(DLSconcat_OT,1);
  111. DLSsem=nanste(DLSconcat_OT,1);
  112. DLSup=DLSpsth+DLSsem;
  113. DLSdown=DLSpsth-DLSsem;
  114. hold on;
  115. patch([time,time(end:-1:1)],[DLSup,DLSdown(end:-1:1)],myblue,'EdgeColor','none');alpha(0.5);
  116. plot(time,DLSpsth,'Color',myblue,'linewidth',1.5);
  117. DMSpsth=nanmean(DMSconcat_OT,1);
  118. DMSsem=nanste(DMSconcat_OT,1);
  119. DMSup=DMSpsth+DMSsem;
  120. DMSdown=DMSpsth-DMSsem;
  121. patch([time,time(end:-1:1)],[DMSup,DMSdown(end:-1:1)],'r','EdgeColor','none');alpha(0.5);
  122. plot(time,DMSpsth,'r','linewidth',1.5);
  123. %plot([0 0], [-2 2.5],'LineStyle',':','Color','k');
  124. plot([Xaxis(1) Xaxis(end)], [0 0],'LineStyle',':','Color','k');
  125. plot([0 0], [Yaxis(1) Yaxis(end)],'LineStyle',':','Color','k');
  126. axis([Xaxis,Yaxis]);
  127. set(gca,'XTick',[Xaxis(1):tickdist:Xaxis(end)]);
  128. title('STOP neurons');
  129. ylabel('z-score');
  130. xlabel(labelxaxis(i));
  131. end
  132. %% Stop neurons, activity around PE at the end of trials VS during inter-trial intervals
  133. titlelabel={'STOP neurons DLS' 'STOP neurons DMS'};
  134. selectionDLS=R.Coord(:,4)==10 & Celltype(:,1)==1 & table_OT(:,6)==2;
  135. selectionDMS=R.Coord(:,4)==20 & Celltype(:,1)==1 & table_OT(:,6)==2;
  136. Xaxis1=[-1 1]; Yaxis=[-2 6];
  137. Ishow=find(R.Param.Tm>=Xaxis1(1) & R.Param.Tm<=Xaxis1(2));
  138. time=[-1:0.01:1];
  139. colors{1,1}=[0.00 0.75 0.75];
  140. colors{1,2}=[0.3 0.1 0.8];
  141. for i=1:2
  142. if i==1
  143. selection=selectionDLS;
  144. else
  145. selection=selectionDMS;
  146. end
  147. meanPostRew_PE=nanmean(R.Ev(6).PSTHz(selection,Ishow),1);
  148. stePostRew_PE=nanste(R.Ev(6).PSTHz(selection,Ishow),1);
  149. meanITI_PE=nanmean(R.Ev(12).PSTHz(selection,Ishow),1);
  150. steITI_PE=nanste(R.Ev(12).PSTHz(selection,Ishow),1);
  151. PRPE_up=meanPostRew_PE+stePostRew_PE;
  152. PRPE_down=meanPostRew_PE-stePostRew_PE;
  153. ITIPE_up=meanITI_PE+steITI_PE;
  154. ITIPE_down=meanITI_PE-steITI_PE;
  155. subplot(2,4,7+i-1)
  156. patch([time,time(end:-1:1)],[PRPE_up,PRPE_down(end:-1:1)],colors{1,1},'EdgeColor','none');alpha(0.5);
  157. hold on
  158. g1=plot(time,meanPostRew_PE,'Color',colors{1,1},'linewidth',1.5);
  159. patch([time,time(end:-1:1)],[ITIPE_up,ITIPE_down(end:-1:1)],colors{1,2},'EdgeColor','none');alpha(0.5);
  160. g2=plot(time,meanITI_PE,'Color',colors{1,2},'linewidth',1.5);
  161. plot([-1 1], [0 0],'LineStyle',':','Color','k');
  162. plot([0 0],Yaxis,'LineStyle',':','Color','k')
  163. axis([Xaxis1,Yaxis]);
  164. title(titlelabel(i));
  165. set(gca,'XTick',[-1:0.5:1]);
  166. ylabel('z-score');
  167. xlabel('time from PE');
  168. hold off
  169. end