-
Notifications
You must be signed in to change notification settings - Fork 1
/
fitFLIM.m
50 lines (45 loc) · 2.08 KB
/
fitFLIM.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
% Results = fitFLIM(FlimData, IRFProb, FitType, Channel, Offset)
function Results = fitFLIM(FlimData, IRFProb, FitType, Channel, Offset)
close all;
if ~exist('Offset', 'var') || isempty(Offset)
Offset = 0;
end
EvalTEdges = 0 : (50 / FlimData(Channel).ADCResolution) : 25;
EvalTCenters = ((25 / FlimData(Channel).ADCResolution) : ...
(50 / FlimData(Channel).ADCResolution) : ...
(25 - 25 / FlimData(Channel).ADCResolution)) + Offset;
Xlim = [0, 25] + Offset;
figure(1);
hold on;
set(gca, 'LineWidth', 2, 'FontSize', 16);
xlabel('Microtime (ns)');
ylabel('Photon counts');
xlim(Xlim);
plot(FlimData(Channel).DecayHistogramTimeAxis, ...
FlimData(Channel).AllPixelsDecayHistogram, ...
'-k.', 'MarkerSize', 9);
Idx = (FlimData(Channel).DecayHistogramTimeAxis >= ...
min(EvalTEdges + Offset)) & ...
(FlimData(Channel).DecayHistogramTimeAxis <= ...
max(EvalTEdges + Offset)); % time-gating
Results = deconvolveIRF(FlimData(Channel).AllPixelsDecayHistogram(Idx), ...
IRFProb, FitType, EvalTEdges);
FullConvolution = conv(IRFProb, Results.Decay, 'full');
plot(EvalTCenters, FullConvolution(1 : length(IRFProb)), ...
'-r.', 'MarkerSize', 9);
if (Results.OptimX(1) >= 0.5)
Results.OptimX = [Results.OptimX(1 : 2), ...
1 - Results.OptimX(1), Results.OptimX(3), ...
Results.OptimX(4), Results.OptimX(5)];
else
Results.OptimX = [1 - Results.OptimX(1), Results.OptimX(3), ...
Results.OptimX(1 : 2), ...
Results.OptimX(4), Results.OptimX(5)];
end
hold off;
residualReport(EvalTCenters, FlimData(Channel).AllPixelsDecayHistogram( ...
(FlimData(Channel).DecayHistogramTimeAxis > Offset) & ...
(FlimData(Channel).DecayHistogramTimeAxis < 25 + Offset)), ...
FullConvolution(1 : length(IRFProb)), ...
'.k--', 'MarkerSize', 9, 'LineStyle', 'none');
end