Skip to content

T1 and T2 API

Import from nmrlink. T1 uses inversion recovery; T2 uses spin echo. Acquisition, reanalysis and fitting are separate operations.

On this page

t1Parameters and t2Parameters

js
const calibrated = {
  frequencyHz: 402000, p90Cycles: 21, p180Cycles: 42,
  measurementIntervalMs: 200, scans: 64,
};
const t1 = t1Parameters(calibrated, 5);
const t2 = t2Parameters(calibrated, 5);

t1Parameters(settings, tauMs) returns device settings for 180°(0°) → τ → 90°(0°); t2Parameters uses 90°(0°) → τ → 180°(90°). Calibration values above are examples. Require integer 0 < p90Cycles < p180Cycles and τ=1–32767 ms. Repetition interval must exceed τ+40.96 ms. Invalid settings throw.

Delay planning and acquisition

t1Delays / t2Delays(startMs, endMs, stepMs) return ascending integer τ grids from 1 to 32767 ms, at most 201 points, without exceeding the endpoint.

controller.t1Sweep / controller.t2Sweep(parameters, options) run Double measurements sequentially. Required options: startMs, endMs, stepMs. Optional: analysis=, signal, onPoint. parameters is the ordinary device settings object produced above.

Successful operations return ok:true with value containing points, stopped, analysis, parameters and delays; failures return ok:false and error. Cancellation waits for the current measurement; onPoint reports completed points. Low-level runT1Sweep / runT2Sweep(device, parameters, options) return the same value directly through a promise and reject on failure.

t2Window(tauMs, analysis)

For T2, analysis.startMs / endMs are offsets from the echo center, defaulting to −4 / +4 ms. Acquisition begins after the second pulse, so the center is at acquisition time τ. Returned startMs / endMs are absolute acquisition times.

js
const window = t2Window(10, { startMs: -4, endMs: 4 });
// window.startMs === 6, window.endMs === 14

The start offset must be negative and the end positive. The window must contain the center, stay within 0–40.96 ms and contain at least four samples. Scans validate every moving window in advance. T1 analysis uses ordinary absolute acquisition times.

evaluateT1 and evaluateT2

evaluateT1(record, analysis=) returns tau, amplitude, peakHz and record. evaluateT2 additionally returns the moving window. amplitude is the nonnegative FFT peak within the band. Defaults match frequency evaluation, except for the relative T2 window.

analyzeT1 and analyzeT2

records is an array of measurement records with matching source, Double mode, sample interval and all settings except τ. Options: analysis=, referenceIndex=null, fromMs and toMs. T1 also accepts phaseDegrees=0.

PropertyT1T2
Signal evaluationSigned projection at common frequency and phaseComplex magnitude at a common frequency
ReferenceAutomatic or selected-point phase referenceFrequency from the strongest or selected point
pointstau, signal, magnitude, quadrature, recordtau, signal, magnitude, amplitude, peakHz, window, record
Fit range unitsτ [ms]; defaults to measured min–max τ2τ [ms]; defaults to measured min–max 2τ

Returns points, reference, fit, warnings, fromMs and toMs. Invalid settings or no usable reference signal throw. Failed fits return fit:null and warnings. T1 also skips fitting when coherence is below 0.85. T2 uses magnitude without phase alignment.

fitT1 and fitT2

fitT1 / fitT2(points, { fromMs, toMs }) accept points with tau and signal. The fit range is required, with inclusive endpoints. Repeated τ values are averaged.

PropertyT1T2
ModelA−Be−τ/TA-Be^{-\tau/T}Ae−2τ/TAe^{-2\tau/T}, zero background
Minimum pointsFive distinct τ valuesThree distinct τ values
SignalBoth negative and positive valuesNonnegative echo magnitude
Failure examplesZero/flat data, R2<0.95R^2<0.95, Δt/T<0.8\Delta t/T<0.8, optimum at search boundaryZero/flat data, negative signal, optimum at search boundary

Results include T [ms], A, B, C, sse, r2, rmse, n, from, to and model. T2 has B:null and C:0. Direct fitting functions throw if fitting fails; analyzeT1 / analyzeT2 convert fit errors into warnings.

A maximum τ below three times the estimated T1 is a warning rather than a reason to reject the fit. Short T2 ranges or low agreement also produce warnings. Assess estimates together with the measured range and conditions.

warnings contains English strings; warningDetails contains code, message and details in the same order. Use warningDetails codes for UI translation.

Fit specifications · Archive loading · API index