Fig1JK.m 3.1 KB

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