fitting.amares
Functions¶
| Name | Description |
|---|---|
| fit_amares | Apply AMARES time-domain fitting to an N-dimensional Free Induction Decay (FID). |
fit_amares¶
fitting.amares.fit_amares(
da,
prior_knowledge_file,
dim='time',
mhz=None,
sw=None,
deadtime=None,
method='leastsq',
initialize_with_lm=True,
num_workers=4,
init_fid=None,
verbose=False,
)Apply AMARES time-domain fitting to an N-dimensional Free Induction Decay (FID).
This function isolates the stateful pyAMARES API to perform parallelized batch fitting across spatial or repetition dimensions. It automatically scans the dataset to initialize the fitting template using the voxel with the highest Signal-to-Noise Ratio (SNR), ensuring robust prior knowledge instantiation.
The numerical results and the reconstructed time-domain fits are packed into an aligned xarray Dataset, preserving all physical coordinates.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
| da | xr.DataArray | Input FID data. Must contain the specified time dimension. | required |
| prior_knowledge_file | str | Path | Path to the CSV or XLSX file containing the prior knowledge constraints. | required |
| dim | str | The time dimension along which to fit, by default “time”. | 'time' |
| mhz | float | Spectrometer frequency in MHz. If None, attempts to read from da.attrs[‘MHz’]. | None |
| sw | float | Spectral width in Hz. If None, attempts to calculate from dim coordinates. | None |
| deadtime | float | Time delay before the first point in seconds. If None, defaults to 0.0. | None |
| method | (leastsq, least_squares) | Fitting method. Defaults to ‘leastsq’ (Levenberg-Marquardt). | "leastsq" |
| initialize_with_lm | bool | Run an internal Levenberg-Marquardt initializer before fitting. Defaults to True. | True |
| num_workers | int | Number of parallel processes to spawn. Defaults to 4. | 4 |
| init_fid | np.ndarray | A 1D complex array to use as the template for pyAMARES initialization. If None, the function automatically selects the spectrum with the highest SNR. | None |
| verbose | bool | If True, sets logging level to INFO. Default is False -> log level ERROR. | False |
Returns¶
| Name | Type | Description |
|---|---|---|
| xr.Dataset | A dataset containing the original data, the fitted FIDs, the residuals, and quantified parameters (amplitude, chem_shift, linewidth, phase, CRLB, SNR) mapped across the original dimensions and the new ‘Metabolite’ dimension. |