Skip to content

Analysis specifications

How NMRLink corrects, transforms and fits measurement values. See the signal analysis API for arguments and results, or the analysis guide for examples.

On this page

Baseline correction

Each channel uses the mean of its final tailPoints samples as the baseline, subtracting it from every sample. Defaults: 100 samples and truncate:true, applying Math.trunc toward zero after subtraction. Use false to retain fractional values.

The corrected array is new; raw is unchanged. A remaining signal in the tail contributes to the mean. This is not an automatic separation of device offsets from physical signal.

bc=1K∑n=L−KL−1xn,c,yn,c=xn,c−bcb_c=\frac{1}{K}\sum_{n=L-K}^{L-1}x_{n,c},\qquad y_{n,c}=x_{n,c}-b_c

L is the total sample count, K is tailPoints and c is the channel. Truncation, when enabled, is applied to the corrected values.

Complex FFT convention

zj=Ij+iQjz_j=I_j+iQ_j
Xk=∑j=0N−1wjzj e−i2πkj/M∑j=0N−1wjX_k=\frac{\displaystyle\sum_{j=0}^{N-1} w_jz_j\,e^{-i2\pi kj/M}}{\displaystyle\sum_{j=0}^{N-1} w_j}
Ak=∣Xk∣,ϕk=atan2⁡ ⁣(Im⁡Xk,Re⁡Xk)A_k=|X_k|,\qquad \phi_k=\operatorname{atan2}\!\left(\operatorname{Im}X_k,\operatorname{Re}X_k\right)

I and Q denote Data 1 and Data 2. N is the selected sample count; j starts at zero at the beginning of that interval. M is the padded FFT size. A and φ correspond to amplitude and phaseRadians. The forward exponent is negative. This is a two-sided complex spectrum, not a one-sided real-signal spectrum; amplitudes are not doubled.

hz is relative to the receiver frequency. Bins run in ascending order from negative Nyquist to the positive side, excluding positive Nyquist. At the usual 0.02 ms interval, the sampling frequency is 50 kHz and Nyquist is 25 kHz. Reversing the sign of Data 2 reverses the complex frequency direction.

Interval, window and normalization

The FFT interval is [startMs, endMs). Both endpoints are converted to sample indexes using the following expression, capping the end index at the total sample count. Δt is the sample interval. At least four selected samples are required; actualStartMs and actualEndExclusiveMs describe the resulting interval.

n(t)=⌈tΔt−10−9⌉n(t)=\left\lceil\frac{t}{\Delta t}-10^{-9}\right\rceil

hann uses the following symmetric N-sample window. The rectangular window rect uses wj=1w_j=1. Windowed data is padded to the next power of two M. Real, imaginary and amplitude values are normalized by the sum of window weights rather than the padded length.

wj=12(1−cos⁡2πjN−1),0≤j<Nw_j=\frac{1}{2}\left(1-\cos\frac{2\pi j}{N-1}\right),\qquad 0\le j<N
Typical default analysisValue
Acquisition2048 samples, 0.02 ms spacing, 0–40.96 ms (end excluded)
FFT interval1–5 ms (end excluded), 200 samples
FFT size256 points after padding
Bin spacing, spacingHz1000256×0.02=195.3125 Hz\frac{1000}{256\times0.02}=195.3125\,\mathrm{Hz}
Resolution estimate, resolutionHz1000200×0.02=250 Hz\frac{1000}{200\times0.02}=250\,\mathrm{Hz}

Zero padding refines frequency sampling without improving observation-time resolution. Window choice changes spectral broadening and leakage. Frequency display limits are separate from the time interval used for computation.

Peak, amplitude and phase

analyzeMeasurement selects the maximum-amplitude FFT bin across all frequencies; ties choose the first bin in ascending order. evaluateFrequency and related functions restrict the search to a specified band. Reported peak frequencies are bin values, without interpolation.

Phase uses the start of the selected interval as the time origin, without compensation to absolute acquisition time. Do not interpret phase at nearly zero amplitude. Amplitudes are arbitrary units; physical calibration depends on the apparatus.

Common frequency and phase

Pulse calibration and T1 evaluate a complex component at one shared frequency, then subtract a common phase to obtain a signed real projection. They do not align every point independently, retaining pulse sign reversals and negative-to-positive T1 recovery. magnitude is phase-independent magnitude; quadrature is the orthogonal component.

The automatic frequency maximizes summed squared FFT amplitudes, adjusting weights for duplicate scan values. Phase comes from strong points; the pulse sign is oriented positive at short lengths and T1 toward a positive recovery slope. Manual referenceIndex changes the phase reference only; frequency still comes from all points.

Pulse sine fitting

The signed and magnitude models are shown below. Here ℓ is length, the RF cycle count, and p180=2p90p_{180}=2p_{90}. Candidates from measured peaks and crossings are distinct from least-squares estimates. Fitting is attempted from at least three points; candidates outside the measured range are extrapolations. Incoherent phase and low agreement produce warnings.

S(ℓ)=Asin⁡ ⁣(πℓ2p90)+BS(\ell)=A\sin\!\left(\frac{\pi\ell}{2p_{90}}\right)+B
Smag(ℓ)=A∣sin⁡ ⁣(πℓ2p90)∣+BS_{\mathrm{mag}}(\ell)=A\left|\sin\!\left(\frac{\pi\ell}{2p_{90}}\right)\right|+B

T1 and T2 exponential fitting

PropertyT1T2
ModelS(τ)=A−Be−τ/T1S(\tau)=A-Be^{-\tau/T_1}S(2τ)=Ae−2τ/T2S(2\tau)=Ae^{-2\tau/T_2}
Axis and fit rangeτ [ms]2τ [ms]
SignalSigned projection at common phaseCommon-frequency complex magnitude in a moving echo window
BackgroundA is fittedFixed at zero

T2 acquisition time begins after the second pulse; the echo center is at τ, and the analysis window follows it. A manual T2 referenceIndex selects the point that supplies the common frequency.

Repeated τ values are averaged. Fits minimize squared residuals in the original signal values, not a straight line in log amplitude. T1 needs at least five distinct delays with both signal signs; T2 estimates from at least three nonnegative points. See the fitting API for acceptance conditions.

Inspect r2, rmse and warnings along with the estimate. Short-range estimates may be sensitive to the interval or phase reference. Fits never automatically change hardware parameters.

Invalid data

Incomplete pairs, NaN, Infinity, invalid time ranges and arithmetic overflow are errors. Invalid values are not replaced with zero, and intervals are not silently shortened for small records. Keep the raw data and display the error in the calling UI.