Skip to content

Commit

Permalink
17/10
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianNGitahi committed Oct 18, 2023
1 parent e7a6c8d commit b330ee9
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 290 deletions.
5 changes: 0 additions & 5 deletions Bleach_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@
b4 = bleach_all(K_D = 1000, tau=chosen_tau, F_max = 45, F_min = 10, nm_conc=nm_conc, bline_len=5000)


# create a fit for the initial values of the bleach 4 result and subtract it -- revise this later
# it should be a fit of the f value

poly4 = np.polyfit(t,b4,2)
fit4 = np.polyval(poly4,t)

plt.show()



Expand Down
225 changes: 225 additions & 0 deletions Bleaching Analysis.ipynb

Large diffs are not rendered by default.

383 changes: 112 additions & 271 deletions Simulation.ipynb

Large diffs are not rendered by default.

Binary file modified __pycache__/b_factory.cpython-311.pyc
Binary file not shown.
31 changes: 17 additions & 14 deletions b_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@ def bleach_nm(K_D, tau, F_max, F_min, nm_conc, bline_len=5000):

# calculate f0 values and populate the signal array
for i in range(f.size):

# calculate f0 by averaging the previous x number of f values
# if x is bigger than the current index then use all the prev f values
# where x is the length of the moving baseline (first element if f[0])


# calculate f0 by getting the median value of the bottom 70% of previous f values

if i == 0:
f0 = f[0]
elif i < bline_len:
f0 = np.average(f[:i])
percentile_mark = np.percentile(f[:i],70)
f0 = np.median(f[f<percentile_mark])
else:
f0 = np.average(f[i-bline_len:i])
prev_values = f[i-bline_len:i]
percentile_mark = np.percentile(prev_values,70)
f0 = np.median(prev_values[prev_values<percentile_mark])


# calculate normalized signal using the calculated f0
Expand Down Expand Up @@ -103,16 +104,17 @@ def bleach_dnm(K_D, tau, F_max, F_min, nm_conc, bline_len =5000):
# calculate f0 values and populate the signal array
for i in range(f.size):

# calculate f0 by averaging the previous x number of f values
# if x is bigger than the current index then use all the prev f values
# where x is the length of the moving baseline (first element if f[0])

# calculate f0 by getting the median value of the bottom 70% of previous f values

if i == 0:
f0 = f_sub[0]
f0 = f[0]
elif i < bline_len:
f0 = np.average(f_sub[:i])
percentile_mark = np.percentile(f[:i],70)
f0 = np.median(f[f<percentile_mark])
else:
f0 = np.average(f_sub[i-bline_len:i])
prev_values = f[i-bline_len:i]
percentile_mark = np.percentile(prev_values,70)
f0 = np.median(prev_values[prev_values<percentile_mark])

# calculate df, and df/f, the normalized signal, using the calculated f0
delta_f[i] = f_sub[i]-f0
Expand Down Expand Up @@ -153,6 +155,7 @@ def bleach_dnm(K_D, tau, F_max, F_min, nm_conc, bline_len =5000):

return delta_ft_f0


# TESTING IF THE FUNCTION WORKS
# # check this bleaching effect 1 for different values of tau -- different bleach factor
# different_taus = np.array([10e6,10e5,10e4,10e3,10e2,10e1,10e0])
Expand Down

0 comments on commit b330ee9

Please sign in to comment.