-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSurfacePlot.asv
More file actions
75 lines (66 loc) · 2.57 KB
/
SurfacePlot.asv
File metadata and controls
75 lines (66 loc) · 2.57 KB
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
function [outputplot] = SurfacePlot(data, filetitle, filename)
%this function creates surface plots using imagesc function, of either LFP,
%MUA, CSD. During this process, either LFP, aMUA/dMUA,or CSD is baseline adjusted(corrected);
%-baseline corrected LFP mean, baseline corrected MUA mean, or baseline corrected CSD mean is then computed;
%-LFP or MUA: normalized;
%-filtered and interpolated with filterCSD function and plotted.
%baseline adjusted data process
basedata = data(25:75,:,:);
mean_bp = mean(basedata,1); % length(data(1,1,:))) ;
adj_data = data(:,:,:) - mean_bp;
mean_adj = mean(adj_data,3);
% if the data is either LFP or MUA, do a normalization (data - min)/(max-min)
if any(strfind(inputname(1), 'LFP')) || any(strfind(inputname(1), 'MUA'))
norm_mean_adj = nan(length(mean_adj(:,1)),length(mean_adj(1,:)));
for n=1:24
norm_mean_adj(:,n) = (mean_adj(:,n) - min(mean_adj(:,n)))/(max(mean_adj(:,n))-min(mean_adj(:,n)));
end
%fcsd = filterCSD(norm_data)';
else
%fcsd = filterCSD(mean_data')'; % filter baseline corrected CSD
norm_mean_adj = mean_adj;
end
fint_data = filterCSD(norm_mean_adj')';
h = figure();
xabs = [-50:2000];
yvec = [1:14,16:24];
imagesc(xabs,yvec, fint_data')
if any(strfind(inputname(1), 'CSD'))
colormap(flipud(jet));
end
colorbar;
%climit = max(abs(get(gca,'CLim'))*.8);
if any(strfind(inputname(1), 'CSD'))
set(gca,'CLim',[-800 800],'Box','off','TickDir','out')
else
end
hold on;
plot([0 0], ylim,'k')
plot([1100 1100], ylim,'k')
clrbar = colorbar;
if any(strfind(inputname(1), 'LFP')) || any(strfind(inputname(1), 'MUA'))
title({sprintf('LGN %s ', char(filetitle)), 'baseline-corrected, averaged, then normalized', inputname(1)}, 'Interpreter', 'none', 'fontsize', 18)
clrbar.Label.String = 'µV';
else
title({sprintf('LGN %s baseline-corrected, then averaged', char(filetitle)), inputname(1)}, 'Interpreter', 'none', 'fontsize', 18)
clrbar.Label.String = 'nA/mm^3';
end
xlabel('time (ms)')
ylabel('Contact index')
if any(strfind(inputname(1), 'LFP'))
save(strcat(filename, 'baselinecorr_mean_normalized_LFP.png'));
else
if any(strfind(inputname(1), 'aMUA'))
save(strcat(filename, 'baselinecorr_mean_normalized_aMUA.png'));
else
if any(strfind(inputname(1), 'dMUA'))
save(strcat(filename, 'baselinecorr_mean_normalized_dMUA.png'));
else
if any(strfind(inputname(1), 'CSD'))
save(strcat(filename, 'baselinecorr_mean_CSD.png'));
end
end
end
end
outputplot = h;
end