-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZMW_sim_Bleaching.m
More file actions
41 lines (29 loc) · 935 Bytes
/
ZMW_sim_Bleaching.m
File metadata and controls
41 lines (29 loc) · 935 Bytes
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
function [Bleach] = ZMW_sim_Bleaching(MonTrace,B_rate)
% This programs adds a bleaching pattern to a trace
% Last up date 20-06-2017 Alvaro
rate = B_rate;
dt = 0.2;
Bel_di = makedist('exp',1/rate);
Up = find(diff(MonTrace)>0);
down = find(diff(MonTrace)<0);
Nup = length(Up);
TraceBle = MonTrace;
Ble = random(Bel_di,Nup,1);
tBle = round(Ble)./dt + 1;
for i = 1:length(Up)
ds = down(down>Up(i));
[ind]=ds(find(MonTrace(Up(i))==MonTrace(ds+1),1));
if isempty(ind) && Up(i) + tBle(i) < 4000
TraceBle(Up(i)+tBle(i):end) = TraceBle(Up(i)+tBle(i):end) -1;
else
TraceBle(Up(i)+tBle(i):ind) = TraceBle(Up(i)+tBle(i):ind) -1;
end
end
%Bleach = MonTrace + cumsum(tBlea);
Bleach = TraceBle;
% figure
% plot([dt:dt:800],TraceBle,'r')
% hold on
% plot([dt:dt:800],MonTrace,'')
% plot([dt:dt:800],BleachTrace,'k')
% hold off