Advanced processing and simulation of MRS data using the FID appliance (FID-A)—An open source, MATLAB-based toolkit

Authors

  • Robin Simpson,

    1. Department of Radiology, Medical Physics, Freiburg University, Freiburg, Germany
    Search for more papers by this author
  • Gabriel A. Devenyi,

    1. Centre d'Imagerie Cérébrale, Douglas Mental Health University Institute, Montreal, Canada
    Search for more papers by this author
  • Peter Jezzard,

    1. FMRIB Centre, Nuffield Department of Clinical Neurosciences, University of Oxford, Oxford, UK
    Search for more papers by this author
  • T. Jay Hennessy,

    1. Centre d'Imagerie Cérébrale, Douglas Mental Health University Institute, Montreal, Canada
    2. Department of Biomedical Engineering, McGill University, Montreal, Canada
    Search for more papers by this author
  • Jamie Near

    Corresponding author
    1. Centre d'Imagerie Cérébrale, Douglas Mental Health University Institute, Montreal, Canada
    2. Department of Biomedical Engineering, McGill University, Montreal, Canada
    3. Department of Psychiatry, McGill University, Montreal, Canada
    • Correspondence to: Dr. Jamie Near, Room GH-2113, CIC Pavilion, Douglas Mental Health University Institute, Department of Psychiatry, McGill University, Montreal, Canada, H4H 1R3. Telephone: 514-761-6131 ext. 4759; FAX: 514-888-4487; E-mail: jamie.near@mcgill.ca

    Search for more papers by this author

  • Correction made after online publication 14 January 2016. References 17 and 42 were updated with page numbers. The caption of Figure 7b was updated to “a generic MEGA-PRESS basis set.” Additional grammatical errors were corrected on page 5.

Abstract

Purpose

To introduce a new toolkit for simulation and processing of magnetic resonance spectroscopy (MRS) data, and to demonstrate some of its novel features.

Methods

The FID appliance (FID-A) is an open-source, MATLAB-based software toolkit for simulation and processing of MRS data. The software is designed specifically for processing data with multiple dimensions (eg, multiple radiofrequency channels, averages, spectral editing dimensions). It is equipped with functions for importing data in the formats of most major MRI vendors (eg, Siemens, Philips, GE, Agilent) and for exporting data into the formats of several common processing software packages (eg, LCModel, jMRUI, Tarquin). This paper introduces the FID-A software toolkit and uses examples to demonstrate its novel features, namely 1) the use of a spectral registration algorithm to carry out useful processing routines automatically, 2) automatic detection and removal of motion-corrupted scans, and 3) the ability to perform several major aspects of the MRS computational workflow from a single piece of software. This latter feature is illustrated through both high-level processing of in vivo GABA-edited MEGA-PRESS MRS data, as well as detailed quantum mechanical simulations to generate an accurate LCModel basis set for analysis of the same data.

Results

All of the described processing steps resulted in a marked improvement in spectral quality compared with unprocessed data. Fitting of MEGA-PRESS data using a customized basis set resulted in improved fitting accuracy compared with a generic MEGA-PRESS basis set.

Conclusions

The FID-A software toolkit enables high-level processing of MRS data and accurate simulation of in vivo MRS experiments. Magn Reson Med 77:23–33, 2017. © 2015 Wiley Periodicals, Inc.

INTRODUCTION

Magnetic resonance spectroscopy (MRS) enables noninvasive measurement of tissue metabolite levels in vivo. Localized in vivo MRS has been in existence for nearly three decades [1-3] and still remains unique today in its ability to measure tissue metabolite levels noninvasively. The metabolite measurements obtained by MRS can provide useful information for clinical diagnosis [4-6] as well as for basic physiological and biochemical research [7-13].

Dedicated computing software is a necessity for in vivo MRS experimentation. For example, computer-aided simulations are often necessary to determine the optimal acquisition parameters for metabolite detection, or to generate prior knowledge (i.e., basis spectra) for use in spectral analysis. Furthermore, both data processing (to prepare the acquired data for analysis) and spectral analysis (to estimate metabolite peak intensities) benefit greatly from custom software tools. A number of software packages are available, both freely and commercially, to aid in various aspects of the MRS workflow, including spectral simulation [14-18], spectral processing [13, 16, 17, 19, 20], radiofrequency (RF) pulse design [21], and spectral analysis [17, 18, 20, 22-26].

In this paper, we present a powerful and flexible new open-source MRS software toolkit that enables advanced MRS simulation and data processing, as well as basic design and analysis of radiofrequency pulses. This new toolkit is called the FID appliance (FID-A), and is freely available from https://github.com/CIC-methods/FID-A. The FID-A toolkit contains a number of unique features. First, FID-A is specifically designed for managing raw MRS data sets, which often contain multiple dimensions of data resulting from the presence of multiple RF channels, averages, and/or subspectra (eg, spectral editing or other subtraction MRS data such as ISIS [2] or SPECIAL [27]). By providing a convenient tool for the management of such raw, multidimensional data, this software toolkit facilitates the implementation and use of higher-level processing and analysis routines such as advanced coil combination [28], frequency and phase drift correction [29-33], and processing of functional MRS time-series data [13, 34, 35]. Second, the FID-A toolkit integrates a vast library of simulation and processing operations that are not currently available, to our knowledge, within a single piece of software. FID-A also includes functions for importing MRS data in the proprietary formats of most MRI vendors (eg, Siemens, Philips, GE, Agilent, Bruker) as well as functions for importing from and exporting to the formats of common analysis software packages (eg, LCModel, jMRUI, Tarquin). Finally, FID-A is written in MATLAB (The Mathworks, Natick, Massachusetts, USA), and is almost entirely command-line based. The widespread use of MATLAB among the medical imaging research community will ensure easy adoption of this software by most users. Furthermore, the primarily command-line nature of the software provides users with a high level of flexibility and efficiency.

In this paper, we focus specifically on a few unique aspects of the FID-A toolbox: 1) The use of the recently described spectral registration algorithm [29] to automatically perform useful processing routines such as frequency and phase correction of averages, alignment of MRS data from separate scans, and alignment of subspectra (both from J-difference editing [36] and ISIS [2] sequences) prior to subtraction; 2) automatic detection and removal of motion corrupted scans; and 3) the ability to perform several major aspects of the MRS computational workflow from a single piece of software. This latter feature is illustrated through both high-level processing of in vivo GABA-edited MEGA-PRESS MRS data, as well as detailed quantum mechanical simulations to generate an accurate LCModel basis set for the same data.

METHODS

Basic Description of the FID-A Toolkit

The FID-A software toolkit (Version 1.0) consists of four separate “toolboxes”:

  • The Input-Output Toolbox contains functions for reading and writing data between MATLAB and other useful data formats. MRS data can be imported from the formats of major MRI vendors (eg, Siemens, Agilent, Philips, GE, Bruker), and can also be imported from and exported to the formats of major MRS software packages (LCModel, jMRUI, and Tarquin). Once loaded into MATLAB, data sets are then stored in uniquely formatted data structures that encapsulate the data (in both the time domain and frequency domain), as well as the relevant header information, in the fields of the structure. By encapsulating data and header information in this way, processing operations have access to all relevant information and thus require as few input arguments as possible. In addition to reading and writing MRS data, the Input-Output Toolbox also supports reading and writing RF pulses in three MRI vendor formats (Siemens, Agilent, and Bruker) with more formats to be supported in the future. The names of all functions in the Input-Output Toolbox begin with the prefix “io_.”
  • The RF-Pulse Toolbox enables the design of basic RF pulse waveforms (Gaussian, dual-banded Gaussian, sinc, and hyperbolic secant), as well as Bloch simulation to determine the magnetization profiles of designed or imported RF pulses. The RF-Pulse Toolbox is also equipped with tools for manipulating existing RF waveforms, including frequency shifting and resampling. Importantly, the RF-Pulse Toolbox interfaces with the Simulation Toolbox to enable simulations that incorporate fully shaped RF waveforms. All functions in the RF-Pulse Toolbox are named with the prefix “rf_.”
  • The Simulation Toolbox enables the simulation of in vivo MRS experiments using an implementation of the density matrix formalism, in which the nuclear magnetic resonance (NMR) experiment is modeled as a series of successive evolutions of the density matrix, math formula, by time-independent Hamiltonian operators, math formula, as shown in Eq. (1) [37, 38]:
    display math(1)
    Included within the FID-A Simulation Toolbox is a full set of metabolite spin system definitions based on previously published values [39, 40]. Implementations of a number of common in vivo MRS pulse sequences (FID, PRESS, STEAM, and spin-echo) are also included, and RF pulses can be modeled either as instantaneous rotations or fully shaped waveforms. To enable users to easily simulate their own pulse sequences, the Simulation Toolbox contains functions for simulating all of the basic building blocks of a pulse sequence, including excitation, delays, refocusing pulses, and signal readout. All functions in the simulation toolbox are named with the prefix “sim_.”
  • The Processing Toolbox contains over 50 different processing operations, which can be applied to both simulated and experimental datasets. Many of the processing operations are designed specifically to operate on data sets with higher dimensionality (eg, multiple averages, multiple receive channels). All functions in the Processing Toolbox are named with the prefix “op_”, which stands for “operation.”

A full listing of the functions currently available in each toolbox is shown in the Supporting Information, Table S1. In addition to the four toolboxes listed previously, FID-A also comes with a library of example run scripts, which provide examples of useful “pipelines” for NMR simulation and data processing using combinations of the various functions within the FID-A Toolboxes. Finally, although the FID-A toolkit is primarily MATLAB command-line based, a few graphical user interfaces are also provided to assist with operations in which visual feedback is required.

MRS Scanning

Fourteen healthy participants (11 male, 3 female, age = 24.3 ± 3.5 years) were scanned using a Siemens (Erlangen, Germany) 3 Tesla Magnetom TIM Trio MRI system with a body coil transmitter and a 32-channel head receiver array. All participants provided informed consent prior to scanning, and scans were approved by the local research ethics committee. In each subject, a three-plane localizer image was acquired, followed by a T1-weighted magnetization-prepared rapid gradient echo (MP-RAGE) anatomical image with 1-mm isotropic resolution. The anatomical image was used to guide placement of a 3 × 3 × 2 cm2 voxel in the dorsolateral prefrontal cortex (DLPFC). The voxel was aligned with the angle of the skull above the DLPFC to maximize the inclusion of cortical gray matter. Localized first and second-order shimming of this region was performed using the FASTESTMAP sequence [41]. Short echo-time MRS data were then acquired using the SPECIAL sequence with TE 8.5 ms, and the GABA-edited MRS data were acquired using the MEGA-PRESS sequence with TE=68 ms. Both sequences used the following parameters (TR = 3200 ms, 2048 spectral points, 2000-Hz spectral width, 160 averages, ∼8.5-min scan time).

Spectral Registration

The method of time-domain spectral registration was described recently as an automated way to estimate and correct frequency and phase drift errors in in vivo MRS data [29]. Specifically, spectral registration uses nonlinear least-squares minimization to fit each time-domain signal average, S(t), to a reference scan, R(t), by adjustment of the frequency, f (in Hz) and phase, ϕ (in degrees), of the signal S(t), which can be expressed as follows:

display math(2)

where

display math(3)

In addition to frequency and phase drift correction, the above algorithm can also be applied (with minor modifications) toward other useful processing operations, such as the alignment of multiple MRS data sets for the purposes of group-wise comparison, or the alignment of the subspectra of subtraction sequences such as the ISIS [2] localized SPECIAL sequence [27] or the MEGA-PRESS J-difference editing sequence [36]. In the case of frequency and phase drift correction, the reference scan, R(t), can be either the first average in the series or the overall time series average. Likewise, for the case of aligning separate MRS data sets, the reference scan can either be one of the individual data sets, or the group-wise average data set. For the case of aligning the subspectra of J-difference editing data prior to subtraction, the reference scan can be one of either the edit-on or edit-off sub-spectra. The special case in which spectral registration is used to align ISIS subspectra prior to subtraction requires a few additional modifications, as described below.

The SPECIAL sequence involves the collection of interleaved pairs of two averages, one with and one without a slice-selective ISIS pre-inversion pulse. Each individual average (or subspectrum) contains large signal contributions from outside the region of interest, and only upon subtraction of the inversion on/off pairs is the signal properly localized to the region of interest. However, very subtle patient motion can induce small frequency and phase shifts between subspectra that result in noticeable subtraction errors. These errors are particularly noticeable when the subspectra contain large lipid signals due to ineffective outer volume suppression, and artifacts appear in the difference spectra as random fluctuations in signal intensity from shot to shot at the frequency of the lipid resonance (Figure 1). Because these subtraction errors result from small motion-induced frequency and phase offsets between subspectra, they can be corrected simply by adjusting the relative phase and frequency of the subspectra prior to subtraction. This procedure can be achieved using a variant of spectral registration in which, rather than minimizing the difference between the subspectra themselves, minimization is performed between a single difference spectrum (formed from the subtraction of a single inversion on/off subspectrum pair) and the time series average of all difference spectra, as shown below:

display math(4)

where

display math(5)

and where N is the total number of on-off pairs acquired, i is the index of the on-off pair to be corrected, and SOFF and SON are the inversion-off and inversion-on ISIS subspectra, respectively.

Figure 1.

Alignment of inversion on/off subspectra using the op_alignISIS.m function. The inversion-on and inversion-off subspectra are shown above. A large lipid signal is clearly visible in the subspectra at approximately 1.3 ppm. The resulting difference spectra (scaled up by a factor of 10) are shown below (third from top). Subtle patient motion leads to imperfect subtraction of this resonance in the difference spectrum, resulting in unstable signal intensity near the lipid and water resonances. However, following the use of spectral registration to align the SPECIAL subspectra prior to subtraction, the signal instabilities are effectively removed (bottom).

To demonstrate the use of spectral registration for the applications described previously, the inversion on/off subspectra of the acquired SPECIAL data were aligned using the op_alignISIS.m function. Following the processing of each individual spectrum, all 14 spectra were automatically frequency and phase aligned to one of the data sets (the first subject scanned) using the op_alignAllScans_fd.m function, which uses a limited frequency range to perform the alignment. For this example, the frequency range used was 0.2–4.2 ppm.

Removal of Motion Corrupted Averages

Although a small amount of subject motion during scanning results in minor shifts in spectral frequency and phase that can be corrected using spectral registration as described previously, larger motions often result in severe spectral distortion that cannot be corrected by simple frequency and phase adjustment. One previously described method for mitigating the effects of motion corrupted averages is the all rank selection order statistic (ARSOS) filtering method, which is available as a plugin in jMRUI, and is also implemented in the FID-A Processing Toolbox (op_arsos.m). The ARSOS method involves calculating the median (rather than the average) of the spectral averages [42]. Although this method reduces the influence of motion-corrupted averages, it also results in a reduction in signal-to-noise ratio (SNR) by a factor of sqrt(2/pi). An alternative approach is to identify and remove motion corrupted averages prior to signal averaging, and the FID-A Processing Toolbox also includes processing functions for this purpose (op_rmbadaverages.m, op_rmNworstaverages.m, op_rmworstaverage.m). Identification of motion-corrupted averages is performed by calculating the “deviation” of each average from the rest of the averages. Specifically, this deviation metric is calculated for each individual average by subtracting that average from the time-series average (to obtain a difference spectrum) and then taking the root mean square of all of the spectral points in that difference spectrum. Scans whose deviation metrics fall above a certain threshold are deemed to have been corrupted by motion, and are removed. The threshold is quantified in terms of the number of standard deviations above the mean deviation metric, and a typical cutoff is between 2.6–3.2 standard deviations. To demonstrate the use of this method, processing of the acquired MEGA-PRESS MRS data was performed using the FID-A Processing Toolbox, including the removal of motion-corrupted averages using the op_rmbadaverages.m function. Importantly, because MEGA-PRESS data contain two subspectra (edit-on and edit-off), removal of bad averages must be performed separately for each of the two sets of subspectra. In such cases, the op_rmbadaverages.m function automatically recognizes when its input contains multiple subspectra, and acts accordingly with no user input. In data sets with multiple subspectra, when one corrupted average is detected and removed, its editing pair is automatically removed as well so that equal numbers of both subspectra are always maintained.

Processing and Simulation Pipelines

As mentioned previously, the FID-A Toolkit contains a folder of example run scripts, which are examples of automated MRS data processing pipelines. These pipelines accept raw MRS data in Siemens .dat (twix) format (although they can readily be modified to accept raw data in other formats) and then operate on them in a logical step-by-step fashion to generate fully processed spectra that are ready to be analyzed using one of the leading MRS analysis software packages (LCModel, jMRUI, or Tarquin).

In addition to processing pipelines, a number of simulation pipelines are also contained within the folder of example run scripts. These are examples of detailed, spatially resolved simulations involving pulse sequences with shaped RF pulses.

To demonstrate the utility of the simulation and processing pipelines provided within FID-A, we applied both pipelines in an example involving both processing and LCModel fitting of MRS data. First, the raw acquired MEGA-PRESS data were processed using the run_megapressproc_auto.m function in MATLAB R2012a (7.14.0.739, 64-bit). This processing script involves the following sequence of processing operations, as shown in Figure 2: First, a weighted coil array reconstruction was performed using op_addrcvrs.m, with receiver weights and phases determined from the magnitude and phase, respectively, of the first point in the time domain. This was followed by the removal of motion-corrupted averages using op_rmbadaverages.m as described previously, with a removal threshold of 3.2 standard deviations. This procedure was iterated until no motion-corrupted averages remained. Then, iterative retrospective frequency- and phase-drift correction of averages was performed using op_alignaverages_fd.m. This function implements the method of spectral registration over a limited frequency range, as described previously [29], and the function is iterated within the pipeline using various different frequency range values until convergence of the frequency and phase drift estimates is achieved. Following the frequency and phase alignment, averaging was performed using the op_averaging.m function. Automatic phase correction was then performed using the first point in the fid, and adjustment of the relative frequency and phase of the edit-on and edit-off spectra was performed automatically using op_alignMPSubspecs.m. Finally, difference spectra were obtained by subtraction of the edit-on and edit-off subspectra using the op_combinesubspecs.m function.

Figure 2.

Block diagram showing all individual steps in the automated processing pipeline for MEGA-PRESS MRS data (run_megapressproc_auto.m). Dotted lines indicate optional steps.

The impact of processing on spectral quality was assessed at various stages of the analysis. First, using the methods described by Slotboom et al [42], we calculated the skewness and kurtosis intervals, kskewness ± st.dev(kskewness) and kkurtosis ± st.dev(kkurtosis), respectively, to determine the spectral reliability both before and after processing (but before signal averaging) using the above pipeline. As suggested by Slotboom et al [42], spectra were considered to be unreliable if their skewness and kurtosis values differed significantly from those of pure Gaussian noise, which has kskewness = 0.3272 and kkurtosis = 0.6101. These metrics were calculated automatically using the FID-A function op_relyTest.m. Second, the FID-A functions op_getLW.m and op_getSNR.m were used to calculate the linewidth and SNR, respectively, of the fully processed data, the averaged data without processing, and the ARSOS filtered data.

Detailed, spatially resolved simulations were then performed to generate a metabolite basis set for fitting the processed MEGA-PRESS data in the LCModel. The exact experimental shapes of both the editing and localization pulses were taken fully into account, and all simulation parameters were designed to mimic as closely as possible the experimental parameters of the acquired in vivo MEGA-PRESS spectrum described previously. Simulations were performed in MATLAB R2012a (7.14.0.739, 64-bit) on a 24-CPU Intel Xeon E5645 with 2.40 GHz and 48 GB of RAM. The first echo time (TE1) was 10.4 ms and the second echo time (TE2) was 57.6 ms (total TE = 68 ms). The editing pulses were placed such that the time between the center of the first editing pulse and the center of the second refocusing pulse was 17.9 ms, and the time between the center of the second refocusing pulse and the center of the second editing pulse was 16.1 ms. Slice-selective refocusing was achieved using a 5.2-ms optimal selective 180 ° pulse [43] with 100 points and a bandwidth of 1105 Hz, whereas frequency-selective editing was achieved using a 17-ms Gaussian pulse with 100 points and a full width at half-maximum bandwidth of 72 Hz. Slice-selective gradient strengths were chosen such that both refocusing pulses had a selection width of 3 cm each, with the first refocusing pulse selective along the x-direction and the second refocusing pulse selective along the y-direction. Simulations were performed on a 48 × 48 grid of equally spaced points ranging from 2.5 to 2.5 cm in both the x and y directions and a step size of 0.1064 cm. To remove unwanted coherences at each spatial position, a 16-step phase cycle involving both editing and refocusing pulses was performed. Specifically, each of the editing and refocusing RF pulses was cycled through two phases (0 and 90 °). The editing pulse was applied at 1.88 ppm in edit-on scans, and 7.5 ppm in edit-off scans. The magnetic field strength (B0) was 2.89 T, which corresponds to the magnetic field strength of the Siemens Magnetom TIM Trio system. The MATLAB parallel processing toolbox was used in conjunction with 12 processing cores to parallelize the simulation along the spatial x-direction, thus reducing the duration of the simulation by a factor of 12. Simulation was performed for the following metabolites: creatine (Cr), phosphocreatine (PCr), glutamate (Glu), glutamine (Gln), γ-aminobutyric acid (GABA), glutathione (GSH), glycerophosphocholine (GPC), phosphocholine (PCh), N-acetylaspartate (NAA), N-acetylaspartylglutamate (NAAG), myo-inositol (Ins), scyllo-inositol (Scyllo), and Aspartate (Asp). The simulated metabolite spectra were then used to generate three LCModel basis sets for the MEGA-PRESS sequence: one for the edit-on spectrum, one for the edit-off spectrum, and one for the difference spectrum. The edit-on and edit-off basis sets contained all metabolite basis spectra, but the basis set for the difference spectrum contained only GABA, Glu, Gln, GSH, NAA, and NAAG. These three basis sets were then used to fit all acquired, processed MEGA-PRESS spectra in LCModel. To enable the comparison of the fitting performance of our simulated basis set against some standard, the acquired, processed MEGA-PRESS spectra were also fitted in LCModel using a generic MEGA-PRESS basis set, which was obtained from http://purcell.healthsciences.purdue.edu/mrslab/downloads.htm. This generic basis set is provided freely online and was generated using simulations that incorporated shaped editing pulses but not shaped refocusing pulses, and the specific pulse-sequence parameters and timings were not optimized to match the parameters of our data acquisition. Furthermore, because generic basis sets were available only for edit-off and difference spectra, an edit-on version of the generic basis set was also generated by combining the edit-off and difference basis spectra (edit-on = difference + edit-off).

RESULTS

Spectral Registration

Figure 1 shows an example of the use of the function op_alignISIS.m for the alignment of inversion on/off subspectra in data acquired using the SPECIAL sequence. Shown in this figure are all averages of the inversion-on and inversion-off spectra and the resulting difference spectrum scaled up by a factor of 10. A large lipid signal is clearly visible in the subspectra at approximately 1.3 ppm. Very subtle patient motion led to imperfect subtraction of this resonance in the difference spectrum, resulting in unstable signal intensity at that frequency. A similar effect occurred around the large residual water resonance. However, following the use of spectral registration to align the SPECIAL subspectra prior to subtraction, the signal instabilities were effectively removed in all 14 subjects. Figure 3 shows 14 SPECIAL MRS data sets acquired from the left primary motor cortex of 14 healthy volunteers, before and after alignment using the op_alignAllScans_fd.m function. Despite differences in signal intensity across individuals, the spectral registration method was effective at automatically aligning the scans. Figure 4 shows examples of both the removal of motion-corrupted averages, and the frequency and phase drift correction in a MEGA-PRESS data set from one of the participants. Figure 4a shows all of the averages for both edit-on and edit-off sub-spectra, before the removal of motion-corrupted averages. The calculation of deviation metrics for removal of motion-corrupted averages is illustrated in Figure 4b. Each blue dot represents the deviation metric for a single average, whereas the local mean and +3.2 standard deviation threshold of deviation values are represented by the green and dotted red lines, respectively. For simplicity, Fig. 4b shows only the first iteration of this procedure in which one of the edit-off averages was removed, along with its edit-on pair. This procedure was iterated until no motion-corrupted averages remained. Figure 4c shows all of the averages for both edit-on and edit-off sub-spectra, following the removal of motion-corrupted averages. By visual comparison of Figures 4a and 4c, it is clear that the most obviously motion-corrupted averages were removed by this procedure. Following the removal of motion-corrupted averages, the correction of frequency and phase drifts was performed by iterative spectral registration over a limited frequency range (op_alignAverages_fd.m). Figure 4d shows the estimated frequency and phase drift values for both edit-on and edit-off scans, and Figure 4e shows all of the averages for both edit-on and edit-off subspectra following the frequency and phase drift correction. By visual comparison of Figures 4c and 4e, it is clear that the alignment of the averages has been significantly improved by the spectral registration.

Figure 3.

Automated alignment of 14 separately acquired SPECIAL MRS data sets from the left primary motor cortices of healthy volunteers, using spectral registration (op_alignAllScans_fd.m). This kind of alignment enables group-wise averaging or group-wise comparisons.

Figure 4.

Removal of motion-corrupted averages in MEGA-PRESS data using op_rmbadaverages.m and spectral registration using op_alignaverages_fd.m. (a) All averages (both edit-on and edit-off) before the removal of motion-corrupted averages. (b) Calculation of deviation metrics for removal of motion-corrupted averages. Each blue dot represents the deviation metric for a single average, whereas the local mean and +3.2 standard deviation threshold are represented by the green and dotted red lines, respectively. (c) All averages after the removal of motion-corrupted averages. The most obviously motion-corrupted averages from (a) have been removed. (d) The estimated frequency and phase drift values for both edit-on and edit-off scans. (e) All averages following the frequency and phase drift correction. The alignment of the averages has been noticeably improved by spectral registration.

Figure 5 summarizes the effects of the processing pipeline on reliability metrics for all subjects. Specifically, the skewness and kurtosis intervals calculated before and after spectral processing (but before signal averaging) are shown for both edit-on and edit-off subspectra. Based on these reliability metrics, 8 of 14 subjects did not pass the reliability test before spectral processing, whereas 14 out of 14 subjects passed the reliability test following FID-A spectral processing. Table 1 summarizes the final spectral linewidth and SNR of the final difference spectrum for all subjects in the case of unprocessed, fully processed, and ARSOS-filtered data. Table 1 also lists the total frequency and phase drift for each subject, as well as the number of motion corrupted averages that were removed in processing. Without processing, the average difference spectrum linewidth was 4.7 Hz. ARSOS filtering had no effect on linewidth compared with the unprocessed data, whereas the FID-A processing pipeline resulted in approximately a 5% reduction in linewidth (4.5 Hz) compared with both the unprocessed data and ARSOS filtered data. As expected, ARSOS filtering resulted in a reduction in SNR. Despite the removal of motion-corrupted averages, the FID-A processing pipeline resulted in an increase in SNR over unprocessed data and ARSOS-filtered data by 2 and 34%, respectively. Across all subjects, the mean frequency and phase drift were 2.2 Hz and 69 °, respectively, whereas on average, 20 motion-corrupted averages were identified and removed by the op_rmbadaverages.m function. Figure 6 shows an example of the MEGA-PRESS difference spectrum with no processing, after ARSOS filtering, and with processing. In this example, it is clear that FID-A processing resulted in an improvement in spectral lineshape (reduction in choline and creatine subtraction artifacts) compared with unprocessed and ARSOS-filtered data.

Figure 5.

Reliability testing before and after spectral processing (before signal averaging). Skewness intervals (left) and kurtosis intervals (right) are shown for edit-on and edit-off data both before and after spectral processing using the run_megapressproc_auto.m pipeline. A data set was considered reliable if the skewness and kurtosis intervals contained the values 0.3272 and 0.6101, respectively. Prior to processing, 8 of 14 subjects did not pass the reliability testing, whereas after processing, 14 of 14 subjects passed the reliability testing.

Figure 6.

Final edited MEGA-PRESS difference spectrum without processing (green curve), following ARSOS filtering (red curve) and with high-level processing using the FID-A toolkit (black curve). FID-A processing resulted in 2 and 37% increases in SNR compared with no processing and ARSOS filtering, respectively. FID-A processing also resulted in a 5% decrease in linewidth compared with both no processing and ARSOS filtering. Furthermore, FID-A processing resulted in a reduction in the appearance of subtraction artifacts from water, choline, and creatine.

Table 1. Spectral Quality Metrics for MEGA-PRESS Difference Spectra Across All Subjects Scanned
Subject No.Linewidth (Hz)SNRFrequency drift (Hz)Phase drift (deg)Number of averages removed
PreARSOSPostPreARSOSPost
  1. Note: Linewidth and SNR are shown for unprocessed, ARSOS-filtered, and FID-A processed difference spectra. Linewidth and SNR were calculated using the FID-A functions op_getLW.m and op_getSNR.m. Also shown are the average measured frequency and phase drift, and the number of averages removed by the automated removal of motion-corrupted averages.

014.44.33.52291592603.4966
024.74.84.72101412251.88412
034.54.54.42571682582.47128
044.74.64.32731882792.75526
056.46.45.82471582634.55516
064.74.74.62651722611.99510
075.15.15.02631862612.26428
086.36.46.22031482041.37022
094.13.93.92691812812.15620
103.83.83.73032073031.76124
115.15.14.72201342392.410014
123.43.43.33592403441.05626
134.44.44.23352183251.74524
144.74.74.52391632322.05426
Mean4.74.74.52621762672.26920

Simulation and Fitting Results

The computation time for the full spatially resolved MEGA-PRESS simulation was highly dependent on the number of spins in the spin system of interest. Simulation of the scyllo and PCh-trimethyl systems, which were each modeled as a single spin and later scaled up by a factor of nine, took approximately 1.5 h. For the largest spin systems simulated, such as GABA, Ins, and the glutamate group of NAAG, which each contained six spins, the simulation time was approximately 30 h. An example of the LCModel fitting results for the in vivo acquired MEGA-PRESS is shown in Figure 7a for each of the edit-on, edit-off, and difference spectra. An excellent fit was achieved, as evidenced by the good correspondence between data and fit, and the primarily flat residuals. For comparison, Figure 7b shows the same in vivo spectrum after fitting using a generic MEGA-PRESS basis set, which did not take into account the specific timings of the acquisition, or the shapes of the refocusing pulses. The use of the more generic MEGA-PRESS basis set led to a visibly poorer fit, as evidenced by the large peaks in the residual. Similar improvements in fit quality were observed across all 14 subjects when using the FID-A basis set, compared with the generic basis set. On average across 14 subjects, the use of the FID-A basis set resulted in a reduction in the standard deviation of the fit residual by 47 ± 8 %, 36 ± 7 %, and 10 ± 4% for the edit-on, edit-off, and difference spectra, respectively.

Figure 7.

LCModel fitting of acquired MEGA-PRESS data using (a) a basis set generated in the FID-A simulation toolbox, accounting for the exact sequence timings and the RF pulse waveforms, and (b) a generic MEGA-PRESS basis set. Accounting for the exact RF waveforms and sequence timings results in a marked improvement to the LCModel fit quality in all subjects. Specifically, the standard deviation of the fit residual was reduced by an average of 47 ± 8%, 36 ± 7%, and 10 ± 4% for the edit-on, edit-off, and difference spectra, respectively.

DISCUSSION

The FID Appliance is a powerful and flexible new software toolkit that enables simulation of in vivo MRS experiments, design and analysis of radiofrequency pulses, and processing of in vivo MRS data. In this paper, we highlighted just a few of the unique features of the FID-A toolkit, including the use of spectral registration for a number of useful processing operations, the ability to automatically identify and remove motion-corrupted averages, and the ability to perform several major aspects of the MRS computational workflow (such as high-level processing and accurate simulation) within a single piece of software. The particular design of the FID-A toolkit to manage and process raw MRS data sets with multiple dimensions of data is a feature that, to our knowledge, is not currently available in any other MRS software packages. For this reason, most of the papers describing the development or use of high-level processing operations on multidimensional MRS data have involved the use of “home-grown” software implementations, and have not relied on any publicly available software packages (13,28–35). It is also likely, for this reason, that many papers do not report the use of high-level processing routines such as frequency and phase drift correction, or the removal of motion-corrupted averages prior to signal averaging, despite the fact that the importance of such processing routines is increasingly accepted [29, 44]. The lack of availability of tools for high-level MRS data processing up to this point may have contributed to a lag in the uptake of MRS methods in both research and in the clinic, and may also have also contributed to a lack of consistency or replicability of results in the MRS literature. It is hoped, then, that the FID-A software toolkit will provide a common platform for the development and dissemination of open-source processing tools for in vivo MRS data, thus enabling improved consistency and replicability of MRS methods across sites.

At this point, it is worth noting some of the similarities and differences in functionality between FID-A and other currently available MRS software packages. The software packages that share the greatest similarities to FID-A are VeSPA [16] and jMRUI [17]. Like FID-A, both of these software packages contain a full suite of NMR simulation tools and spectral processing tools. Like FID-A, VeSPA also contains a suite of tools for RF pulse design and Bloch simulation. However, these software packages both differ from FID-A in a number of important ways. First, although FID-A is designed to enable the processing of raw data sets with multiple RF coil channels, multiple averages, or multiple subspectra of data, neither VeSPA nor jMRUI is capable of handling higher dimensional data sets in this way. Second, the FID-A simulation toolbox includes several built-in functions and example run scripts for realistic simulation of pulse sequences with shaped RF waveforms. Although both VeSPA and jMRUI are also capable of simulating pulse sequences with shaped RF waveforms, the actual implementations are not provided and must be coded manually by the user. Third, whereas both VeSPA and jMRUI are graphical user interface (GUI) based, FID-A is run primarily from the MATLAB command line. The advantage of a command line-based approach is that it provides a high degree of flexibility and efficiency through the use of scripts that require no user interaction. Finally, both VeSPA and jMRUI contain advanced spectral fitting and analysis tools that are not currently included within FID-A.

Although FID-A is equipped for processing multidimensional MRS data sets, it is not designed for the fitting of two-dimensional (2D) MRS data, such as 2D J-resolved MRS or 2D-COSY. There are currently at least two software packages that are capable of fitting such multidimensional MRS data: ProFit [23] and FitAid [26]. The Gannet software package [20] is capable of processing data sets with higher dimensionality (multiple averages, multiple coil channels, and multiple subspectra); however, this software is designed specifically for the processing and analysis of GABA-edited MEGA-PRESS MRS data, and cannot currently be used to process and analyze other types of MRS data in the way that FID-A can.

Because of the need for editing pulse phase cycling and simulation of both edit-on and edit-off subspectra, the spatially resolved MEGA-PRESS simulations described previously were highly computationally demanding, leading to a long simulation time of up to 30 h for large spin systems. It should be noted, however, that for a standard PRESS experiment the simulation time would be reduced by approximately a factor of 8, because of the removal of the four editing pulse phase encodes and one of the two subspectra.

The fact that the FID-A software toolkit is MATLAB-based has both advantages and disadvantages. On the one hand, MATLAB is not freely available, meaning that users without access to a MATLAB license will not be able to benefit from the FID-A software toolkit. Furthermore, users who are not familiar with the MATLAB environment and programming language may find it difficult to use the FID-A software toolkit. On the other hand, the use of MATLAB among the medical imaging research community is quite prevalent, as implied by the success of many other MATLAB-based software packages in this field, including SPM (http://www.fil.ion.ucl.ac.uk/spm/software/spm8/), PLS [45], MatPulse [21], matNMR [19], and others. For this reason we believe that the MATLAB-based approach will lend itself to easy adoption of FID-A by most members of the MRS research community.

CONCLUSIONS

FID-A is a powerful and flexible software toolkit that enables simulation of in vivo MRS experiments, design and simulation of radiofrequency pulses, and processing of MRS data.

ACKNOWLEDGMENTS

Philip Cowen provided guidance and support during the development of this software. Martyn Klassen provided MATLAB code for importing Agilent MRS data, importing Agilent RF pulse files, and Bloch simulation of RF pulses. Philip Ehses provided MATLAB code for importing Siemens raw MRS data. Richard Edden provided MATLAB code for importing GE and Philips raw MRS data. Kimberly Chan provided some modifications to sim_Hamiltonian.m and sim_shapedRF.m. Saad Jbabdi provided some assistance with the code for sim_readout.m. We thank all the above for their valuable contributions.

Ancillary