-
Notifications
You must be signed in to change notification settings - Fork 2
/
crossCorr.m
74 lines (60 loc) · 2.15 KB
/
crossCorr.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
function p = crossCorr(mol, p)
% Last update by MH 29.3.2019
% >> adapt bleethrough and direct excitation calculations to new parameter
% structure (see project/setDefPrm_traces.m)
% >> correct traces, first from bleedthrough, then from direct excitation
proj = p.curr_proj;
nChan = p.proj{proj}.nb_channel;
% added by MH, 29.3.2019
exc = p.proj{proj}.excitations;
chanExc = p.proj{proj}.chanExc;
labels = p.proj{proj}.labels;
isCrossCorr = ~isempty(p.proj{proj}.intensities_crossCorr) && ...
~all(sum(sum(isnan(p.proj{proj}.intensities_crossCorr(:, ...
((mol-1)*nChan+1):mol*nChan,:)),2),3));
if ~isCrossCorr
nExc = p.proj{proj}.nb_excitations;
I_bin = p.proj{proj}.intensities_bin(:,((mol-1)*nChan+1):mol*nChan,:);
I_corr = I_bin;
% added by MH, 29.3.2019
% bleedthrough corr.
for c = 1:nChan
if nChan > 1
n = 0;
for c2 = 1:nChan % c bleeds into c2
if c ~= c2
n = n+1;
coeff = p.proj{proj}.TP.fix{4}{1}(c,n);
I_corr(:,c2,:) = I_corr(:,c2,:)-coeff*I_bin(:,c,:);
end
end
end
end
% direct exc. corr.
if nExc > 1
for c = 1:nChan
l0 = find(exc==chanExc(c));
if isempty(l0)
if sum(p.proj{proj}.TP.fix{4}{2}(:,c))
disp(cat(2,labels{c},'-specific illumination ',...
'is not defined: direct excitation can not be ',...
'calculated; DE coefficient set to zero.'));
p.proj{proj}.TP.fix{4}{2}(:,c) = 0;
end
continue;
end
l0 = l0(1);
n = 0;
for l = 1:nExc
if l ~= l0
n = n+1;
coeff = p.proj{proj}.TP.fix{4}{2}(n,c);
I_corr(:,c,l) = I_corr(:,c,l) - coeff*I_corr(:,c,l0);
end
end
end
end
p.proj{proj}.intensities_crossCorr(:,((mol-1)*nChan+1):mol*nChan,:)= ...
I_corr;
p.proj{proj}.intensities_denoise(:,((mol-1)*nChan+1):mol*nChan,:)= NaN;
end