-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotLifetimeComparison1Ch.m
executable file
·68 lines (59 loc) · 2 KB
/
plotLifetimeComparison1Ch.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
%plotLifetimeComparison(lftRes, varargin) plots CCP lifetime distributions from different conditions
%
% Input:
% lftRes : cell array of structures returned by runLifetimeAnalysis()
% legend : string array of the same size as 'lftRes'
%
% Options ('specifier', value):
% 'Frequency' : 'relative' normalizes the distributions by proportion of CCPs
% 'PlotAll' : true|{false} also displays the lifetime distributions for all CCSs
% 'Color' : color matrix, Nx3
%
% Note: the control condition should be first in the 'lftRes' array
% Francois Aguet, 06/03/2013
function [ha] = plotLifetimeComparison(lftRes, varargin)
N = numel(lftRes);
ip = inputParser;
ip.CaseSensitive = false;
ip.addRequired('lftRes', @iscell);
ip.addOptional('legend', arrayfun(@(i) [' Condition ' num2str(i)], 1:N, 'unif', 0));
ip.addParamValue('PlotOrder', 1:N);
ip.addParamValue('PlotAll', false, @islogical);
ip.addParamValue('Frequency', '', @(x) strcmpi(x, 'relative'));
ip.addParamValue('Color', []);
ip.addParamValue('SlaveName', [], @iscell);
ip.addParamValue('Control', []);
ip.addParamValue('XSpace', []);
ip.parse(lftRes, varargin{:});
fset = loadFigureSettings('print');
% normalization
if strcmpi(ip.Results.Frequency, 'relative')
w = cellfun(@(i) mean(i.pctCCP), lftRes);
w = w/w(1);
else
w = ones(N,1);
end
hp = zeros(N,1);
cv = ip.Results.Color;
if isempty(cv)
cv = hsv2rgb([0 0 0;
0.3 1 1;
0.55 1 1;
0.99 1 1;
0.11 1 1]);
if N>5
cv = [0 0 0; jet(N-1)];
end
end
% 2) Optional: plot CCS distributions (all objects)
setupFigure;
hold on;
for i = ip.Results.PlotOrder
hp(i) = plot(lftRes{i}.t, nanmean(lftRes{i}.lftHist_Ia,1), '-', 'LineWidth', 1, 'Color', cv(i,:));
end
hl = legend(hp, ip.Results.legend);
set(hl, 'Box', 'off', fset.tfont{:}, 'Position', [4 5-N*0.3 2 N*0.3]);
axis([0 120 0 0.05]);
set(gca, 'YTick', 0:0.01:0.05);
xlabel('Lifetime (s)', fset.lfont{:});
ylabel('Frequency', fset.lfont{:});