f_Figure2_Figure3_VPResponsestoAlcCues.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. %% Code for final figures for pavlovian versus instrumental comparison
  2. if ~exist('RvppaALL'),load('RvppaALL.mat'); end
  3. if ~exist('RvpppaALL'),load('RvpppaALL.mat'); end
  4. DarkPurple=[123/255 50/255 148/255];
  5. LightPurple=[194/255 165/255 207/255];
  6. LightGreen=[166/255 219/255 160/255];
  7. DarkGreen=[77/255 172/255 38/255];
  8. DarkPink=[208/255 28/255 139/255];
  9. MyBlue=[0.4940 0.1840 0.5560];
  10. MyOrange=[0.9290 0.6940 0.1250];
  11. BSIZE=0.01;
  12. Dura=[-0.5 1]; Tm=Dura(1):BSIZE:Dura(2);
  13. Baseline=[-2 0]; Tbase=Baseline(1):BSIZE:Baseline(2); %used to calculate Z-scores
  14. Tbin=-1:0.005:1; %window used to determine the optimal binsize
  15. PStat=0.05;
  16. prewin=[Dura(1) 0];
  17. postwin=[.1 .3];
  18. postwin2=[Dura(1):0.05:Dura(2)]; %bounds should match Dura
  19. Slopebounds=[-.5:.05:.5];
  20. R2Bounds=[0:0.05:0.5];
  21. PvalBounds=[0:0.01:0.5];
  22. Struct=10;
  23. %% Figure 3. VP neurons encode the value of discriminative stimuli for alcohol availability but fail to encode the value of Pavlovian alcohol cues.
  24. BrainRegion=1; %10 for Core, 100 for dms and 1000 for shell
  25. LeftEv=1; RightEv=2;
  26. ExcInh=1; % 1 for excitations, 2 for inhibitions -- Used to find Exc or Inh onsets in R.Ev(.).Onsets
  27. Pstat=0.05;
  28. stepsize=0.3; % Used for the scatter plot projections
  29. %For COLOR-CODED PSTH only (not Average PSTH)
  30. Norm=0; % 0 = no norm - max accross all the selected neurons
  31. % 1 each neuron is normalized wh its own max
  32. % 2 for baseline substraction
  33. if LeftEv==1, Xaxis=[-0.25 .5]; elseif LeftEv==3, Xaxis=[-0.25 .5]; elseif LeftEv==5; Xaxis=[-3 3]; elseif LeftEv==7; Xaxis=[-1 2]; elseif LeftEv==9; Xaxis=[-0.25 1]; end
  34. if ExcInh==1, Yaxis=[-5 10]; elseif ExcInh==2, Yaxis=[-5 5]; end
  35. %----------- COLORS ---------
  36. myblue=[0 113/255 188/255];
  37. mypurple=[200/255 0 255/255];
  38. mydarkblue=[0 0/255 255/255];
  39. TickSize=[0.015 0.02];
  40. DarkPurple=[123/255 50/255 148/255];
  41. LightPurple=[194/255 165/255 207/255];
  42. LightGreen=[166/255 219/255 160/255];
  43. DarkGreen=[77/255 172/255 38/255];
  44. DarkPink=[208/255 28/255 139/255];
  45. Ishow=find(RvppaALL.Param.Tm>=Xaxis(1) & RvppaALL.Param.Tm<=Xaxis(2));
  46. time=RvppaALL.Param.Tm(Ishow);
  47. if ExcInh==1, A=1; elseif ExcInh==2; A=-1;end
  48. figure;
  49. for i=1:2 %plots 3 different conditions (eg LP+No0 / LP+No+ / LP0No+)
  50. selectionInst=RvpppaALL.Structure==10 & ~isnan(RvpppaALL.Ev(LeftEv).Meanz) & ~isnan(RvpppaALL.Ev(RightEv).Meanz) & RvpppaALL.CSPlusRatio>=.5 & (RvpppaALL.CSPlusRatio./(RvpppaALL.CSPlusRatio+RvpppaALL.CSMinusRatio))>=.7;%) & RvpppaALL.Ev(1).RespDir==0;% & CvpppaALL.STATSpost>=0.05;
  51. selectionPav=RvppaALL.Structure==10 & ~isnan(RvppaALL.Ev(LeftEv).Meanz) & ~isnan(RvppaALL.Ev(RightEv).Meanz) & RvppaALL.CSPlusRatio>=.5 & (RvppaALL.CSPlusRatio./(RvppaALL.CSPlusRatio+RvppaALL.CSMinusRatio))>=.7;% & RvppaALL.Ev(1).RespDir==0;% & CvppaALL.STATSpost>=0.05;
  52. %------------- SORTING -------------
  53. SortEv=LeftEv; NonSortEv=RightEv;
  54. if i==1;
  55. selection=selectionInst;
  56. TMP=-RvpppaALL.Ev(SortEv).Meanz(selection,ExcInh);
  57. %TMP=RvpppaALL.Ev(SortEv).RespDir(selection,ExcInh);
  58. else;
  59. selection=selectionPav;
  60. TMP=-RvppaALL.Ev(SortEv).Meanz(selection,ExcInh);
  61. %TMP=RvppaALL.Ev(SortEv).RespDir(selection,ExcInh);
  62. end
  63. TMP(isnan(TMP))=0; %To place the neurons with no onset/duration/peak at the top of the color-coded map
  64. [~,SORTimg]=sort(TMP);
  65. %NNids are the indexes for the 3 different selections
  66. if i==1; NNid1=cell2mat(RvpppaALL.Ninfo(selection,3)); NNid1=NNid1(SORTimg); end
  67. if i==2; NNid2=cell2mat(RvppaALL.Ninfo(selection,3)); NNid2=NNid2(SORTimg); end
  68. if i==1,
  69. selection=selectionInst; SortEv=LeftEv; NonSortEv=RightEv;
  70. % ------------- NORMALIZATION -------------
  71. if Norm==0
  72. imgLeft=RvpppaALL.Ev(LeftEv).PSTHz(selection,Ishow);
  73. imgRight=RvpppaALL.Ev(RightEv).PSTHz(selection,Ishow);
  74. E=[-200 400];Clim=sign(E).*abs(E).^(1/4);%ColorMap
  75. elseif Norm~=0
  76. imgLeft=normalize(RvpppaALL.Ev(LeftEv).PSTHz(selection,Ishow),RvpppaALL.Ev(LeftEv).PSTHz(selection,(RvpppaALL.Param.Tm<0)),Norm); %normalize to max response
  77. imgRight=normalize(RvpppaALL.Ev(RightEv).PSTHz(selection,Ishow),RvpppaALL.Ev(LeftEv).PSTHz(selection,(RvpppaALL.Param.Tm<0)),Norm); %normalize to max response of the left event
  78. if Norm==1, Clim=[0 1]; elseif Norm==2, Clim=[-5 10]; end
  79. end
  80. imgLeft=imgLeft(SORTimg,:);
  81. imgRight=imgRight(SORTimg,:);
  82. else if i==2,
  83. selection=selectionPav; SortEv=LeftEv; NonSortEv=RightEv;
  84. if Norm==0
  85. imgLeft=RvppaALL.Ev(LeftEv).PSTHz(selection,Ishow);
  86. imgRight=RvppaALL.Ev(RightEv).PSTHz(selection,Ishow);
  87. E=[-200 400];Clim=sign(E).*abs(E).^(1/4);%ColorMap
  88. elseif Norm~=0
  89. imgLeft=normalize(RvppaALL.Ev(LeftEv).PSTHz(selection,Ishow),RvppaALL.Ev(LeftEv).PSTHz(selection,(RvppaALL.Param.Tm<0)),Norm); %normalize to max response
  90. imgRight=normalize(RvppaALL.Ev(RightEv).PSTHz(selection,Ishow),RvppaALL.Ev(LeftEv).PSTHz(selection,(RvppaALL.Param.Tm<0)),Norm); %normalize to max response of the left event
  91. if Norm==1, Clim=[0 1]; elseif Norm==2, Clim=[-5 10]; end
  92. end
  93. imgLeft=imgLeft(SORTimg,:);
  94. imgRight=imgRight(SORTimg,:);
  95. end
  96. end
  97. %---------------- HEAT MAPS ----------------------
  98. subplot(3,4,i+((i-1)*3));
  99. imagesc(time,[1 size(imgLeft,1)],imgLeft,Clim); %colorbar;axis tight;
  100. colormap(parula);
  101. ylabel('Neuron #');
  102. xlabel('Time from Cue (sec)');
  103. if i==1;
  104. title('DS');
  105. elseif i==2;
  106. title('CS+');
  107. end
  108. subplot(3,4,i+1+((i-1)*3));
  109. imagesc(time,[1 size(imgRight,1)],imgRight,Clim) ;%colorbar;axis tight;
  110. colormap(parula);
  111. %title(Erefnames(RightEv));
  112. ylabel('Neuron #');
  113. xlabel('Time from Cue (sec)');
  114. if i==1;
  115. title('NS');
  116. elseif i==2;
  117. title('CS-');
  118. end
  119. subplot(3,2,i*2);
  120. hold on;
  121. if i==1 %PPS
  122. if LeftEv==1, Stat=RvpppaALL.CSStat;
  123. elseif LeftEv==3, Stat=RvpppaALL.CSPlusResponseStat;
  124. end
  125. selection1=selectionInst & Stat>=0.05;
  126. selection2=selectionInst & Stat<0.05 & RvpppaALL.Ev(LeftEv).Meanz>RvpppaALL.Ev(RightEv).Meanz;
  127. selection3=selectionInst & Stat<0.05 & RvpppaALL.Ev(LeftEv).Meanz<RvpppaALL.Ev(RightEv).Meanz;
  128. scatter(RvpppaALL.Ev(LeftEv).Meanz(selection1),RvpppaALL.Ev(RightEv).Meanz(selection1),30, 'k');%,'filled');
  129. scatter(RvpppaALL.Ev(LeftEv).Meanz(selection2),RvpppaALL.Ev(RightEv).Meanz(selection2),30, DarkPink);
  130. scatter(RvpppaALL.Ev(LeftEv).Meanz(selection3),RvpppaALL.Ev(RightEv).Meanz(selection3),30, DarkGreen);
  131. %selection4= R.Ev(RightEv).RespDir==1 & R.Ev(6).RespDir==1;
  132. %scatter(R.Ev(LeftEv).Meanz(selection4),R.Ev(RightEv).Meanz(selection4),30,'g','filled');
  133. xlabel('DS Response Magnitude (z-score)');
  134. ylabel('NS Response magnitude (z-score)');
  135. legend('DS=NS','DS>NS','DS<NS','Location','northwest','AutoUpdate','off');
  136. else %PS
  137. if LeftEv==1, Stat=RvppaALL.CSStat;
  138. elseif LeftEv==3, Stat=RvppaALL.CSResponseStat;
  139. end
  140. selection1=selectionPav & Stat>=0.05;
  141. selection2=selectionPav & Stat<0.05 & RvppaALL.Ev(LeftEv).Meanz>RvppaALL.Ev(RightEv).Meanz;
  142. selection3=selectionPav & Stat<0.05 & RvppaALL.Ev(LeftEv).Meanz<RvppaALL.Ev(RightEv).Meanz;
  143. scatter(RvppaALL.Ev(LeftEv).Meanz(selection1),RvppaALL.Ev(RightEv).Meanz(selection1),30, 'k');%,'filled');
  144. scatter(RvppaALL.Ev(LeftEv).Meanz(selection2),RvppaALL.Ev(RightEv).Meanz(selection2),30, DarkPink);
  145. scatter(RvppaALL.Ev(LeftEv).Meanz(selection3),RvppaALL.Ev(RightEv).Meanz(selection3),30, DarkGreen);
  146. Min=floor(min([RvppaALL.Ev(LeftEv).Meanz(selection2);RvppaALL.Ev(RightEv).Meanz(selection2)]));
  147. Max=ceil(max([RvppaALL.Ev(LeftEv).Meanz(selection2);RvppaALL.Ev(RightEv).Meanz(selection2)]));
  148. xlabel('CS+ Response Magnitude (z-score)');
  149. ylabel('CS- Response magnitude (z-score)');
  150. legend('CS+=CS-','CS+>CS-','CS+<CS-','Location','northwest','AutoUpdate','off');
  151. end
  152. Min=floor(min([RvpppaALL.Ev(LeftEv).Meanz(RvpppaALL.Structure==10);RvpppaALL.Ev(RightEv).Meanz(RvpppaALL.Structure==10)]));
  153. Max=ceil(max([RvpppaALL.Ev(LeftEv).Meanz(RvpppaALL.Structure==10);RvpppaALL.Ev(RightEv).Meanz(RvpppaALL.Structure==10)]));
  154. line([Min Max],[Min Max],'Color', 'k');
  155. line([Min Max], [0 0],'Color', 'k');
  156. line([0 0], [Min Max],'Color', 'k');
  157. subplot(10,6,58); %Histograms for scatterplots
  158. if LeftEv==1, Stat=RvpppaALL.CSStat;
  159. elseif LeftEv==3, Stat=RvpppaALL.CSPlusResponseStat;
  160. end
  161. axis([-10 10 0 .25]);
  162. edges = [-10:1:9];
  163. selection1=selectionInst & Stat>=0.05;
  164. selection2=selectionInst & Stat<0.05 & RvpppaALL.Ev(LeftEv).Meanz>RvpppaALL.Ev(RightEv).Meanz;
  165. selection3=selectionInst & Stat<0.05 & RvpppaALL.Ev(LeftEv).Meanz<RvpppaALL.Ev(RightEv).Meanz;
  166. Delta1= RvpppaALL.Ev(LeftEv).Meanz(selection1)-RvpppaALL.Ev(RightEv).Meanz(selection1);
  167. Delta2= RvpppaALL.Ev(LeftEv).Meanz(selection2)-RvpppaALL.Ev(RightEv).Meanz(selection2);
  168. Delta3= RvpppaALL.Ev(LeftEv).Meanz(selection3)-RvpppaALL.Ev(RightEv).Meanz(selection3);
  169. Delta1Hist=hist(Delta1,edges)/314;
  170. Delta2Hist=hist(Delta2,edges)/314;
  171. Delta3Hist=hist(Delta3,edges)/314;
  172. edges = [-10:1:10];
  173. histogram('FaceColor','k', 'BinEdges',edges,'BinCounts',Delta1Hist);
  174. hold on;
  175. histogram('FaceColor',DarkPink, 'BinEdges',edges,'BinCounts',Delta2Hist);
  176. histogram('FaceColor',DarkGreen, 'BinEdges',edges,'BinCounts',Delta3Hist);
  177. subplot(10,6,59); %Histograms for scatterplots
  178. if LeftEv==1, Stat=RvppaALL.CSStat;
  179. elseif LeftEv==3, Stat=RvppaALL.CSrespStat;
  180. end
  181. axis([-10 10 0 .25]);
  182. edges = [-10:1:9];
  183. selection1=selectionPav & Stat>=0.05;
  184. selection2=selectionPav & Stat<0.05 & RvppaALL.Ev(LeftEv).Meanz>RvppaALL.Ev(RightEv).Meanz;
  185. selection3=selectionPav & Stat<0.05 & RvppaALL.Ev(LeftEv).Meanz<RvppaALL.Ev(RightEv).Meanz;
  186. Delta1= RvppaALL.Ev(LeftEv).Meanz(selection1)-RvppaALL.Ev(RightEv).Meanz(selection1);
  187. Delta2= RvppaALL.Ev(LeftEv).Meanz(selection2)-RvppaALL.Ev(RightEv).Meanz(selection2);
  188. Delta3= RvppaALL.Ev(LeftEv).Meanz(selection3)-RvppaALL.Ev(RightEv).Meanz(selection3);
  189. Delta1Hist=hist(Delta1,edges)/392;
  190. Delta2Hist=hist(Delta2,edges)/392;
  191. Delta3Hist=hist(Delta3,edges)/392;
  192. edges = [-10:1:10];
  193. histogram('FaceColor','k', 'BinEdges',edges,'BinCounts',Delta1Hist);
  194. hold on;
  195. histogram('FaceColor',DarkPink, 'BinEdges',edges,'BinCounts',Delta2Hist);
  196. histogram('FaceColor',DarkGreen, 'BinEdges',edges,'BinCounts',Delta3Hist);
  197. selection1=selectionInst & ~isnan(RvpppaALL.Ev(LeftEv).Meanz) & ~isnan(RvpppaALL.Ev(RightEv).Meanz)& RvpppaALL.Ev(1).RespDir==1;% & CvpppaALL.STATSpost>=0.05;
  198. selection2=selectionPav & ~isnan(RvppaALL.Ev(LeftEv).Meanz) & ~isnan(RvppaALL.Ev(RightEv).Meanz)& RvppaALL.Ev(1).RespDir==1;% & CvppaALL.STATSpost>=0.05;
  199. %subplot of DS vs NS excited neurons
  200. if i==1
  201. selection=selection1;
  202. subplot(6,4,i+16);
  203. psthLeft=nanmean(RvpppaALL.Ev(LeftEv).PSTHz(selection,Ishow),1);
  204. semLeft=nanste(RvpppaALL.Ev(LeftEv).PSTHz(selection,Ishow),1);
  205. upLeft=psthLeft+semLeft;
  206. downLeft=psthLeft-semLeft;
  207. hold on;
  208. plot(time,psthLeft,'Color',MyBlue,'linewidth',1.5);
  209. psthRight=nanmean(RvpppaALL.Ev(RightEv).PSTHz(selection,Ishow),1);
  210. semRight=nanste(RvpppaALL.Ev(RightEv).PSTHz(selection,Ishow),1);
  211. upRight=psthRight+semRight;
  212. downRight=psthRight-semRight;
  213. plot(time,psthRight,'k','linewidth',1.5);
  214. patch([time,time(end:-1:1)],[upLeft,downLeft(end:-1:1)],MyBlue,'EdgeColor','none');alpha(0.5);
  215. patch([time,time(end:-1:1)],[upRight,downRight(end:-1:1)],'k','EdgeColor','none');alpha(0.5);
  216. plot([0 0], [-10 20],'LineStyle',':','Color','k');
  217. plot([-10 20], [0 0],'LineStyle',':','Color','k');
  218. if LeftEv==3
  219. plot([1 1], [-10 20],'LineStyle',':','Color','k');
  220. plot([2.5 2.5], [-10 20],'LineStyle',':','Color','k');
  221. elseif LeftEv==5
  222. plot([-2 -2], [-10 20],'LineStyle',':','Color','k');
  223. plot([.5 .5], [-10 20],'LineStyle',':','Color','k');
  224. elseif LeftEv==7
  225. plot([1 1], [-10 20],'LineStyle',':','Color','k');
  226. plot([5 5], [-10 20],'LineStyle',':','Color','k');
  227. end
  228. axis([Xaxis,Yaxis]);
  229. %xlabel('Time from Cue (sec)');
  230. ylabel('Average Response (z-score)');
  231. legend('DS','NS','Location','northeast');
  232. else if i==2
  233. selection=selection2;
  234. subplot(6,4,i+19);
  235. psthLeft=nanmean(RvppaALL.Ev(LeftEv).PSTHz(selection,Ishow),1);
  236. semLeft=nanste(RvppaALL.Ev(LeftEv).PSTHz(selection,Ishow),1);
  237. upLeft=psthLeft+semLeft;
  238. downLeft=psthLeft-semLeft;
  239. hold on;
  240. plot(time,psthLeft,'Color',MyOrange,'linewidth',1.5);
  241. psthRight=nanmean(RvppaALL.Ev(RightEv).PSTHz(selection,Ishow),1);
  242. semRight=nanste(RvppaALL.Ev(RightEv).PSTHz(selection,Ishow),1);
  243. upRight=psthRight+semRight;
  244. downRight=psthRight-semRight;
  245. plot(time,psthRight,'k','linewidth',1.5);
  246. patch([time,time(end:-1:1)],[upLeft,downLeft(end:-1:1)],MyOrange,'EdgeColor','none');alpha(0.5);
  247. patch([time,time(end:-1:1)],[upRight,downRight(end:-1:1)],'k','EdgeColor','none');alpha(0.5);
  248. plot([0 0], [-10 20],'LineStyle',':','Color','k');
  249. plot([-10 20], [0 0],'LineStyle',':','Color','k');
  250. if LeftEv==3
  251. plot([1 1], [-10 20],'LineStyle',':','Color','k');
  252. plot([2.5 2.5], [-10 20],'LineStyle',':','Color','k');
  253. elseif LeftEv==5
  254. plot([-2 -2], [-10 20],'LineStyle',':','Color','k');
  255. plot([.5 .5], [-10 20],'LineStyle',':','Color','k');
  256. elseif LeftEv==7
  257. plot([1 1], [-10 20],'LineStyle',':','Color','k');
  258. plot([5 5], [-10 20],'LineStyle',':','Color','k');
  259. end
  260. axis([Xaxis,Yaxis]);
  261. xlabel('Time from Cue (sec)');
  262. ylabel('Average Response (z-score)');
  263. legend('CS+','CS-','Location','northeast');
  264. end
  265. end
  266. selection1=selectionInst & ~isnan(RvpppaALL.Ev(LeftEv).Meanz) & ~isnan(RvpppaALL.Ev(RightEv).Meanz)& RvpppaALL.Ev(1).RespDir==-1;
  267. selection2=selectionPav & ~isnan(RvppaALL.Ev(LeftEv).Meanz) & ~isnan(RvppaALL.Ev(RightEv).Meanz)& RvppaALL.Ev(1).RespDir==-1;
  268. if i==1
  269. selection=selection1;
  270. subplot(6,4,i+17);
  271. psthLeft=nanmean(RvpppaALL.Ev(LeftEv).PSTHz(selection,Ishow),1);
  272. semLeft=nanste(RvpppaALL.Ev(LeftEv).PSTHz(selection,Ishow),1);
  273. upLeft=psthLeft+semLeft;
  274. downLeft=psthLeft-semLeft;
  275. hold on;
  276. plot(time,psthLeft,'Color',MyBlue,'linewidth',1.5);
  277. psthRight=nanmean(RvpppaALL.Ev(RightEv).PSTHz(selection,Ishow),1);
  278. semRight=nanste(RvpppaALL.Ev(RightEv).PSTHz(selection,Ishow),1);
  279. upRight=psthRight+semRight;
  280. downRight=psthRight-semRight;
  281. plot(time,psthRight,'k','linewidth',1.5);
  282. patch([time,time(end:-1:1)],[upLeft,downLeft(end:-1:1)],MyBlue,'EdgeColor','none');alpha(0.5);
  283. patch([time,time(end:-1:1)],[upRight,downRight(end:-1:1)],'k','EdgeColor','none');alpha(0.5);
  284. plot([0 0], [-10 20],'LineStyle',':','Color','k');
  285. plot([-10 20], [0 0],'LineStyle',':','Color','k');
  286. if LeftEv==3
  287. plot([1 1], [-10 20],'LineStyle',':','Color','k');
  288. plot([2.5 2.5], [-10 20],'LineStyle',':','Color','k');
  289. elseif LeftEv==5
  290. plot([-2 -2], [-10 20],'LineStyle',':','Color','k');
  291. plot([.5 .5], [-10 20],'LineStyle',':','Color','k');
  292. elseif LeftEv==7
  293. plot([1 1], [-10 20],'LineStyle',':','Color','k');
  294. plot([5 5], [-10 20],'LineStyle',':','Color','k');
  295. end
  296. axis([Xaxis,Yaxis]);
  297. legend('DS','NS','Location','northwest');
  298. %xlabel('Time from Cue (sec)');
  299. %ylabel('Average Response (z-score)');
  300. else if i==2
  301. selection=selection2;
  302. subplot(6,4,i+20);
  303. psthLeft=nanmean(RvppaALL.Ev(LeftEv).PSTHz(selection,Ishow),1);
  304. semLeft=nanste(RvppaALL.Ev(LeftEv).PSTHz(selection,Ishow),1);
  305. upLeft=psthLeft+semLeft;
  306. downLeft=psthLeft-semLeft;
  307. hold on;
  308. plot(time,psthLeft,'Color',MyOrange,'linewidth',1.5);
  309. psthRight=nanmean(RvppaALL.Ev(RightEv).PSTHz(selection,Ishow),1);
  310. semRight=nanste(RvppaALL.Ev(RightEv).PSTHz(selection,Ishow),1);
  311. upRight=psthRight+semRight;
  312. downRight=psthRight-semRight;
  313. plot(time,psthRight,'k','linewidth',1.5);
  314. patch([time,time(end:-1:1)],[upLeft,downLeft(end:-1:1)],MyOrange,'EdgeColor','none');alpha(0.5);
  315. patch([time,time(end:-1:1)],[upRight,downRight(end:-1:1)],'k','EdgeColor','none');alpha(0.5);
  316. plot([0 0], [-10 20],'LineStyle',':','Color','k');
  317. plot([-10 20], [0 0],'LineStyle',':','Color','k');
  318. if LeftEv==3
  319. plot([1 1], [-10 20],'LineStyle',':','Color','k');
  320. plot([2.5 2.5], [-10 20],'LineStyle',':','Color','k');
  321. elseif LeftEv==5
  322. plot([-2 -2], [-10 20],'LineStyle',':','Color','k');
  323. plot([.5 .5], [-10 20],'LineStyle',':','Color','k');
  324. elseif LeftEv==7
  325. plot([1 1], [-10 20],'LineStyle',':','Color','k');
  326. plot([5 5], [-10 20],'LineStyle',':','Color','k');
  327. end
  328. axis([Xaxis,Yaxis]);
  329. xlabel('Time from Cue (sec)');
  330. %ylabel('Average Response (z-score)');
  331. legend('CS+','CS-','Location','northwest');
  332. end
  333. end
  334. end
  335. subplot(9,2,[14 18]);
  336. %Plot of auROC descriptions for CS versus DS on response versus no response
  337. %(percent of neurons!)
  338. sel1=RvpppaALL.Structure~=0;
  339. sel2=RvppaALL.Structure~=0;
  340. axis([0 1 0 .25]);
  341. %histogram(-RvpppaALL.CSauROC(RvpppaALL.Structure==10),[0:0.05:1],'Normalization','probability');
  342. cdfplot(-RvpppaALL.CSauROC(RvpppaALL.Structure==10 & RvpppaALL.CSPlusRatio>=.5 & (RvpppaALL.CSPlusRatio./(RvpppaALL.CSPlusRatio+RvpppaALL.CSMinusRatio))>=.7));
  343. hold on;
  344. cdfplot(-RvppaALL.CSauROC(RvppaALL.Structure==10 & RvppaALL.CSPlusRatio>=.5 & (RvppaALL.CSPlusRatio./(RvppaALL.CSPlusRatio+RvppaALL.CSMinusRatio))>=.7));
  345. %histogram(-RvppaALL.CSauROC(RvppaALL.Structure==10),[0:0.05:1],'Normalization','probability');
  346. MEANsel1=nanmedian(-RvpppaALL.CSauROC(RvpppaALL.Structure==10 & RvpppaALL.CSPlusRatio>=.5 & (RvpppaALL.CSPlusRatio./(RvpppaALL.CSPlusRatio+RvpppaALL.CSMinusRatio))>=.7));
  347. MEANsel2=nanmedian(-RvppaALL.CSauROC(RvppaALL.Structure==10 & RvppaALL.CSPlusRatio>=.5 & (RvppaALL.CSPlusRatio./(RvppaALL.CSPlusRatio+RvppaALL.CSMinusRatio))>=.7));
  348. plot([MEANsel1 MEANsel1], [0 1],'Color',MyBlue);
  349. plot([MEANsel2 MEANsel2], [0 1],'Color',MyOrange);
  350. plot([.5 .5], [0 1],'Color','k');
  351. legend('DS','CS+','Location','northwest');
  352. xlabel('Cue Identity auROC');
  353. ylabel('Proportion of Neurons');
  354. %% Figure 2. VP neurons respond to cues and reward seeking in both tasks.
  355. figure;
  356. %DS
  357. subplot(4,5,11);
  358. exc=sum((RvpppaALL.Ev(1).RFLAG(selectionInst)==1 | RvpppaALL.Ev(1).RespDir(selectionInst)==1) & RvpppaALL.Ev(1).RFLAG(selectionInst)~=-1 & RvpppaALL.Ev(1).RespDir(selectionInst)~=-1);
  359. inh=sum(RvpppaALL.Ev(1).RespDir(selectionInst)==-1 | RvpppaALL.Ev(1).RFLAG(selectionInst)==-1);
  360. no=sum(RvpppaALL.Ev(1).RFLAG(selectionInst)==0 & RvpppaALL.Ev(1).RespDir(selectionInst)==0);
  361. response=[exc inh no];
  362. labels = {'Excited','Inhibited','No Response'};
  363. pie(response);
  364. colormap([252/255 206/255 46/255; %// excitation yellow
  365. 50/255 67/255 186/255; %// inhibition blue
  366. 46/255 183/255 164/255]); %// no response teal
  367. title('DS');
  368. %CS+
  369. subplot(4,5,12);
  370. exc=sum((RvppaALL.Ev(1).RFLAG(selectionPav)==1 | RvppaALL.Ev(1).RespDir(selectionPav)==1) & RvppaALL.Ev(1).RFLAG(selectionPav)~=-1 & RvppaALL.Ev(1).RespDir(selectionPav)~=-1);
  371. inh=sum(RvppaALL.Ev(1).RespDir(selectionPav)==-1 | RvppaALL.Ev(1).RFLAG(selectionPav)==-1);
  372. no=sum(RvppaALL.Ev(1).RFLAG(selectionPav)==0 & RvppaALL.Ev(1).RespDir(selectionPav)==0);
  373. response=[exc inh no];
  374. pie(response);
  375. title('CS+');
  376. %DS port entry
  377. subplot(4,5,13);
  378. exc=sum((RvpppaALL.Ev(8).RFLAG(selectionInst)==1 | RvpppaALL.Ev(8).RespDir(selectionInst)==1) & RvpppaALL.Ev(5).RFLAG(selectionInst)~=-1 & RvpppaALL.Ev(5).RespDir(selectionInst)~=-1);
  379. inh=sum(RvpppaALL.Ev(8).RespDir(selectionInst)==-1 | RvpppaALL.Ev(8).RFLAG(selectionInst)==-1);
  380. no=sum(RvpppaALL.Ev(8).RFLAG(selectionInst)==0 & RvpppaALL.Ev(8).RespDir(selectionInst)==0);
  381. response=[exc inh no];
  382. labels = {'Excited','Inhibited','No Response'};
  383. pie(response);
  384. title('post-DS Port Entry');
  385. %CS+ port entry
  386. subplot(4,5,14);
  387. exc=sum((RvppaALL.Ev(8).RFLAG(selectionPav)==1 | RvppaALL.Ev(8).RespDir(selectionPav)==1) & RvppaALL.Ev(5).RFLAG(selectionPav)~=-1 & RvppaALL.Ev(5).RespDir(selectionPav)~=-1);
  388. inh=sum(RvppaALL.Ev(8).RespDir(selectionPav)==-1 | RvppaALL.Ev(8).RFLAG(selectionPav)==-1);
  389. no=sum(RvppaALL.Ev(8).RFLAG(selectionPav)==0 & RvppaALL.Ev(8).RespDir(selectionPav)==0);
  390. response=[exc inh no];
  391. h=pie(response);
  392. title('post-CS+ Port Entry');
  393. %CS+ reward
  394. subplot(4,5,15);
  395. exc=sum((RvppaALL.Ev(9).RFLAG(selectionPav)==1 | RvppaALL.Ev(9).RespDir(selectionPav)==1) & RvppaALL.Ev(7).RFLAG(selectionPav)~=-1 & RvppaALL.Ev(7).RespDir(selectionPav)~=-1);
  396. inh=sum(RvppaALL.Ev(9).RespDir(selectionPav)==-1 | RvppaALL.Ev(9).RFLAG(selectionPav)==-1);
  397. no=sum(RvppaALL.Ev(9).RFLAG(selectionPav)==0 & RvppaALL.Ev(9).RespDir(selectionPav)==0);
  398. response=[exc inh no];
  399. h=pie(response);
  400. title('post-CS+ Reward');