Processing Relaxation measurement

Processing NMR spectra taken for relaxation measurements

Import API

import spectrochempy as scp

# short version of the unit registry
U = scp.ur

Importing a pseudo 2D NMR spectra

Define the folder where are the spectra

datadir = scp.preferences.datadir
nmrdir = datadir / "nmrdata" / "bruker" / "tests" / "nmr"

dataset = scp.read_topspin(nmrdir / "relax" / "100" / "ser", use_list="vdlist")

Analysing the data

Print dataset summary

NDDataset: [complex128] pp (shape: (y:9, x:1982))[relax expno:100 procno:1 (SER)]
Summary
name
:
relax expno:100 procno:1 (SER)
author
:
runner@fv-az2211-104
created
:
2025-04-27 01:43:24+00:00
Data
title
:
intensity
values
:
...
R[[ 0.5522 2.137 ... -1.437 -0.02603]
[ 1.099 3.404 ... -0.6497 -0.0129]
...
[ 1.603 5.99 ... 4.959 0.09235]
[ 1.61 6.14 ... -0.7725 -0.01501]] pp
I[[ -1.513 -2.733 ... 4.471 0.08437]
[ -2.496 -4.623 ... -6.003 -0.1152]
...
[ -4.25 -7.726 ... 4.695 0.08693]
[ -4.302 -7.69 ... 0.222 0.004867]] pp
shape
:
(y:9, x:1982(complex))
Dimension `x`
size
:
1982
title
:
F2 acquisition time
coordinates
:
[ 0 6.4 ... 1.267e+04 1.268e+04] µs
Dimension `y`
size
:
9
title
:
time
coordinates
:
[ 1 2 ... 20 50] s


Plot the dataset

ds = dataset.em(lb=15 * U.Hz)
ds = ds.fft()
ds = ds.pk(phc0=-10 * U.deg, phc1=0 * U.deg)
ds.plot(xlim=(-60, -140))
plot processing nmr relax


Integrate a region

dsint = ds[:, -90.0:-115.0].simpson()
dsint.plot(marker="^", ls=":")
dsint.real
plot processing nmr relax
NDDataset: [float64] pp⋅ppm (size: 9)[relax expno:100 procno:1 (SER)]
Summary
name
:
relax expno:100 procno:1 (SER)
author
:
runner@fv-az2211-104
created
:
2025-04-27 01:43:24+00:00
description
:
Integration of NDDataset 'relax expno:100 procno:1 (SER)' along dim: 'x'.
history
:
2025-04-27 01:43:24+00:00> Dataset resulting from application of `simpson` method
Data
title
:
area
values
:
...
[ 1556 2472 ... 4253 4284] pp⋅ppm
size
:
9
Dimension `y`
size
:
9
title
:
time
coordinates
:
[ 1 2 ... 20 50] s


Fit a model

create an Optimize object using a simple leastsq method

fitter = scp.Optimize(log_level="INFO", method="leastsq")

Define the model to fit

def T1_model(t, I0, T1):  # no underscore in parameters names.
    # T1 relaxation model
    import numpy as np

    I = I0 * (1 - np.exp(-t / T1))
    return I

Add the model to the fitter usermodels as it it not a built-in model

fitter.usermodels = {"T1_model": T1_model}

Define the parameter variables using a script (parameter: value, low_bound, high_bound) no underscore in parameters names.

fitter.script = """
MODEL: T1
shape: T1_model
  $ I0:  1000.0, 1, none
  $ T1:  2.0,    0.1, none
"""

Performs the fit

<spectrochempy.analysis.curvefitting.optimize.Optimize object at 0x7fcff0b611d0>
NDDataset: [float64] pp⋅ppm (size: 9)[relax expno:100 procno:1 (SER)_Optimize.inverse_transform]
Summary
name
:
relax expno:100 procno:1 (SER)_Optimize.inverse_transform
author
:
runner@fv-az2211-104
created
:
2025-04-27 01:43:24+00:00
history
:
2025-04-27 01:43:24+00:00> Created using method Optimize.inverse_transform
Data
title
:
area
values
:
...
[ 1500 2467 ... 4223 4223] pp⋅ppm
size
:
9
Dimension `y`
size
:
9
title
:
time
coordinates
:
[ 1 2 ... 20 50] s


fitter.plotmerit(dsint, som, method="scatter", title="T1 relaxation fitting")
T1 relaxation fitting


This ends the example ! The following line can be removed or commented when the example is run as a notebook (ipynb).

# scp.show()

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