T2 relaxation
The transverse relaxation time T2 is determined from a series of spin echoes with increasing echo time TE. The echo amplitudes are fitted to the model
\[
S(\text{TE}) = a + b \, e^{-\text{TE}/T_2},
\]
where the offset \(a\) accounts for noise and baseline contributions.
Sequence
The constructor t2_relaxation.constructor repeats a spin-echo experiment for num_steps echo times linearly spaced in echo_time_range, separated by the repetition time. It returns the sequence and the array of echo times. Each echo time yields one ADC event, i.e. one entry in AcquisitionData.receive_data per echo time and average.
Procedure
- Construct the sequence, set the calibrated Larmor frequency and \(B_1\) scaling.
- Run the acquisition and arrange the data as
(averages, coils, echo times, samples)usingRxData.average_index. - Average (if acquisition parameter
num_averages> 1), determine the peak amplitude of each echo and fit the model withscipy.optimize.curve_fit. - Store the fitted T2 and the echo times with the acquisition data.
Script
examples/t2_measurement.py
"""T2 relaxation measurement with a series of spin echoes."""
# %%
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit
import console
from console.interfaces.acquisition_data import AcquisitionData
from console.spcm_control.acquisition_control import AcquisitionControl
from console.utilities import sequences
# Create acquisition control instance, adapt the path to the device configuration of your system
acq = AcquisitionControl(configuration_file="example_device_config.yaml")
# Construct and plot sequence
params = {
"echo_time_range": (10e-3, 100e-3),
"num_steps": 50,
"repetition_time": 600e-3,
}
seq, te_values = sequences.t2_relaxation.constructor(**params)
# Set larmor frequency and b1 scaling factor
console.parameter.larmor_frequency = 2038550.0
console.parameter.b1_scaling = 2.43
# Perform acquisition
acq.set_sequence(sequence=seq, parameter=console.parameter)
acq_data: AcquisitionData = acq.run()
num_avg = acq_data.receive_data[0].total_averages
num_echos = int(len(acq_data.receive_data) / num_avg)
num_coils = np.size(acq_data.receive_data[0].processed_data, 0)
num_points = np.size(acq_data.receive_data[0].processed_data, 1)
data = np.zeros((num_avg, num_coils, num_echos, num_points), dtype=complex)
for idx, echo in enumerate(acq_data.receive_data):
data[echo.average_index, :, idx % num_echos, :] = echo.processed_data
data = np.mean(data, axis=0).squeeze()
peaks = np.max(data, axis=-1)
# T2 model to fit the acquired data
def t2_model(te_values: np.ndarray, a: float, b: float, c: float) -> np.ndarray:
"""Model for T2 relaxation."""
return a + b * np.exp(-te_values / c)
# Fit parameters to measured data
params = curve_fit(t2_model, xdata=te_values, ydata=np.abs(peaks))[0]
t2 = params[-1]
te_values_fit = np.linspace(te_values[0], te_values[-1], 1000)
# Calculate decay with fitted parameters
t2_fit = t2_model(te_values_fit, *params)
# Plot measurement and fit
fig, ax = plt.subplots(1, 1, figsize=(10, 6))
ax.scatter(te_values * 1e3, np.abs(peaks), marker="x", c="b", label="Measurement")
ax.set_xlabel("TE (ms)")
ax.set_ylabel("Abs. signal amplitude (mV)")
ax.plot(te_values_fit * 1e3, t2_fit, linestyle="--", c="r", label=f"Fit, T2 = {round(t2 * 1e3, 4)} ms")
ax.legend()
# Save
# Add information to acquisition data
acq_data.add_info({
"preamp": "china_preamp",
"te_values": list(te_values),
"T2_ms": t2,
})
acq_data.save()
del acq
# %%