Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

vendor.bruker

vendor.bruker

Functions

NameDescription
build_fidConstruct a strict xmris FID DataArray from an N-dimensional numpy array.
estimate_group_delayMeasure the true digital-filter group delay by minimizing residual phase.
remove_digital_filterRemove the hardware digital filter group delay from Bruker FID data.
reshape_bruker_rawReshape a flat Bruker rawdata.job0 array into a squeezed N-dimensional numpy array.

build_fid

vendor.bruker.build_fid(data, dims, pv_params)

Construct a strict xmris FID DataArray from an N-dimensional numpy array.

Expected Bruker Parameters in pv_params:

Parameters

NameTypeDescriptionDefault
datanp.ndarrayThe squeezed, N-dimensional complex data array.required
dimslist[str]The dimension names matching the data axes. Must contain DIMS.time.required
pv_paramsdictThe parsed Bruker parameter dictionary.required

Returns

NameTypeDescription
xr.DataArrayA fully compliant DataArray ready for the xmris processing pipeline.

estimate_group_delay

vendor.bruker.estimate_group_delay(
    da,
    dim=DIMS.time,
    *,
    search_range=None,
    header_hint=None,
    window=16.0,
    metric='acme',
    refine=True,
    return_profile=False,
)

Measure the true digital-filter group delay by minimizing residual phase.

The vendor header value (Bruker ACQ_RxFilterInfo/GRPDLY) can under-count the real receiver digital-filter group delay for some ParaVision/probe combinations, leaving a residual first-order (frequency-dependent) phase error after :func:remove_digital_filter — negligible near the carrier but large for peaks far from it. This estimator finds the delay that removes that residual.

An incorrect delay is mathematically a residual linear phase across the spectrum, so the correct delay is the one that, after removal, makes the spectrum maximally absorptive under a single global zero-order phase (φ0). The discriminating power comes from forbidding first-order phase (φ1): delay and φ1 are the same linear-phase degree of freedom, so any φ1 freedom would make every delay look equally good. This is the peak-agnostic generalization of a tied-phase model residual. argmax(|FID|) is deliberately not used — it lands on the filter’s ringing, not the true delay.

Parameters

NameTypeDescriptionDefault
daxr.DataArrayInput free induction decay (FID) in the time domain. May be N-dimensional; the single highest-energy 1-D slice is used for estimation.required
dimstrThe time dimension, by default DIMS.time.DIMS.time
search_rangetuple of floatExplicit (low, high) delay bounds (samples) to search. If None (default), the window is anchored on the header: header ± window.None
header_hintfloatVendor-reported delay to anchor the search on. If None, falls back to da.attrs[group_delay] and then to a broad default range.None
windowfloatHalf-width (samples) of the header-anchored search window, by default 16.0.16.0
metric(acme, coherence)Residual-phase cost. "acme" (default) minimizes the ACME entropy over a φ0 grid (whole-spectrum, robust to linear-phase aliasing). "coherence" is a cheaper φ0-invariant phase-coherence proxy."acme"
refineboolIf True (default), refine the best integer delay to sub-sample precision.True
return_profileboolIf True, also return the cost-vs-delay profile (an [xr.DataArray](xref:xarray#xarray.DataArray) over a trial_delay axis) for diagnosing multimodality/aliasing. By default False.False

Returns

NameTypeDescription
float or tuple[float, xr.DataArray]The measured group delay in samples, or (delay, profile) when return_profile=True.

Notes

Emits a UserWarning when the measured delay deviates strongly from the header (a likely under-counting header), or when the cost profile is ambiguous (several delays give a near-minimal residual — linear-phase aliasing).

remove_digital_filter

vendor.bruker.remove_digital_filter(
    da,
    group_delay='header',
    dim=DIMS.time,
    keep_length=True,
)

Remove the hardware digital filter group delay from Bruker FID data.

Bruker consoles use a cascade of digital FIR filters during analog-to-digital conversion. Because these filters calculate a moving average, they require time to “wake up”, introducing a causality delay at the start of the Free Induction Decay (FID). This manifests as a time-shift, effectively prepending the actual signal with a specific number of filter transient points (often appearing as a flatline or wavy noise).

If left uncorrected, this time shift causes a massive, rolling first-order phase error in the frequency-domain spectrum.

This function realigns the signal to t=0 by:

  1. Truncating the integer portion of the delay.

  2. Applying a first-order phase correction to exactly compensate for the remaining fractional sub-point delay.

Parameters

NameTypeDescriptionDefault
daxr.DataArrayInput free induction decay (FID) data in the time domain.required
group_delayfloat or {header, measure}The delay value (in samples) to remove. By default "header", which reads the vendor-reported value from da.attrs (the group_delay attribute written by :func:build_fid, mapping Bruker ACQ_RxFilterInfo[0].groupDelay). Pass an explicit float to force a value, or "measure" to estimate it from the data via :func:estimate_group_delay — robust when the header under-counts the true digital-filter delay. Typical header values: - ~76.0 for standard high-resolution Spectroscopy. - ~0.0 to 16.0 for Fast Imaging or ZTE (where hardware pre-compensation or short filters are used).'header'
dimstrThe time dimension along which to apply the correction, by default DIMS.time.DIMS.time
keep_lengthboolIf True, appends pure zeros to the end of the FID to replace the truncated startup points. This ensures the returned DataArray maintains the exact same length as the input (critical for FFT radix sizes), avoiding the confusion of traditional spectral “zero-filling”. By default True.True

Returns

NameTypeDescription
xr.DataArrayThe corrected FID data with the filter transient stripped, phase aligned, and lineage metadata preserved.

reshape_bruker_raw

vendor.bruker.reshape_bruker_raw(raw_data_1d, pv_params)

Reshape a flat Bruker rawdata.job0 array into a squeezed N-dimensional numpy array.

Bruker stores multi-dimensional data sequentially. This function parses the method parameters to determine the shape, filters out empty dimensions, and reshapes the data to match xmris conventions.

Expected Bruker Parameters in pv_params:

Spatial encoding is currently unsupported, we assume:

n_slices = 1 # number of slices / slabs n_ph1 = 1 # phase encoding direction A n_ph2 = 1 # phase encoding direction B

Parameters

NameTypeDescriptionDefault
raw_data_1dnp.ndarrayThe flat, 1D complex numpy array loaded directly from the binary file.required
pv_paramsdictThe parsed Bruker parameter dictionary.required

Returns

NameTypeDescription
reshaped_datanp.ndarrayThe N-dimensional numpy array.
valid_dimslist[str]A list of dimension names matching the axes of reshaped_data.