Analyze T1 Inversion-Recovery Experiments

This example demonstrates how to import TopSpin data from an inversion recovery NMR experiment and determine the T1 relaxation rate through a fit.

Load Inversion Recovery Spectra

Start with importing data and creating the DNPLab workspace. Note that the data are added to the workspace as 'raw' then copied to the processing buffer 'proc' to preserve the raw data during processing.

import dnplab as dnp

file_name_path = "../../data/topspin/304"
data = dnp.load(file_name_path)
data.attrs["experiment_type"] = "nmr_spectrum"
/github/workspace/dnplab/core/base.py:73: UserWarning: Dimensions not consistent
  warnings.warn("Dimensions not consistent")

Next, we process the FIDs to obtain the frequency domain NMR spectrum

# data = dnp.remove_background(data)

# dnp.remove_background(data)
data = dnp.apodize(data, lw=100)
data = dnp.fourier_transform(data)

data = dnp.autophase(data)

dnp.fancy_plot(data, xlim=[-50, 30], title="Inversion Recorvery")
dnp.plt.show()
Inversion Recorvery

Align Inversion Recovery Spectra

The spectra shown here are the individual NMR spectra for different recovery times. Note how the spectra are not perfectly aligned. This is can be fixed using the aligning function. A more detailed description of the aligning routine of DNPLab is given in the tutorial Align NMR Spectra.

data = dnp.align(data)

# dnp.dnplabplot(data, xlim=[-50, 30], title="Inversion Recovery, aligned")
# dnp.plt.show()

Integrate Spectra

To determine the T1 relaxation time, we first integrate the peak intensity across the entire spectrum. After integration the workspace will have a new dnpdata object called "integrals" where the integral values and indirect axis are kept. To use fancy_plot the attribute experiment_type has to be changed to "inversion_recovery".

integrals = dnp.integrate(data)
integrals.attrs["experiment_type"] = "inversion_recovery"

dnp.fancy_plot(integrals)
dnp.plt.show()

initial_guess = (2., -4000, 4000) # initial guess for: T1, M_0, M_inf

out = dnp.fit(dnp.math.relaxation.t1, integrals, dim = 't1', p0 = initial_guess)

fit = out['fit']
popt = out['popt']
err = out['err']

dnp.fancy_plot(integrals)
dnp.plot(fit, '-')
print(popt)
T1 = popt['popt',0]
M_0 = popt['popt',1]
M_inf = popt['popt',2]

print(T1.values)

dnp.plt.show()
plot 02 analyze inversion recovery experiments
/usr/local/lib/python3.8/site-packages/matplotlib/cbook/__init__.py:1298: ComplexWarning: Casting complex values to real discards the imaginary part
  return np.asarray(x, float)
/usr/local/lib/python3.8/site-packages/numpy/lib/function_base.py:625: ComplexWarning: Casting complex values to real discards the imaginary part
  a = asarray(a, dtype=dtype, order=order)
values:
        3 ndarray (float64)
dims:
        ['popt']
coords:
        array([0, 1, 2])
attrs:

[18.8672407]

Total running time of the script: ( 0 minutes 0.429 seconds)

Gallery generated by Sphinx-Gallery