-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakeHeatPlots.m
122 lines (102 loc) · 3.92 KB
/
makeHeatPlots.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
function makeHeatPlots(peakMap, AUCMap, timeofpeakMap,cellIR,exptSpecs,scalebarSize)
objMag=exptSpecs.objMag;
gridSize=exptSpecs.gridSize;
peakThres=exptSpecs.peakThres;
cellID=exptSpecs.cellID;
[a,b,c,d,e]=gridScaleBar(scalebarSize,objMag,gridSize);
cmp = 'jet';
%% Rotation correction: This corrects the rotation of the grid peaks w.r.t the camera frame
% When overlaying two images: camera and heatmap, the heatmap pixel#1
% should correspond to left bottom and pixel#29 should correspond to left
% top. This rotation takes care of that.
% The transformation is essentially flipping in vertical and horizontal both and then taking a transpose.
% This approach is better than changing the original peakMap because the
% original peakMap preserves the pixel identity also as 'ij' address.
peakMapFT = (rot90(peakMap,2))';
AUCMapFT = (rot90(AUCMap,2))';
timeofpeakMapFT = (rot90(timeofpeakMap,2))';
%% Peak heatmap
figure
gridPeakMap = imagesc(peakMapFT);
daspect([0.4,0.7,1])
axis on
colormap(cmp)
h = colorbar();
h.Label.String = exptSpecs.unit;
%titleString = sprintf('Peak Response from baseline(Spikes clipped at %s %s)', int2str(peakThres), exptSpecs.unit);
titleString = sprintf('Peak Response from baseline (%s)',exptSpecs.unit);
title(titleString)
%scale bar
hold on;
line(a,b,'Color','w','LineWidth',5);
text(c,d,e,'Color','w','FontWeight','bold','FontSize',14)
plotFile = strcat(cellID,'_gridPeakMap_',num2str(gridSize),'x');
print(plotFile,'-dpng')
%% AuC heatmap
figure
gridAUCMap = imagesc(AUCMapFT);
daspect([0.4,0.7,1])
axis off
colormap(cmp)
h = colorbar();
h.Label.String = 'a.u.';
title('AuC of Response')
%scale bar
hold on;
line(a,b,'Color','w','LineWidth',5);
text(c,d,e,'Color','w','FontWeight','bold','FontSize',14)
plotFile = strcat(cellID,'_gridAUCMap_',num2str(gridSize),'x');
print(plotFile,'-dpng')
%% Time to Peak heatmap
figure
timeofpeakMapFT = timeofpeakMapFT./20;
gridtimetopeakMap = imagesc(timeofpeakMapFT);
daspect([0.4,0.7,1])
axis off
colormap(cmp)
h = colorbar();
h.Label.String = 'ms';
title('Time to Peak of Responses')
% scale bar
hold on;
line(a,b,'Color','w','LineWidth',5);
text(c,d,e,'Color','w','FontWeight','bold','FontSize',14)
plotFile = strcat(cellID,'_gridtimetoPeakMap_',num2str(gridSize),'x');
print(plotFile,'-dpng')
%% IR Trend
if isnan(cellIR)
disp('No IR Trend Found')
else
figure
plot(1:length(cellIR),cellIR,'b','LineWidth',1);hold on;
plot(1:length(cellIR),movmean(cellIR,[10 0]),'r','LineWidth',3)
xlabel('Trials')
ylabel('IR (M\Omega)')
title('Input Resistance during the grid experiment')
plotFile = strcat(cellID,'_IRtrend');
print(plotFile,'-dpng')
end
%close all
end
function [lineposX, lineposY, textposX, textposY, scaleSize] = gridScaleBar(scalebarSize,objMag,gridSize)
%SCALEBAR gives out specifications to create a scale bar for the heatmaps
%of the responses. The scale factor depends on the model of the Polygon and
%objective magnification used in the experiments.
%
%Resolution data from Mightex website for Olympus system:
%Full frame = 13900 x 7800 µm (Diagonal = 16000 µm)
%Pixel size = 16.2 µm
%---Variables--------------------------------------------------------------
frameSize = 16000; %diagonal in µm, fixed for the Polygon 400E model
res = frameSize/(objMag*gridSize); %pixel size in µm/square for grid29
pxinBar = scalebarSize/res; %number of pixels in the scale bar
%----Scale Bar-------------------------------------------------------------
%ceil function with added 0.5 is to ensure that scale bar start point aligns
%with a square edge.
scalebarPos = ceil(0.8*gridSize)+0.5;
lineposX = [scalebarPos scalebarPos+pxinBar]; %Line start and end points in X-axis
lineposY = [scalebarPos+0.5 scalebarPos+0.5]; %Line start and end points in Y-axis
textposX = scalebarPos; %text should begin where scale bar begins on X-axis
textposY = scalebarPos+1.5; %text should be 1.5 square below the scale bar in Y-axis
scaleSize = strcat(num2str(scalebarSize),' µm'); %text content
end