Listed below are the preprocessing routines that are run in GannetLoad.m. Whether a particular routine or subroutine is run will depend on the format of the inputted data and the options set in GannetPreInitialise.m.

RF coil combination

Certain raw MRS data formats store data without coil combination; specifically, GE P-file (.7), NIfTI-MRS (if the source data were raw), Philips .raw, and Siemens TWIX (.dat) data. Gannet uses generalized least squares1 to optimally combine the signal from the multiple RF channels. If water files are provided, these data will be used as references for signal weighting and phasing of the coil data.

Eddy-current correction

  Eddy-current correction can only be applied if water reference data are provided.

In GannetPreInitialise.m, users have the option to apply eddy-current correction (ECC) to metabolite and water data. If applied, Gannet uses the method described by Klose (1990)2. The code for the ECC routine can be found in EddyCurrentCorrection.m.

Phase correction

It is common for unprocessed spectra to be out of phase. Gannet applies a global zero-order phase correction to all transients by fitting the real-valued 3 ppm Cr and 3.2 ppm Cho signals in the frequency domain and correcting the phase to be 0° phase (i.e., to make all the Cr and Cho peaks have positive phase). This is performed in PhaseCorrection.m.

Line-broadending (apodization)

FID data are multiplied by a time-varying exponential weighting function where the weighting constant is set in GannetPreInitialise.m (3 Hz is the default).

Zero-filling

Gannet zero-pads all raw FIDs (i.e., adds zeros to the end of each FID) to obtain a nominal spectral resolution (the resolution between each frequency-domain data point) of 0.061 Hz/point. Differences in spectral width and number of complex data points of the raw FIDs are accounted for to obtain this nominal spectral resolution.

Frequency and phase alignment

During acquisition, spectral data are affected by frequency and phase offsets as a result of biophysical, electronic, and participant factors. Gannet has several algorithms to correct for these errors during preprocessing. Users can choose which method to use in GannetPreInitialise.m:

Method Option Description Function
Spectral registration3 SpecReg A time-domain-based alignment method that uses nonlinear least-squares optimization to align each individual transient to a reference transient. SpectralRegistration.m
Multi-step frequency and phase correction4 SpecRegHERMES A method originally developed to align multiplexed edited HERMES data. This approach is based on spectral registration. SpectralRegistrationHERMES.m
Robust spectral registration5 (the default and recommended) RobustSpecReg A method based on spectral registration that is robust against spectral distortions caused by unstable residual water peaks and lipid contamination. RobustSpectralRegistration.m
Peak alignment Cr, Cho, NAA, H2O Frequency-domain-based alignment using one of the following peaks in each transient as the target signal: Cr, Cho, NAA, or residual H2O. AlignUsingPeak.m, AlignUsingH2O.m
No alignment none Do not perform any frequency or phase alignment between transients. n/a

Signal averaging

Gannet provides two methods for averaging individual transients (selected in GannetPreInitialise.m): arithmetic averaging (with outlier rejection) and weighted averaging (the default). The code for the signal averaging routines can be found in SignalAveraging.m.

Arithmetic averaging

Arithmetic averaging is straightforward. All sequentially acquired \(n\) pairs of subspectra \(x_i\) (e.g., all edit-ON and edit-OFF subspectra) are averaged using the arithmetic mean: \(\bar{x} = \frac{1}{n}\sum_{i=1}^nx_i\).

Note that before the arithmetic averaging of subspectra, individual transients are excluded based on the outlier rejection algorithm used during frequency and phase alignment.

Weighted averaging

Weighted averaging down-weights individual difference subspectra that are corrupted by signal artifacts — this is an important distinction from traditional signal averaging. First, the difference between sequentially acquired pairs (e.g., all edit-ON and edit-OFF subspectra) is calculated. A similarity matrix \(\mathbf{D}\in\mathbb{R}^{P{\times}P}\) is obtained by calculating the mean squared error between each real-valued difference subspectrum \(p\) and every other real-valued difference subspectrum (in the range 1.8 to 3.4 ppm). A similarity metric \(d_{p}\) is calculated as the column-wise median of \(\mathbf{D}\). Normalized weights \(w_{p}\) are then derived, \(w_{p} = d^{-2}_p/\sum{d^{-2}_p}\), and applied to the difference pairs before summation.

Other algorithms to calculate weights can be found in SignalAveraging.m. (Note: These have not been tested extensively and should be considered experimental.)

Residual water removal

If water_removal is set to 1 in GannetPreInitialise.m (the default), the residual water peak is removed from all difference spectra using an HSVD filter6.


References

1.
An L, Willem van der Veen J, Li S, Thomasson DM, Shen J. Combination of multichannel single-voxel MRS signals using generalized least squares. Journal of Magnetic Resonance Imaging. 2013;37(6):1445-1450. doi:10.1002/jmri.23941
2.
Klose U. In vivo proton spectroscopy in presence of eddy currents. Magnetic Resonance in Medicine. 1990;14(1):26-30. doi:10.1002/mrm.1910140104
3.
Near J, Edden R, Evans CJ, Paquin R, Harris A, Jezzard P. Frequency and phase drift correction of magnetic resonance spectroscopy data by spectral registration in the time domain. Magnetic Resonance in Medicine. 2015;73(1):44-50. doi:10.1002/mrm.25094
4.
Mikkelsen M, Saleh MG, Near J, et al. Frequency and phase correction for multiplexed edited MRS of GABA and glutathione. Magnetic Resonance in Medicine. 2018;80(1):21-28. doi:10.1002/mrm.27027
5.
Mikkelsen M, Tapper S, Near J, Mostofsky SH, Puts NAJ, Edden RAE. Correcting frequency and phase offsets in MRS data using robust spectral registration. NMR in Biomedicine. 2020;33(10):e4368. doi:10.1002/nbm.4368
6.
Barkhuijsen H, Beer R de, Ormondt D van. Improved algorithm for noniterative time-domain model fitting to exponentially damped magnetic resonance signals. Journal of Magnetic Resonance. 1987;73(3):553-557. doi:10.1016/0022-2364(87)90023-0
LS0tCnRpdGxlOiAiUHJlcHJvY2Vzc2luZyIKZGF0ZTogIkxhc3QgdXBkYXRlZDogYHIgZm9ybWF0KFN5cy50aW1lKCksICclQiAlZCwgJVknKWAiCmJpYmxpb2dyYXBoeTogYmlibGlvZ3JhcGh5LmJpYgpjc2w6IGFtZXJpY2FuLW1lZGljYWwtYXNzb2NpYXRpb24uY3NsCmxpbmstY2l0YXRpb25zOiB5ZXMKb3V0cHV0OgogIGh0bWxfZG9jdW1lbnQ6CiAgICB0b2M6IFRSVUUKICAgIHRvY19kZXB0aDogMgogICAgdG9jX2Zsb2F0OgogICAgICBjb2xsYXBzZWQ6IEZBTFNFCi0tLQoKYGBge3Igc2V0dXAsIGluY2x1ZGUgPSBGQUxTRX0Ka25pdHI6Om9wdHNfY2h1bmskc2V0KGVjaG8gPSBUUlVFKQpgYGAKCmBgYHtyLCBjaGlsZCA9ICJqcy9iYWNrLXRvLXRvcC5qcyJ9CmBgYAoKYGBge2NzcywgZWNobyA9IEZBTFNFfQp0YWJsZSB7CiAgbWFyZ2luOiBhdXRvOwp9Cgp0YWJsZSB0aGVhZCB0aCB7CiAgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkICNkZGQ7Cn0KCnRoLCB0ZC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