Fig2AB_Heatmap.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. %% Fig. 2AB - Heatmap
  2. close all
  3. clear all
  4. % ========================================
  5. %% Plot Heatmap - Go-kmeans
  6. % ========================================
  7. %prepare variables
  8. load('Fig2AB_Heatmap.mat');
  9. TimeWinFrame = [-15:1:120];% ca -0.5 s to 4.0 s
  10. fs = 30;
  11. for iLearning = 1:2 %Initial and Reversal
  12. ConcatCaTrace = [];
  13. trans = [];
  14. switch iLearning
  15. case 1 %Initial learning
  16. fig1 = figure('Name', 'Initial k-mean - Go cluster - Heatmap');
  17. ConcatCaTrace = Calcium_Initial;%Calcium data from initial learning
  18. trans = trans_Initial;
  19. case 2 %Reversal learning
  20. fig2 = figure('Name', 'Reversal k-mean - Go cluster - Heatmap');
  21. ConcatCaTrace = Calcium_Reversal;%Calcium data from initial learning
  22. trans = trans_Reversal;
  23. end
  24. for iColumn = 1:2 %1 = Naive, 2 = Expert
  25. switch iColumn
  26. case 1 %Naive -------------------------------------------------
  27. subplot(1,2,1);
  28. title('naive')
  29. case 2 %Expert ------------------------------------------------
  30. subplot(1,2,2);
  31. title('expert')
  32. end%switch-iRow
  33. %Plot heatmap------------------------------------------------------
  34. imagesc('XData', TimeWinFrame/fs, 'YData', [1 size(ConcatCaTrace, 1)], 'CData', ConcatCaTrace(:, :, iColumn))%plot heatmap
  35. box off
  36. %Line separating clusters
  37. lims = axis;
  38. hold all;
  39. line(repmat(lims(1:2)', 1,length(trans)),repmat(trans',2,1), 'color','k','linewidth',1)
  40. %Add colorbar
  41. colorbar;
  42. colorbar('box','off');
  43. caxis([-1.5 1.5]);
  44. colormap(bluewhitered);
  45. hold on
  46. %Adjust y axis-----------------------------------------------------
  47. ylim([1 size(ConcatCaTrace, 1)]);
  48. yticks([1 size(ConcatCaTrace, 1)]);
  49. ylabel('Celll ID')
  50. %Adjust x axis-----------------------------------------------------
  51. xticks([0 2 4]);
  52. xlabel('Time from Stimulus')
  53. end %for - iColumn
  54. end%for - iLearning