vendor.bruker
Functions¶
| Name | Description |
|---|---|
| build_fid | Construct a strict xmris FID DataArray from an N-dimensional numpy array. |
| estimate_group_delay | Measure the true digital-filter group delay by minimizing residual phase. |
| remove_digital_filter | Remove the hardware digital filter group delay from Bruker FID data. |
| reshape_bruker_raw | Reshape 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:¶
PVM_SpecSWH (float): Spectral width in Hz. Used to calculate dwell time.
PVM_RepetitionTime (float): TR in ms. Used to calculate the repetition coordinate.
PVM_FrqRef (float): Reference Larmor frequency in MHz. (Required for to_ppm)
PVM_FrqWorkPpm (float): Carrier chemical shift in ppm. (Required for to_ppm)
groupDelay (float): Bruker specific FID delay. In
ACQ_RxFilterInfo.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
| data | np.ndarray | The squeezed, N-dimensional complex data array. | required |
| dims | list[str] | The dimension names matching the data axes. Must contain DIMS.time. | required |
| pv_params | dict | The parsed Bruker parameter dictionary. | required |
Returns¶
| Name | Type | Description |
|---|---|---|
| xr.DataArray | A 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¶
| Name | Type | Description | Default |
|---|---|---|---|
| da | xr.DataArray | Input free induction decay (FID) in the time domain. May be N-dimensional; the single highest-energy 1-D slice is used for estimation. | required |
| dim | str | The time dimension, by default DIMS.time. | DIMS.time |
| search_range | tuple of float | Explicit (low, high) delay bounds (samples) to search. If None (default), the window is anchored on the header: header ± window. | None |
| header_hint | float | Vendor-reported delay to anchor the search on. If None, falls back to da.attrs[group_delay] and then to a broad default range. | None |
| window | float | Half-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" |
| refine | bool | If True (default), refine the best integer delay to sub-sample precision. | True |
| return_profile | bool | If 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¶
| Name | Type | Description |
|---|---|---|
| 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:
Truncating the integer portion of the delay.
Applying a first-order phase correction to exactly compensate for the remaining fractional sub-point delay.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
| da | xr.DataArray | Input free induction decay (FID) data in the time domain. | required |
| group_delay | float 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' |
| dim | str | The time dimension along which to apply the correction, by default DIMS.time. | DIMS.time |
| keep_length | bool | If 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¶
| Name | Type | Description |
|---|---|---|
| xr.DataArray | The 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:¶
PVM_SpecMatrix (int): Number of points in the FID.
PVM_EncNReceivers (int): Number of receive channels (Default: 1).
PVM_NAverages (int): Number of averages (Default: 1).
PVM_NRepetitions (int): Number of repetitions (Default: 1).
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¶
| Name | Type | Description | Default |
|---|---|---|---|
| raw_data_1d | np.ndarray | The flat, 1D complex numpy array loaded directly from the binary file. | required |
| pv_params | dict | The parsed Bruker parameter dictionary. | required |
Returns¶
| Name | Type | Description |
|---|---|---|
| reshaped_data | np.ndarray | The N-dimensional numpy array. |
| valid_dims | list[str] | A list of dimension names matching the axes of reshaped_data. |