Load the spant package:
Get the path to a data file included with spant:
fname <- system.file("extdata", "philips_spar_sdat_WS.SDAT", package = "spant")
Read the file and save to the workspace as mrs_data
:
mrs_data <- read_mrs(fname)
Output some basic information about the data:
print(mrs_data)
#> MRS Data Parameters
#> ----------------------------------
#> Trans. freq (MHz) : 127.7861
#> FID data points : 1024
#> X,Y,Z dimensions : 1x1x1
#> Dynamics : 1
#> Coils : 1
#> Voxel resolution (mm) : 20x20x20
#> Sampling frequency (Hz) : 2000
#> Repetition time (s) : 2
#> Reference freq. (ppm) : 4.65
#> Nucleus : 1H
#> Spectral domain : FALSE
#> Number of transients : 128
#> Echo time (s) : 0.03
#> Manufacturer : Philips
Plot the spectral region between 5 and 0.5 ppm:
Apply a HSVD filter to the residual water region and align the spectrum to the tNAA resonance at 2.01 ppm:
Simulate a typical basis set for short TE brain analysis, print some basic information and plot:
basis <- sim_basis_1h_brain_press(mrs_proc)
print(basis)
#> Basis set parameters
#> -------------------------------
#> Trans. freq (MHz) : 127.8
#> Data points : 1024
#> Sampling frequency (Hz) : 2000
#> Elements : 27
#>
#> Names
#> -------------------------------
#> -CrCH2,Ala,Asp,Cr,GABA,Glc,Gln,
#> GSH,Glu,GPC,Ins,Lac,Lip09,
#> Lip13a,Lip13b,Lip20,MM09,MM12,
#> MM14,MM17,MM20,NAA,NAAG,PCh,
#> PCr,sIns,Tau
stackplot(basis, xlim = c(4, 0.5), labels = basis$names, y_offset = 5)
Perform ABfit analysis of the processed data
(mrs_proc
):
fit_res <- fit_mrs(mrs_proc, basis)
Plot the fit result:
plot(fit_res)
Unscaled amplitudes, CRLB error estimates and other useful fitting
diagnostics, such as SNR, are given in the fit_res
results
table:
fit_res$res_tab
#> X Y Z Dynamic Coil X.CrCH2 Ala Asp Cr
#> 1 1 1 1 1 1 0 8.133802e-06 3.547064e-05 4.026719e-05
#> GABA Glc Gln GSH Glu GPC
#> 1 1.697276e-05 2.446591e-06 3.036118e-06 2.228048e-05 6.503219e-05 1.606706e-05
#> Ins Lac Lip09 Lip13a Lip13b Lip20 MM09
#> 1 5.906155e-05 5.802244e-06 2.387705e-05 2.670583e-06 0 0 9.630767e-06
#> MM12 MM14 MM17 MM20 NAA NAAG
#> 1 6.511376e-06 2.603852e-05 2.238403e-05 9.203742e-05 6.011109e-05 1.53653e-05
#> PCh PCr sIns Tau tNAA tCr tCho
#> 1 0 2.101921e-05 6.504096e-06 0 7.547639e-05 6.12864e-05 1.606706e-05
#> Glx tLM09 tLM13 tLM20 X.CrCH2.sd Ala.sd
#> 1 6.80683e-05 3.350782e-05 3.522048e-05 9.203742e-05 2.386862e-06 4.343934e-06
#> Asp.sd Cr.sd GABA.sd Glc.sd Gln.sd GSH.sd
#> 1 9.235327e-06 3.689004e-06 4.574399e-06 4.421682e-06 5.083001e-06 2.020427e-06
#> Glu.sd GPC.sd Ins.sd Lac.sd Lip09.sd Lip13a.sd
#> 1 5.082976e-06 2.602652e-06 2.093225e-06 5.301706e-06 4.119256e-06 1.328304e-05
#> Lip13b.sd Lip20.sd MM09.sd MM12.sd MM14.sd MM17.sd
#> 1 6.474468e-06 7.510908e-06 3.827554e-06 4.594028e-06 7.223426e-06 3.811301e-06
#> MM20.sd NAA.sd NAAG.sd PCh.sd PCr.sd sIns.sd
#> 1 8.595853e-06 1.017711e-06 1.208984e-06 2.236874e-06 3.084599e-06 7.240069e-07
#> Tau.sd tNAA.sd tCr.sd tCho.sd Glx.sd tLM09.sd
#> 1 3.759957e-06 7.031382e-07 5.890482e-07 2.110662e-07 3.16966e-06 1.006794e-06
#> tLM13.sd tLM20.sd phase lw shift asym
#> 1 1.573147e-06 3.016809e-06 11.10963 5.023682 -0.00376505 0.1771067
#> res.deviance res.niter res.info
#> 1 7.307671e-05 28 2
#> res.message bl_ed_pppm
#> 1 Relative error between `par' and the solution is at most `ptol'. 2.364083
#> max_bl_flex_used full_res spec_resid fit_pts ppm_range SNR SRR
#> 1 FALSE 7.75437e-05 7.307671e-05 497 3.8 62.71686 51.33279
#> FQN tNAA_lw tCr_lw tCho_lw auto_bl_crit_7 auto_bl_crit_5.901
#> 1 1.492722 0.04562445 0.05189506 0.05438237 -8.900349 -8.944159
#> auto_bl_crit_4.942 auto_bl_crit_4.12 auto_bl_crit_3.425 auto_bl_crit_2.844
#> 1 -8.977355 -9.000064 -9.013367 -9.02055
#> auto_bl_crit_2.364 auto_bl_crit_1.969 auto_bl_crit_1.647 auto_bl_crit_1.384
#> 1 -9.024177 -9.023462 -9.009854 -8.958654
#> auto_bl_crit_1.17 auto_bl_crit_0.997 auto_bl_crit_0.856 auto_bl_crit_0.743
#> 1 -8.844271 -8.690744 -8.56263 -8.485471
#> auto_bl_crit_0.654 auto_bl_crit_0.593 auto_bl_crit_0.558 auto_bl_crit_0.54
#> 1 -8.447135 -8.430173 -8.423052 -8.420085
#> auto_bl_crit_0.532 auto_bl_crit_0.529
#> 1 -8.418839 -8.418312
Note that signal names appended with “.sd” are the CRLB estimates for the uncertainty (standard deviation) in the metabolite quantity estimate. e.g. to calculate the percentage s.d. for tNAA:
fit_res$res_tab$tNAA.sd / fit_res$res_tab$tNAA * 100
#> [1] 0.9316002
Spectral SNR:
fit_res$res_tab$SNR
#> [1] 62.71686
Linewidth of the tNAA resonance in PPM:
fit_res$res_tab$tNAA_lw
#> [1] 0.04562445
Amplitude estimates measured by the fitting method are essentially arbitrary unless scaled to a known reference signal. The simplest approach for proton-MRS is to simply divide all metabolite values by total-creatine:
fit_res_tcr_sc <- scale_amp_ratio(fit_res, "tCr")
amps <- fit_amps(fit_res_tcr_sc)
print(t(amps))
#> [,1]
#> X.CrCH2 0.00000000
#> Ala 0.13271789
#> Asp 0.57876852
#> Cr 0.65703306
#> GABA 0.27694176
#> Glc 0.03992062
#> Gln 0.04953982
#> GSH 0.36354693
#> Glu 1.06111932
#> GPC 0.26216353
#> Ins 0.96369742
#> Lac 0.09467424
#> Lip09 0.38959787
#> Lip13a 0.04357545
#> Lip13b 0.00000000
#> Lip20 0.00000000
#> MM09 0.15714362
#> MM12 0.10624504
#> MM14 0.42486612
#> MM17 0.36523650
#> MM20 1.50175914
#> NAA 0.98082262
#> NAAG 0.25071302
#> PCh 0.00000000
#> PCr 0.34296694
#> sIns 0.10612625
#> Tau 0.00000000
#> tNAA 1.23153565
#> tCr 1.00000000
#> tCho 0.26216353
#> Glx 1.11065914
#> tLM09 0.54674149
#> tLM13 0.57468661
#> tLM20 1.50175914
A more sophisticated approach to scaling metabolite values involves the use of a separate water-reference acquisition - which can be imported in the standard way:
fname_wref <- system.file("extdata", "philips_spar_sdat_W.SDAT", package = "spant")
mrs_data_wref <- read_mrs(fname_wref)
The following code assumes the voxel contains 100% white matter tissue and scales the metabolite values into molal (mM) units (mol / kg tissue water) based on the method described by Gasparovic et al MRM 2006 55(6):1219-26:
p_vols <- c(WM = 100, GM = 0, CSF = 0)
TE = 0.03
TR = 2
fit_res_molal <- scale_amp_molal_pvc(fit_res, mrs_data_wref, p_vols, TE, TR)
fit_res_molal$res_tab$tNAA
#> [1] 12.59789
An alternative method scales the metabolite values into molar (mM) units (mol / Litre of tissue) based on assumptions outlined in the LCModel manual and references therein (section 10.2). This approach may be preferred when comparing results to those obtained LCModel or TARQUIN.
fit_res_molar <- scale_amp_molar(fit_res, mrs_data_wref)
fit_res_molar$res_tab$tNAA
#> [1] 6.826335
Note, while “absolute” units are attractive, a large number of assumptions about metabolite and water relaxation rates are necessary to arrive at these mM estimates. If you’re not confident at being able to justify these assumptions, scaling to a metabolite reference (eg tCr as above) is going to be a better option in most cases. Simple metabolite referenced ratios also have the benefit of being more reproducible due to the simplicity of the approach.