Skip to content

Commit

Permalink
Documentation fixes for 0.12.1 (#57)
Browse files Browse the repository at this point in the history
* docs: fixed broken examples

* README: updated citation info

* docs: fixed broken images in funding page
  • Loading branch information
luisfabib authored Nov 6, 2020
1 parent 01d250b commit 72e75b1
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ More details on the installation of DeerLab can be found [here](https://jeschkel

### Citation

A paper about DeerLab is currently submitted for publication. When you use DeerLab in your work, for now, please cite the preprint

> Fábregas Ibáñez, L., Jeschke, G., and Stoll, S.: a comprehensive software package for analyzing dipolar electron paramagnetic resonance spectroscopy data, Magn. Reson., 1, 209–224, 2020, doi.org/10.5194/mr-1-209-2020
Please check back frequently for updated publication information.
When you use DeerLab in your work, please cite the following publication:

<div style="height:6%px; width:100%; display:flex; flex-wrap:wrap; align-items:center; border-style:solid">
<div style="margin-left:2%; margin-bottom:2%; font-size:14px">
<h3 style="font-size:110%"> DeerLab: a comprehensive software package for analyzing dipolar electron paramagnetic resonance spectroscopy data </h3>
Luis Fábregas Ibáñez, Gunnar Jeschke, Stefan Stoll <br>
Magn. Reson., 1, 209–224, 2020 <br>
<a href="https://doi.org/10.5194/mr-1-209-2020"> doi.org/10.5194/mr-1-209-2020</a>
</div>
</div>

### License

Expand Down
6 changes: 3 additions & 3 deletions docsrc/source/funding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DeerLab is a project that has been funded by the following sources:
Grant ETH-35 18-2
</div>
<div style="height:70%; width=30%">
<img src="./_images/eth_logo.png", style="margin-top:1%; margin-bottom:1%;height:96%;">
<img src="https://raw.githubusercontent.com/JeschkeLab/DeerLab/main/docsrc/source/images/eth_logo.png", style="margin-top:1%; margin-bottom:1%;height:96%;">
</div>
</div>

Expand All @@ -25,7 +25,7 @@ DeerLab is a project that has been funded by the following sources:
Grant GM127325
</div>
<div style="height:70%; width=30%">
<img src="./_images/nih_logo.png", style="margin-top:1%; margin-bottom:1%;height:96%;">
<img src="https://raw.githubusercontent.com/JeschkeLab/DeerLab/main/docsrc/source/images/nih_logo.png", style="margin-top:1%; margin-bottom:1%;height:96%;">
</div>
</div>

Expand All @@ -38,7 +38,7 @@ DeerLab is a project that has been funded by the following sources:
Grant CHE-1452967
</div>
<div style="height:70%; width=30%">
<img src="./_images/nsf_logo.png", style="margin-top:1%; margin-bottom:1%;height:96%;">
<img src="https://raw.githubusercontent.com/JeschkeLab/DeerLab/main/docsrc/source/images/nsf_logo.png", style="margin-top:1%; margin-bottom:1%;height:96%;">
</div>
</div>

14 changes: 7 additions & 7 deletions examples/plot_analyzing_pake_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

# Plot
plt.plot(t,V,'k.')
plt.tight_layout()
plt.grid()
plt.grid(alpha=0.3)
plt.xlabel('Time [$\\mu s$]')
plt.ylabel('V(t)')

plt.tight_layout()
plt.show()
# %% [markdown]
# Prepare the signal
# ------------------
Expand Down Expand Up @@ -71,11 +71,11 @@ def Bmodel(par):
Vcorr = (V/Bfit - (1 - lam))/lam

plt.plot(t,Vcorr,'k.')
plt.tight_layout()
plt.grid(alpha=0.3)
plt.xlabel('Time [$\\mu s$]')
plt.ylabel('V(t)')

plt.tight_layout()
plt.show()
# %% [markdown]
# Computing the dipolar spectrum
# --------------------------------
Expand All @@ -99,13 +99,13 @@ def Bmodel(par):

# Plot results
plt.plot(nu,pake,'k',nuapo,pakeapo,'b',linewidth=1.5)
plt.tight_layout()
plt.grid(alpha=0.3)
plt.xlim([-10, 10])
plt.xlabel('Frequency [MHz]')
plt.ylabel('Intensity [a.u.]')
plt.legend(['Raw','Apodized'])

plt.tight_layout()
plt.show()
# %% [markdown]
# We do not need to worry about the zero-filling since ``fftspec`` takes care
# of setting it to twice the amount of points in the signal, to preserve all information.
Expand Down
7 changes: 4 additions & 3 deletions examples/plot_comparing_uncertainties_for_regularization.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
r = np.linspace(2,5,160) # distance axis, nm
P = dl.dd_gauss2(r,[3, 0.1, 0.6, 3.5, 0.2, 0.4]) # model distribution
lam = 0.32 # modulatio depth
B = dl.bg_strexp(t,[0.04,1],lam) # background decay
B = dl.bg_strexp(t,[0.04,1]) # background decay
K = dl.dipolarkernel(t,r,lam,B) # dipolar kernel matrix
V = K@P + dl.whitegaussnoise(t,0.01) # signal with added noise

Expand Down Expand Up @@ -66,7 +66,7 @@ def mybootfcn(V):
# matrices. This is because bootstrapping takes the nonnegativity constraint of P into
# account, whereas the curvature matrix CIs do not.

fig, ax = plt.subplots(1,2,sharey=True)
fig, ax = plt.subplots(2,1,sharey=True)
ax[0].plot(r,P,'k',r,Pfit,'r',linewidth=1)
ax[0].fill_between(r,Pci50_cm[:,0],Pci50_cm[:,1],color='r',linestyle='None',alpha=0.45)
ax[0].fill_between(r,Pci95_cm[:,0],Pci95_cm[:,1],color='r',linestyle='None',alpha=0.25)
Expand All @@ -85,5 +85,6 @@ def mybootfcn(V):
ax[1].set_xlabel('r [nm]')
ax[1].set_title('Bootstrapped CI')
ax[1].legend(['Truth','Fit','50%-CI','95%-CI'])

plt.tight_layout()
plt.show()
# %%
12 changes: 7 additions & 5 deletions examples/plot_emulating_deeranalysis_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
plt.ylabel('V(t)')
plt.grid(alpha=0.3)
plt.legend(['real','imag'])

plt.tight_layout()
plt.show()
# %% [markdown]
# DeerAnalysis workflow
# ---------------------
Expand All @@ -58,17 +59,17 @@
mask = t>tstart
def Bmodel(par):
lam,kappa,d = par # unpack parameters
B = (1-lam)*dl.bg_strexp(t[mask],[kappa,d],lam)
B = (1-lam)*dl.bg_strexp(t[mask],[kappa,d])
return B

# lam k d
par0 = [0.5, 0.5, 3]
lb = [0.1, 0.1, 1]
lb = [0.1, 0, 1]
ub = [1, 5, 6]
fit = dl.fitparamodel(V[mask],Bmodel,par0,lb,ub,rescale=False)

lamfit,kappa,d = fit.param
Bfit = dl.bg_strexp(t,[kappa,d],lamfit)
Bfit = dl.bg_strexp(t,[kappa,d])

# Background "correction" by division
Vcorr = (V/Bfit - 1 + lamfit)/lamfit
Expand Down Expand Up @@ -99,6 +100,7 @@ def Bmodel(par):
plt.xlabel('r [nm]')
plt.ylabel('P [nm^{-1}]')
plt.legend(['truth','fit'])

plt.tight_layout()
plt.show()

# %%
7 changes: 2 additions & 5 deletions examples/plot_multigauss_fitting_4pdeer.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def K4pdeer(par,t,r):
plt.plot(t,V,'k.')
plt.plot(t,Vfit,'b',linewidth=1.5)
plt.plot(t,(1-Kparfit[0])*dl.bg_hom3d(t,Kparfit[1],Kparfit[0]),'b--',linewidth=1.5)
plt.tight_layout()
plt.grid(alpha=0.3)
plt.legend(['data','Vfit','Bfit'])
plt.xlabel('t [µs]')
Expand All @@ -107,34 +106,32 @@ def K4pdeer(par,t,r):
plt.plot(r,Pfit,'b',linewidth=1.5)
plt.fill_between(r,Pci50[:,0],Pci50[:,1],color='b',linestyle='None',alpha=0.45)
plt.fill_between(r,Pci95[:,0],Pci95[:,1],color='b',linestyle='None',alpha=0.25)
plt.tight_layout()
plt.grid(alpha=0.3)
plt.legend(['truth','optimal fit','95%-CI'])
plt.xlabel('r [nm]')
plt.ylabel('P(r)')

plt.subplot(323)
plt.bar(np.arange(NGauss)+1,metrics + abs(min(metrics)),facecolor='b',alpha=0.6)
plt.tight_layout()
plt.grid(alpha=0.3)
plt.ylabel('$\Delta AIC$')
plt.xlabel('Number of Gaussians')

plt.subplot(325)
plt.bar(np.arange(NGauss)+1,Akaikeweights,facecolor='b',alpha=0.6)
plt.tight_layout()
plt.grid(alpha=0.3)
plt.ylabel('Akaike Weight [%]')
plt.xlabel('Number of Gaussians')

plt.subplot(3,2,(4,6))
for i in range(len(Peval)):
plt.plot(r,P + 2*i,'k',r,Peval[i] + 2*i,'b-',linewidth=1.5)
plt.tight_layout()
plt.grid(alpha=0.3)
plt.xlabel('r [nm]')
plt.ylabel('Number of Gaussians')
plt.legend(['truth','fit'])

plt.tight_layout()
plt.show()

# %%
15 changes: 10 additions & 5 deletions examples/plot_pseudotitration_parameter_free.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def Kmodel(par,ts,rA,rB,L):
Ks = [[]]*Nsignals
# General the dipolar kernels
for i in range(Nsignals):
B = dl.bg_exp(ts[i],k,lam)
B = dl.bg_exp(ts[i],k)
# Kernel for fraction A
KstateA = dl.dipolarkernel(ts[i],rA,lam,B)
# Kernel for fraction B
Expand Down Expand Up @@ -153,7 +153,7 @@ def Kmodel(par,ts,rA,rB,L):
plt.subplot(3,2,(1,3))
for i in range(Nsignals):
Vsfit.append(Ksfit[i]@Pfit)
plt.plot(ts[i],Vs[i]+i/9,'k.',ts[i],Vsfit[i]+i/9,'r',linewidth=1.5)
plt.plot(ts[i],Vs[i]+i/9,'k.',ts[i],Vsfit[i]+i/9,'tab:blue',linewidth=1.5)
plt.grid(alpha =0.3)
plt.xlabel('t [$\mu s$]')
plt.ylabel('V(t) [a.u.]')
Expand All @@ -164,7 +164,7 @@ def Kmodel(par,ts,rA,rB,L):
for i in range(Nsignals):
PAfit = xAfit[i]*Pfit[0:len(rA)]
PBfit = xBfit[i]*Pfit[len(rA):len(rB)+len(rA)]
plt.plot(rA,PAfit+2*i,'r',rB,PBfit+2*i,'b',linewidth=1.5)
plt.plot(rA,PAfit+1.2*i,'tab:red',rB,PBfit+1.2*i,'tab:blue',linewidth=1.5)

plt.grid(alpha =0.3)
plt.xlabel('r [nm]')
Expand All @@ -173,10 +173,15 @@ def Kmodel(par,ts,rA,rB,L):
plt.xlim([2,7])

plt.subplot(325)
plt.plot(np.log10(L),xA,'r-',np.log10(L),xB,'b-')
plt.plot(np.log10(L),xAfit,'ro',np.log10(L),xBfit,'bo',linewidth=1.5)
plt.plot(np.log10(L),xA,'tab:red',np.log10(L),xB,'tab:blue')
plt.plot(np.log10(L),xAfit,'o',color='tab:red')
plt.plot(np.log10(L),xBfit,'o',color='tab:blue')
plt.grid(alpha =0.3)
plt.xlabel('log$_{10}$([L])')
plt.ylabel('Fractions')
plt.legend(['state A','state B'])
plt.ylim([0,1])

plt.tight_layout()
plt.show()
# %%

0 comments on commit 72e75b1

Please sign in to comment.