-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalculateIRF.m
34 lines (31 loc) · 1.36 KB
/
calculateIRF.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
% calculateIRF(EarlyPulseOrLatePulse, MicroTimeRange)
function calculateIRF(EarlyPulseOrLatePulse, MicroTimeRange)
%% Read the header and micro-time data
[Trace, Filename, FCSHeader] = readMicroTime;
%% Determine parameters
ADCResolution = double(FCSHeader.MaxMicroTimeResolution);
if ~exist('MicroTimeRange', 'var') || isempty(MicroTimeRange)
MicroTimeRange = double(FCSHeader.MicroTimeRange); % ns
end
if strcmpi(EarlyPulseOrLatePulse, 'early')
TimeWindow = 1 : (ADCResolution / 2);
elseif strcmpi(EarlyPulseOrLatePulse, 'late')
TimeWindow = (ADCResolution / 2 + 1) : ADCResolution;
elseif strcmpi(EarlyPulseOrLatePulse, 'whole') || ...
strcmpi(EarlyPulseOrLatePulse, 'entire') || ...
strcmpi(EarlyPulseOrLatePulse, 'all') || ...
strcmpi(EarlyPulseOrLatePulse, 'both')
TimeWindow = 1 : ADCResolution;
else
error('Please specify the microtime window.');
end
%% Calculate IRF
PhotonCounts = histcounts(Trace{1}.MicroTimeData, ...
0 : (MicroTimeRange / ADCResolution) : MicroTimeRange);
% NormalizedPhotonCounts = PhotonCounts / sum(PhotonCounts);
% IRFProb = NormalizedPhotonCounts(TimeWindow);
IRFProb = PhotonCounts(TimeWindow) / ...
sum(PhotonCounts(TimeWindow));
%% Save
save([Filename, '.mat'], 'IRFProb');
end