create_figures.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. %% Script to create the figures for the written part of the thesis
  2. % This script creates and modifies the figured needed for the written part
  3. % of the thesis. The aim is to create more or less standardized figures.
  4. % They are saved in the 'Figures' folder automatically. All figures are
  5. % created in the order of appearance in the thesis and the numbers here
  6. % match those in the text.
  7. % -------------------------------------------------------------------------
  8. % Program by: Bjarne Schultze [last modified: 07.03.2022]
  9. % -------------------------------------------------------------------------
  10. %% Paragraph to create the figures for the description of the dataset
  11. % recording example
  12. % plot the data, catch the figure handle and the handle to the tiled layout
  13. plotData(15,1);
  14. fig1 = gcf;
  15. tyldlyt = fig1.Children;
  16. % remove title from the tiled layout
  17. tyldlyt.Title.String = [];
  18. % change panel titles to A,B,C
  19. ax = tyldlyt.Children;
  20. ax(3).Title.String = 'A'; ax(2).Title.String = 'B';
  21. ax(1).Title.String = 'C';
  22. % improve the appearence
  23. enhance_figures(fig1,'KeepTitles');
  24. % Save the figure as an image
  25. print(fig1, "../Figures/example_recording", "-dpng", "-r1200");
  26. % close figure window to safely reset all changes
  27. close(fig1);
  28. %% Paragraph to create the figures for the methods-part
  29. % ---- for the manual analysis (examplary reactions) ----------------------
  30. % access the data
  31. data13 = extract_data(13, 'no'); data13 = data13{1};
  32. data15 = extract_data(15, 'no'); data15 = data15{1};
  33. % set up the figure
  34. fig2 = figure;
  35. tiledlayout(1,3);
  36. % plot the examplary data
  37. nexttile % T cell stimulated, int EPSPs
  38. stackedplot(data13.timeVector(108000:137000), ...
  39. [data13.recordingT(108000:137000,8), ...
  40. data13.recordingINT(108000:137000,8)], 'DisplayLabels', ...
  41. {["T cell","membrane potential [mV]"], ...
  42. ["interneuron","membrane potential [mV]"]});
  43. xlabel("time [s]"); title("A");
  44. nexttile % T cell stimulated, int spikes
  45. stackedplot(data15.timeVector(108000:137000), ...
  46. [data15.recordingT(108000:137000,9), ...
  47. data15.recordingINT(108000:137000,9)], 'DisplayLabels', ...
  48. ["", ""]);
  49. xlabel("time [s]"); title("B");
  50. nexttile % int stimulated, T cell graded hyperpolarization
  51. stackedplot(data13.timeVector(108000:137000), ...
  52. [data13.recordingT(108000:137000,9), ...
  53. data13.recordingINT(108000:137000,9)], 'DisplayLabels', ...
  54. ["", ""]);
  55. xlabel("time [s]"); title("C");
  56. % improve the figure appearance
  57. enhance_figures(fig2, 'KeepTitles');
  58. % Save the figure as an image
  59. print(fig2, "../Figures/example_reactions", "-dpng", "-r1200");
  60. % close figure to safely reset all figure properties
  61. close(fig2);
  62. % ---- for the amplitude during stimulation -------------------------------
  63. % clipping of the test function output for explanation purposes
  64. % call function and catch the right figure handle
  65. ampAtStim_funtest(32,6);
  66. close(2)
  67. fig3 = figure(1);
  68. % improve the figure appearence
  69. enhance_figures(fig3)
  70. % get the axes handles of the tiled layout
  71. children_tlyt = fig3.Children.Children;
  72. ax1 = children_tlyt(3);
  73. ax2 = children_tlyt(4);
  74. % adjust the axes limits to get a clipping of the polts
  75. ax1.XLim = [10, 14.5];
  76. ax2.XLim = [10, 14.5];
  77. % remove the legends
  78. legend(ax1, 'off'); legend(ax2, 'off');
  79. % label panles with A and B
  80. ax1.Title.String = "B"; ax2.Title.String = "A";
  81. % increase the font size of the text for both panels seperately
  82. gchilds1 = ax1.Children;
  83. gchilds2 = ax2.Children;
  84. for child = 1:length(gchilds1) % panel 1
  85. if isequal(gchilds1(child).Type, 'text')
  86. gchilds1(child).FontSize = 12;
  87. end
  88. end
  89. for child = 1:length(gchilds2) % panel 2
  90. if isequal(gchilds2(child).Type, 'text')
  91. gchilds2(child).FontSize = 12;
  92. end
  93. end
  94. % Save the figure as an image
  95. print(fig3, "../Figures/expl_current_amplitude", "-dpng", "-r1200");
  96. % close figure window to safely reset all changes
  97. close(fig3);
  98. % ----- for the spike triggered average of the postsynaptic response ------
  99. % call function and catch figure handle
  100. spikeTrigAvg_postsyn(32);
  101. fig4 = gcf;
  102. % improve figure appearance
  103. enhance_figures(fig4);
  104. % Save the figure as an image
  105. print(fig4, "../Figures/spikeTrigAvg_postsyn", "-dpng", "-r1200");
  106. % close figure window to safely reset all changes
  107. close(fig4);
  108. % ----- for the spike triggered average of the presynaptic potential ------
  109. % call function and get the figure handle
  110. spikeTrigAvg_presyn(54);
  111. fig5 = gcf;
  112. % adjust the figure appearance
  113. enhance_figures(fig5)
  114. % Save the figure as an image
  115. print(fig5, "../Figures/spikeTrigAvg_presyn", "-dpng", "-r1200");
  116. % close figure to safely reset all figure properties
  117. close(fig5);
  118. % ----- for the spike count current plot ----------------------------------
  119. % call function and get the figure handle
  120. plot_FI(52);
  121. fig6 = gcf;
  122. % adjust figure appearance
  123. enhance_figures(fig6)
  124. % save the figure as an image
  125. print(fig6, "../Figures/current_spike_count", "-dpng", "-r1200");
  126. % close figure to safely reset all figure properties
  127. close(fig6);
  128. % ----- for the methods valitation part -----------------------------------
  129. % clipping of the average spike response test function
  130. % call the function and catch the figure handle, close the others
  131. spikeTrigAvg_postsyn_funtest(32);
  132. close([1,2,4,5,6,7])
  133. fig7 = gcf;
  134. % get the axes handle
  135. ax7 = fig7.CurrentAxes;
  136. % modify the axes limits to get a clipping of the plot
  137. xlim(ax7, [13.13, 13.55]);
  138. % improve figure appearance
  139. enhance_figures(fig7);
  140. % Save the figure as an image
  141. print(fig7, "../Figures/test_spikeTrigAvg_postsyn", "-dpng", "-r1200");
  142. % close figure to safely reset all figure properties
  143. close(fig7);
  144. %% Create figures for the first part of the results section
  145. % ---- for the general tendencies, most common behaviours -----------------
  146. % get the appropriate data and set up the figure window
  147. data1 = extract_data(14, 'no'); data1 = data1{1}; trial = 13;
  148. fig8 = figure();
  149. tyldlyt = tiledlayout(1,2);
  150. selection_window = 65000:140000;
  151. nexttile % T cell stimulated, int EPSPs
  152. stackedplot(data1.timeVector(selection_window), ...
  153. [data1.recordingT(selection_window,trial), ...
  154. data1.recordingINT(selection_window,trial)], 'DisplayLabels', ...
  155. {["T cell","membrane potential [mV]"], ...
  156. ["interneuron","membrane potential [mV]"]});
  157. xlabel("time [s]"); title("A");
  158. nexttile % int stimulated, T cell graded hyperpolarizations
  159. stackedplot(data1.timeVector(selection_window), ...
  160. [data1.recordingT(selection_window,18), ...
  161. data1.recordingINT(selection_window,18)], 'DisplayLabels', ...
  162. ["", ""]);
  163. xlabel("time [s]"); title("B");
  164. % improve figure appearance
  165. enhance_figures(fig8, 'KeepTitles');
  166. % Save the figure as an image
  167. print(fig8, "../Figures/general_tendencies", "-dpng", "-r1200");
  168. % close figure to safely reset all figure properties
  169. close(fig8);
  170. % ---- for the three main clustering criteria -----------------------------
  171. % load the data for this criteria from the AdditionalFiles directory
  172. load("../AdditionalFiles/decisionData.mat")
  173. % set the font size for the histogram legends
  174. fontSze = 12;
  175. fig9 = figure('Position',[106,220,1325,552]);
  176. tldlyt = tiledlayout(fig9,1,3);
  177. % histogram for the spike amplitude
  178. % devide the spike heights into groups resembild the groups later used for
  179. % clusting
  180. sh_group0 = spike_heights(spike_heights < 0);
  181. sh_group1 = spike_heights(spike_heights < 9 & spike_heights >= 0);
  182. sh_group2 = spike_heights(spike_heights < 30 & spike_heights >= 9);
  183. sh_group3 = spike_heights(spike_heights >= 30);
  184. % create the histograms with a defined bin width
  185. nexttile
  186. binW = 1.5;
  187. histogram(sh_group1, 'BinLimits', [-1.5,7.5], 'BinWidth', binW, ...
  188. 'LineWidth',1)
  189. hold on;
  190. histogram(sh_group2, 'BinLimits', [9,21], 'BinWidth', binW, 'LineWidth',1)
  191. histogram(sh_group3, 'BinLimits', [33,57], 'BinWidth', binW, ...
  192. 'LineWidth',1)
  193. histogram(sh_group0, 'BinLimits', [-10,-8.5], 'BinWidth', binW, ...
  194. 'LineWidth',1)
  195. hold off;
  196. ylim([0,28]);
  197. % labelling
  198. xlabel("sipke amplitude [mV]"); ylabel("count");
  199. legend("small spikes", "medium spikes", "large spikes", "no spikes", ...
  200. 'Location','northeast', 'FontSize',fontSze);
  201. title("A")
  202. % get the axes handle for the first histogram
  203. axA = gca;
  204. % histogram for the T cell amplitude during -2 nA int stimulation
  205. % devide the amplitude in two groups (hyperpolarization and no
  206. % hyperpolarization)
  207. hypT_group0 = amp_minus2nA_stim(amp_minus2nA_stim==0 | ...
  208. amp_minus2nA_stim>0);
  209. hypT_group1 = amp_minus2nA_stim(amp_minus2nA_stim < 0);
  210. % plot the two groups in one histogram with different colors
  211. nexttile
  212. binW = 0.5;
  213. histogram(hypT_group1, 'BinLimits',[-10,0], 'BinWidth',binW, ...
  214. 'LineWidth',1, 'FaceColor', [0.3 0.6 0.85])
  215. hold on;
  216. histogram(hypT_group0, 'BinLimits',[0,0.5], 'BinWidth',binW, ...
  217. 'LineWidth',1, 'FaceColor', [0.9 0.15 0.15])
  218. hold off;
  219. ylim([0, 28]);
  220. % labelling
  221. xlabel("T cell amplitude for -2 nA stimulus [mV]", ...
  222. 'Position', [-4.697,-2.41,-1]); ylabel("count");
  223. legend("hyperpolarization", "no hyperpolarization", ...
  224. 'Location','northeast','FontSize',fontSze)
  225. title("B")
  226. % histogram for the latency of the interneuron reaction
  227. % devide the latencies into groups resembling those used in the analysis
  228. lat_group0 = latencies(eq(latencies,60));
  229. lat_group1 = latencies(latencies < 5);
  230. lat_group2 = latencies(latencies >= 5 & latencies < 60);
  231. % plot the single groups in one histogram with different colors
  232. nexttile
  233. binW = 2.5;
  234. histogram(lat_group1, 'BinLimits',[0,5], 'BinWidth',binW,'LineWidth',1, ...
  235. 'FaceColor', [0.9 0.85 0])
  236. hold on;
  237. histogram(lat_group2, 'BinLimits',[5,27.5], 'BinWidth',binW, ...
  238. 'LineWidth',1, 'FaceColor', [0 0.7 0.8])
  239. histogram(lat_group0, 'BinLimits',[57.5,60], 'BinWidth',binW, ...
  240. 'LineWidth',1, 'FaceColor', [0.8, 0.1 0.6])
  241. hold off;
  242. ylim([0,28]);
  243. % labelling
  244. xlabel("latency of interneuron reaction [ms]"); ylabel("count");
  245. legend("fast reaction", "slower reaction", "no/very slow reaction", ...
  246. 'Location','northeast','FontSize',fontSze)
  247. title("C")
  248. % get the axis handle for later changes
  249. axC = gca;
  250. % improve the appearance
  251. enhance_figures(fig9,'KeepTitles')
  252. fig9.Position = [106 220 1325 552];
  253. % change the tick values for the first histogram
  254. axA.XTick = [-10,0,10,20,30,40,50,60];
  255. axA.XTickLabel(1) = {'no spikes'};
  256. axA.XTickLabelRotation = -30;
  257. axA.XLabel.Position = [22.14,-2.46,-1];
  258. % change the tick values for the last histogram
  259. axC.XTick = [0,10,20,30,40,50,60];
  260. axC.XTickLabel(7) = {'no reaction'};
  261. axC.XTickLabelRotation = -30;
  262. axC.XLabel.Position = [30.61,-2.46,-1];
  263. % Save the figure as an image
  264. print(fig9, "../Figures/hist_important_features", "-dpng", "-r1200");
  265. % close figure to safely reset all figure properties
  266. close(fig9);
  267. %% create figures for the clustering results within the results section
  268. % ---- scatter plot for the bild approach ---------------------------------
  269. % load the file containing the deanonymization information
  270. load("../AdditionalFiles/deanonymization.mat")
  271. % get the numbers of the cells in each package
  272. pack_1_3 = find(eq(deanonymization.package(:,1),13));
  273. pack_2 = find(eq(deanonymization.package(:,1),2));
  274. pack_4_6 = find(eq(deanonymization.package(:,1),46));
  275. pack_5 = find(eq(deanonymization.package(:,1),5));
  276. % take the assigned cell types into account
  277. int218 = find(eq(deanonymization.cellType(:,1),218));
  278. int162 = find(eq(deanonymization.cellType(:,1),162));
  279. int264 = find(eq(deanonymization.cellType(:,1),264));
  280. int212 = find(eq(deanonymization.cellType(:,1),212));
  281. int201203 = find(eq(deanonymization.cellType(:,1),201203));
  282. int159 = find(eq(deanonymization.cellType(:,1),159));
  283. int157 = find(eq(deanonymization.cellType(:,1),157));
  284. int6061 = find(eq(deanonymization.cellType(:,1),6061));
  285. % scatter plot with the package information included
  286. fig10 = figure();
  287. scatter3(spike_heights(pack_1_3),amp_minus2nA_stim(pack_1_3), ...
  288. latencies(pack_1_3), 'MarkerEdgeColor',[0,0,0], 'MarkerFaceColor', ...
  289. [0 0.66 0.85])
  290. hold on;
  291. scatter3(spike_heights(pack_2),amp_minus2nA_stim(pack_2),latencies(pack_2), ...
  292. 'MarkerEdgeColor',[0,0,0], 'MarkerFaceColor',[1,0.48,0])
  293. scatter3(spike_heights(pack_4_6),amp_minus2nA_stim(pack_4_6), ...
  294. latencies(pack_4_6), 'MarkerEdgeColor',[0,0,0], 'MarkerFaceColor', ...
  295. [0,0.87,0])
  296. scatter3(spike_heights(pack_5),amp_minus2nA_stim(pack_5),latencies(pack_5), ...
  297. 'MarkerEdgeColor',[0,0,0], 'MarkerFaceColor',[0.8,0,1])
  298. hold off;
  299. % labelling
  300. xlabel("spike amplitude [mV]");
  301. ylabel("T cell amplitude [mV]");
  302. zlabel("latency [ms]");
  303. lgnd = legend("Packages 1 & 3", "Package 2", "Packages 4 & 6", ...
  304. "Packages 5", 'FontSize', fontSze);
  305. % adapt the plot style
  306. enhance_figures(fig10);
  307. ax = gca;
  308. ax.CameraPosition = [228,-78,264];
  309. lgnd.Position = [0.72,0.67,0.18,0.16];
  310. ax.XLabel.Rotation = -5;
  311. ax.XTick = [-10, 0, 10, 20, 30, 40, 50, 60];
  312. ax.XTickLabel(1) = {'no spikes'};
  313. ax.XLabel.Position = [30.4,-10.2,-5.7];
  314. ax.XTickLabelRotation = 34;
  315. ax.YLabel.Rotation = 34;
  316. ax.YLabel.Position = [66.2,-4.8,-2.6];
  317. ax.YTickLabelRotation = -6;
  318. ax.ZTick = [0,10,20,30,40,50,60];
  319. ax.ZTickLabel(7) = {'no reaction'};
  320. ax.ZLabel.Position = [-14.97,-10.29,30.00];
  321. % save the figure to a png file
  322. print(fig10, "../Figures/scatter_blind_approach", "-dpng", "-r1200")
  323. % close the current figure
  324. close(fig10)
  325. % ---- scatter plots for packages 4 to 5 ----------------------------------
  326. % set up the figure
  327. fig11 = figure;
  328. tiledlayout(1,2)
  329. % plot the data
  330. nexttile % packages 4 and 6 (interneurons 60-61)
  331. scatter3(spike_heights(int6061),amp_minus2nA_stim(int6061),...
  332. latencies(int6061), 'MarkerEdgeColor',[0,0,0], ...
  333. 'MarkerFaceColor',[0.87,0.87,0.23]);
  334. title("A")
  335. % labelling
  336. xlabel("spike amplitude [mV]");
  337. ylabel("T cell amplitude [mV]");
  338. zlabel("latency [ms]");
  339. legend("int 60-61")
  340. nexttile % package 5 (interneuron 264)
  341. scatter3(spike_heights(int264),amp_minus2nA_stim(int264),...
  342. latencies(int264),'MarkerEdgeColor',[0,0,0], ...
  343. 'MarkerFaceColor',[0,0.4,0.7]);
  344. title("B")
  345. % labelling
  346. xlabel("spike amplitude [mV]");
  347. ylabel("T cell amplitude [mV]");
  348. zlabel("latency [ms]");
  349. legend("int 264")
  350. % improve the figure appearance
  351. enhance_figures(fig11,'KeepTitles')
  352. fig11.Position = [1,49,1536,740.8];
  353. ax = fig11.Children.Children;
  354. ax(2).TitleFontSizeMultiplier = 1.7;
  355. ax(4).TitleFontSizeMultiplier = 1.7;
  356. % align and adjust the scatter plots
  357. ax(4).XLim = [-10,60]; ax(4).YLim = [-10,0]; ax(4).ZLim = [0,60];
  358. ax(4).CameraPosition = [362.39,-65.15,266.87];
  359. ax(4).XTick = [-10, 0, 10, 20, 30, 40, 50, 60];
  360. ax(4).XTickLabel(1) = {'no spikes'};
  361. ax(4).XLabel.Rotation = -19;
  362. ax(4).XLabel.Position = [18.244,-7.199,-16.297];
  363. ax(4).XTickLabelRotation = 31;
  364. ax(4).YLabel.Rotation = 31;
  365. ax(4).YLabel.Position = [57.94,-3.20,-6.03];
  366. ax(4).YTickLabelRotation = -19;
  367. ax(4).ZTick = [0,10,20,30,40,50,60];
  368. ax(4).ZTickLabel(7) = {'no reaction'};
  369. ax(4).ZLabel.Position = [-14.59,-10.526,30.00];
  370. % adapt the position of the legend
  371. ax(3).Position = [0.395,0.741,0.07,0.03];
  372. % align and adjust the scatter plots
  373. ax(2).XLim = [-10,60]; ax(2).YLim = [-10,0]; ax(2).ZLim = [0,60];
  374. ax(2).CameraPosition = [336.046,-69.564,251.027];
  375. ax(2).XTick = [-10, 0, 10, 20, 30, 40, 50, 60];
  376. ax(2).XTickLabel(1) = {'no spikes'};
  377. ax(2).XLabel.Rotation = -15;
  378. ax(2).XLabel.Position = [34.55,-9.89,-5.14];
  379. ax(2).XTickLabelRotation = 33;
  380. ax(2).YLabel.Rotation = 33;
  381. ax(2).YLabel.Position = [65.95,-4.644,-0.10];
  382. ax(2).YTickLabelRotation = -15;
  383. ax(2).ZTick = [0,10,20,30,40,50,60];
  384. ax(2).ZTickLabel(7) = {'no reaction'};
  385. ax(2).ZLabel.Position = [-14.91,-10.48,30.00];
  386. % adapt the postion of the legend
  387. ax(1).Position = [0.89,0.763,0.062,0.03];
  388. % Save the figure as an image
  389. print(fig11, "../Figures/scatter_4-6", "-dpng", "-r1200");
  390. % close figure window to safely reset all changes
  391. close(fig11);
  392. % ---- scatter plot for packge 2 ------------------------------------------
  393. % plot the data
  394. fig12 = figure;
  395. scatter3(spike_heights(int218), amp_minus2nA_stim(int218), ...
  396. latencies(int218),'MarkerEdgeColor',[0,0,0], ...
  397. 'MarkerFaceColor',[0.4,0.8,0.8])
  398. hold on;
  399. scatter3(spike_heights(int212), amp_minus2nA_stim(int212), ...
  400. latencies(int212),'MarkerEdgeColor',[0,0,0], ...
  401. 'MarkerFaceColor',[0.8,0.2,0.1])
  402. scatter3(spike_heights(int201203),amp_minus2nA_stim(int201203),...
  403. latencies(int201203), 'MarkerEdgeColor',[0,0,0],...
  404. 'MarkerFaceColor', [0.4,0.7,0.1])
  405. hold off;
  406. % labelling
  407. xlabel("spike amplitude [mV]");
  408. ylabel("T cell amplitude [mV]");
  409. zlabel("latency [ms]");
  410. legend("int 218","int 212", "int 201-203")
  411. enhance_figures(fig12)
  412. ax = fig12.Children;
  413. ax(2).XLim = [-10,60]; ax(2).YLim = [-10,0]; ax(2).ZLim = [0,60];
  414. ax(2).CameraPosition = [266.6,-71.21,293.2];
  415. ax(2).XLabel.Rotation = -8;
  416. ax(2).XTickLabelRotation = 29;
  417. ax(2).XTick = [-10, 0, 10, 20, 30, 40, 50, 60];
  418. ax(2).XTickLabel(1) = {'no spikes'};
  419. ax(2).XLabel.Position = [10.39,-4.49,-28.57];
  420. ax(2).YLabel.Rotation = 29;
  421. ax(2).YLabel.Position = [51.95,-0.73,-16.73];
  422. ax(2).YTickLabelRotation = -8;
  423. ax(2).ZTick = [0,10,20,30,40,50,60];
  424. ax(2).ZTickLabel(7) = {'no reaction'};
  425. ax(2).ZLabel.Position = [-14.82,-10.359,30.00];
  426. ax(1).Position = [0.764,0.693,0.139,0.107];
  427. % save the figure to a png file
  428. print(fig12, "../Figures/scatter_pack2", "-dpng", "-r1200")
  429. % close the current figure
  430. close(fig12)
  431. % ---- scatter plots for packages 1 and 3 ---------------------------------
  432. % plot the data
  433. fig13 = figure;
  434. scatter3(spike_heights(int159), amp_minus2nA_stim(int159), ...
  435. latencies(int159),'MarkerEdgeColor',[0,0,0], ...
  436. 'MarkerFaceColor',[0.1,0.8,0.2])
  437. hold on;
  438. scatter3(spike_heights(int157), amp_minus2nA_stim(int157), ...
  439. latencies(int157),'MarkerEdgeColor',[0,0,0], ...
  440. 'MarkerFaceColor',[1,0.75,0])
  441. scatter3(spike_heights(int162), amp_minus2nA_stim(int162), ...
  442. latencies(int162),'MarkerEdgeColor',[0,0,0], ...
  443. 'MarkerFaceColor',[0.7,0.7,0.4])
  444. hold off;
  445. % labelling
  446. xlabel("spike amplitude [mV]");
  447. ylabel("T cell amplitude [mV]");
  448. zlabel("latency [ms]");
  449. legend("int 159","int 157", "int 162")
  450. enhance_figures(fig13)
  451. ax = fig13.Children;
  452. ax(2).XLim = [-10,60]; ax(2).YLim = [-10,0]; ax(2).ZLim = [0,60];
  453. ax(2).CameraPosition = [266.6,-71.21,293.2];
  454. ax(2).XLabel.Rotation = -8;
  455. ax(2).XTickLabelRotation = 29;
  456. ax(2).XTick = [-10, 0, 10, 20, 30, 40, 50, 60];
  457. ax(2).XTickLabel(1) = {'no spikes'};
  458. ax(2).XLabel.Position = [10.39,-4.49,-28.57];
  459. ax(2).YLabel.Rotation = 29;
  460. ax(2).YLabel.Position = [51.95,-0.73,-16.73];
  461. ax(2).YTickLabelRotation = -8;
  462. ax(2).ZTick = [0,10,20,30,40,50,60];
  463. ax(2).ZTickLabel(7) = {'no reaction'};
  464. ax(2).ZLabel.Position = [-14.82,-10.359,30.00];
  465. ax(1).Position = [0.797,0.693,0.107,0.107];
  466. % save the figure to a png file
  467. print(fig13, "../Figures/scatter_pack13", "-dpng", "-r1200")
  468. % close the current figure
  469. close(fig13)
  470. % ---- additional figure for packages 1 and 3 -----------------------------
  471. % get the data and set up the figure
  472. data17 = extract_data(17,'hn'); data17 = data17{1};
  473. fig14 = figure();
  474. tiledlayout(1,2,'Padding','compact');
  475. selection_window = 65000:140000;
  476. % plot the data
  477. nexttile % T cell IPSPs, int stimulated
  478. stckplt1 = stackedplot(data17.timeVector(selection_window), ...
  479. [data17.recordingT(selection_window,8), ...
  480. data17.recordingINT(selection_window,8)], 'DisplayLabels', ...
  481. {["T cell","membrane potential [mV]"], ...
  482. ["interneuron","membrane potential [mV]"]});
  483. xlabel("time [s]"); title("A");
  484. nexttile
  485. scatter3(amp_1_5nA_stim(int159), amp_minus2nA_stim(int159), ...
  486. spike_heights(int159),'MarkerEdgeColor',[0,0,0], ...
  487. 'MarkerFaceColor',[0.1,0.8,0.2])
  488. hold on;
  489. scatter3(amp_1_5nA_stim(int157), amp_minus2nA_stim(int157), ...
  490. spike_heights(int157),'MarkerEdgeColor',[0,0,0], ...
  491. 'MarkerFaceColor',[1,0.75,0])
  492. scatter3(amp_1_5nA_stim(int162), amp_minus2nA_stim(int162), ...
  493. spike_heights(int162),'MarkerEdgeColor',[0,0,0], ...
  494. 'MarkerFaceColor',[0.7,0.7,0.4])
  495. hold off;
  496. title("B");
  497. % labelling
  498. xlabel("T cell amp for 1.5 nA stim [mV]");
  499. ylabel("T cell amp for -2 nA stim [mV]");
  500. zlabel("spike amplitude [mV]");
  501. legend("int 159","int 157", "int 162",'Location','northeast')
  502. % improve figure appearance
  503. enhance_figures(fig14,'KeepTitles')
  504. fig14.Position = [23.4,160.2,1154.4,611.2];
  505. ax = fig14.Children.Children;
  506. % align and adjust the scatter plot
  507. ax(2).CameraPosition = [-5.666,-14.243,128.2412];
  508. ax(2).XLim = [-1,0.2]; ax(2).YLim = [-2,0];
  509. ax(2).ZTick = [-10, 0, 10, 20, 30];
  510. ax(2).ZTickLabel = {'no spikes','0','10','20','30'};
  511. ax(2).ZLabel.Position = [-1.103,0.133,8.155];
  512. ax(2).XLabel.Rotation = 16;
  513. ax(2).XLabel.Position = [-0.333,-2.147,-12.449];
  514. ax(2).YLabel.Rotation = -33;
  515. ax(2).YLabel.Position = [-1.119,-0.922,-11.817];
  516. % adapt the position of the legend
  517. ax(1).Position = [0.869,0.65,0.082,0.0985];
  518. % Save the figure as an image
  519. print(fig14, "../Figures/scatter_13_additional", "-dpng", "-r1200");
  520. % close figure window to safely reset all changes
  521. close(fig14);
  522. %% End
  523. % clear all variables from the workspace
  524. clear