figS3CD_Heatmap.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. %% fig. S3CD Heatmap
  2. close all;
  3. clear all;
  4. % ========================================
  5. %% Plot Heatmap - Go-Aligned
  6. % ========================================
  7. %prepare variables
  8. %load('figS3C_Calcium.mat');
  9. load('figS3D_Calcium.mat');
  10. TimeWinFrame = [-15:1:120];% -0.5 s to 4.0 s
  11. fs = 30;
  12. StimWinFrame = [16 76];
  13. % 1st column: Initial - Naive
  14. % 2nd column: Initial - Expert
  15. % 3rd column: Reversal - Naive
  16. % 4th column: Reversal - Expert
  17. fig1 = figure('Name', 'Heatmap_GoAlighned_AllMice');
  18. fig1.Position = [907 247 1020 677];
  19. for iPhase = 1:4 %Task phase.
  20. %iPhase = 1: Initial Naive
  21. %iPhase = 2: Initial Expert
  22. %iPhase = 3: Reversal Naive
  23. %iPhase = 4: Reversal Expert
  24. for iRow = 1:2 %1 = Go, 2 = Nogo
  25. ConcatCaTrace = [];
  26. ConcatCaTrace_Sort = [];
  27. switch iRow
  28. case 1 %Go trial ----------------------------------------------
  29. ConcatCaTrace = GoCalcium{iPhase};
  30. %Sort cells in accordance with the activity level (High-->Low)
  31. %Nogo trial data is sorted based on the Go trial data
  32. Row4Sort = mean(ConcatCaTrace(:,StimWinFrame(1):StimWinFrame(2)),2);
  33. [SortResp, SortID] = sortrows(Row4Sort, 'ascend');
  34. ConcatCaTrace_Sort = ConcatCaTrace(SortID, :);
  35. disp('Go')
  36. case 2 %Nogo trial---------------------------------------------
  37. ConcatCaTrace = NogoCalcium{iPhase};
  38. ConcatCaTrace_Sort = ConcatCaTrace(SortID,:);
  39. disp('Nogo')
  40. end%switch-iRow
  41. %Plot heatmap------------------------------------------------------
  42. subplot(2, 4, iPhase+(4*(iRow-1)));
  43. imagesc('XData', TimeWinFrame/fs, 'YData', [1 size(ConcatCaTrace_Sort, 1)], 'CData', ConcatCaTrace_Sort)%plot heatmap
  44. box off
  45. colorbar('box','off')
  46. caxis([-2.0 2.0])
  47. colormap(bluewhitered)
  48. hold on
  49. %Adjust y axis-----------------------------------------------------
  50. ylim([1 size(ConcatCaTrace_Sort, 1)]);
  51. yticks([1 size(ConcatCaTrace_Sort, 1)]);
  52. %Adjust x axis-----------------------------------------------------
  53. xlim([-0.5 4.05])
  54. xticks([0 2 4]);
  55. %Add title---------------------------------------------------------
  56. if iRow == 1
  57. switch iPhase
  58. case 1 %Initial-Naive
  59. title('Ini-Naive')
  60. ylabel('Go', 'FontSize', 10,'FontWeight','bold')
  61. case 2 %Initial-Expert
  62. title('Ini-Exp')
  63. case 3 %Reversal-Naive
  64. title('REV-Naive')
  65. case 4 %Reversal-Expert
  66. title('REV-Exp')
  67. end%switch-iPhase
  68. elseif ((iRow == 2)&& (iPhase == 1))
  69. ylabel('Nogo', 'FontSize', 10, 'FontWeight','bold')
  70. end%if iPhase
  71. xlabel('Time from Stim')
  72. end %for - iRow
  73. end%for - iPhase
  74. disp('Plot heatmap-Go aligned finished')