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/ 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")
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")

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"


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

out =, integrals, dim = 't1', p0 = initial_guess)

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

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

plot 02 analyze inversion recovery experiments
/usr/local/lib/python3.8/site-packages/matplotlib/cbook/ ComplexWarning: Casting complex values to real discards the imaginary part
  return np.asarray(x, float)
/usr/local/lib/python3.8/site-packages/numpy/lib/ ComplexWarning: Casting complex values to real discards the imaginary part
  a = asarray(a, dtype=dtype, order=order)
        3 ndarray (float64)
        array([0, 1, 2])


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

Gallery generated by Sphinx-Gallery