123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- %% fig. S3CD Heatmap
- close all;
- clear all;
- % ========================================
- %% Plot Heatmap - Go-Aligned
- % ========================================
- %prepare variables
- %load('figS3C_Calcium.mat');
- load('figS3D_Calcium.mat');
- TimeWinFrame = [-15:1:120];% -0.5 s to 4.0 s
- fs = 30;
- StimWinFrame = [16 76];
- % 1st column: Initial - Naive
- % 2nd column: Initial - Expert
- % 3rd column: Reversal - Naive
- % 4th column: Reversal - Expert
- fig1 = figure('Name', 'Heatmap_GoAlighned_AllMice');
- fig1.Position = [907 247 1020 677];
- for iPhase = 1:4 %Task phase.
- %iPhase = 1: Initial Naive
- %iPhase = 2: Initial Expert
- %iPhase = 3: Reversal Naive
- %iPhase = 4: Reversal Expert
-
- for iRow = 1:2 %1 = Go, 2 = Nogo
- ConcatCaTrace = [];
- ConcatCaTrace_Sort = [];
-
- switch iRow
- case 1 %Go trial ----------------------------------------------
- ConcatCaTrace = GoCalcium{iPhase};
-
- %Sort cells in accordance with the activity level (High-->Low)
- %Nogo trial data is sorted based on the Go trial data
- Row4Sort = mean(ConcatCaTrace(:,StimWinFrame(1):StimWinFrame(2)),2);
- [SortResp, SortID] = sortrows(Row4Sort, 'ascend');
- ConcatCaTrace_Sort = ConcatCaTrace(SortID, :);
- disp('Go')
- case 2 %Nogo trial---------------------------------------------
- ConcatCaTrace = NogoCalcium{iPhase};
- ConcatCaTrace_Sort = ConcatCaTrace(SortID,:);
- disp('Nogo')
- end%switch-iRow
-
- %Plot heatmap------------------------------------------------------
- subplot(2, 4, iPhase+(4*(iRow-1)));
- imagesc('XData', TimeWinFrame/fs, 'YData', [1 size(ConcatCaTrace_Sort, 1)], 'CData', ConcatCaTrace_Sort)%plot heatmap
- box off
- colorbar('box','off')
- caxis([-2.0 2.0])
- colormap(bluewhitered)
- hold on
-
- %Adjust y axis-----------------------------------------------------
- ylim([1 size(ConcatCaTrace_Sort, 1)]);
- yticks([1 size(ConcatCaTrace_Sort, 1)]);
-
- %Adjust x axis-----------------------------------------------------
- xlim([-0.5 4.05])
- xticks([0 2 4]);
-
- %Add title---------------------------------------------------------
- if iRow == 1
- switch iPhase
- case 1 %Initial-Naive
- title('Ini-Naive')
- ylabel('Go', 'FontSize', 10,'FontWeight','bold')
-
- case 2 %Initial-Expert
- title('Ini-Exp')
-
- case 3 %Reversal-Naive
- title('REV-Naive')
-
- case 4 %Reversal-Expert
- title('REV-Exp')
-
- end%switch-iPhase
- elseif ((iRow == 2)&& (iPhase == 1))
- ylabel('Nogo', 'FontSize', 10, 'FontWeight','bold')
- end%if iPhase
- xlabel('Time from Stim')
- end %for - iRow
- end%for - iPhase
- disp('Plot heatmap-Go aligned finished')
|