Load the spant package:
library(spant)
Get the path to a data file included with spant:
<- system.file("extdata", "philips_spar_sdat_WS.SDAT", package = "spant") fname
Read the file and save to the workspace as mrs_data
:
<- read_mrs(fname, format = "spar_sdat") mrs_data
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
#> Reference freq. (ppm) : 4.65
#> Nucleus : 1H
#> Spectral domain : FALSE
Plot the spectral region between 5 and 0.5 ppm:
plot(mrs_data, xlim = c(5, 0.5))
Apply a HSVD filter to the residual water region and align the spectrum to the tNAA resonance at 2.01 ppm:
<- hsvd_filt(mrs_data)
mrs_proc <- align(mrs_proc, 2.01)
mrs_proc plot(mrs_proc, xlim = c(5, 0.5))
Simulate a typical basis set for short TE brain analysis, print some basic information and plot:
<- sim_basis_1h_brain_press(mrs_proc)
basis print(basis)
#> Basis set parameters
#> -------------------------------
#> Trans. freq (MHz) : 127.786142
#> 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_mrs(mrs_proc, basis) fit_res
Plot the fit result:
plot(fit_res)
Extract the estimated amplitudes from fit_res
and print
as a ratio to total-creatine in column format:
<- fit_amps(fit_res)
amps print(t(amps / amps$tCr))
#> [,1]
#> X.CrCH2 0.00000000
#> Ala 0.15614859
#> Asp 0.54809284
#> Cr 0.66327699
#> GABA 0.28180941
#> Glc 0.06746709
#> Gln 0.07453033
#> GSH 0.35689235
#> Glu 1.10359880
#> GPC 0.26459032
#> Ins 0.99276965
#> Lac 0.09734849
#> Lip09 0.37880064
#> Lip13a 0.04545721
#> Lip13b 0.00000000
#> Lip20 0.00000000
#> MM09 0.17194558
#> MM12 0.11370654
#> MM14 0.44454014
#> MM17 0.42554639
#> MM20 1.53642857
#> NAA 0.97179650
#> NAAG 0.27434672
#> PCh 0.00000000
#> PCr 0.33672301
#> sIns 0.10883974
#> Tau 0.00000000
#> tNAA 1.24614322
#> tCr 1.00000000
#> tCho 0.26459032
#> Glx 1.17812914
#> tLM09 0.55074622
#> tLM13 0.60370388
#> tLM20 1.53642857
Unscaled amplitudes, CRLB error estimates and other fitting diagnostics, such as SNR, are given in the results table:
$res_tab
fit_res#> X Y Z Dynamic Coil X.CrCH2 Ala Asp Cr GABA
#> 1 1 1 1 1 1 0 9.497426e-06 3.333665e-05 4.03425e-05 1.71405e-05
#> Glc Gln GSH Glu GPC Ins
#> 1 4.103551e-06 4.533159e-06 2.170727e-05 6.71242e-05 1.609318e-05 6.038323e-05
#> Lac Lip09 Lip13a Lip13b Lip20 MM09 MM12
#> 1 5.921028e-06 2.303979e-05 2.764844e-06 0 0 1.045825e-05 6.915974e-06
#> MM14 MM17 MM20 NAA NAAG PCh
#> 1 2.703827e-05 2.588301e-05 9.34502e-05 5.910758e-05 1.668659e-05 0
#> PCr sIns Tau tNAA tCr tCho
#> 1 2.048051e-05 6.61996e-06 0 7.579418e-05 6.082301e-05 1.609318e-05
#> Glx tLM09 tLM13 tLM20 X.CrCH2.sd Ala.sd
#> 1 7.165736e-05 3.349804e-05 3.671909e-05 9.34502e-05 2.353862e-06 4.359105e-06
#> Asp.sd Cr.sd GABA.sd Glc.sd Gln.sd GSH.sd
#> 1 8.967176e-06 3.769571e-06 4.496026e-06 4.330378e-06 4.891686e-06 2.019976e-06
#> Glu.sd GPC.sd Ins.sd Lac.sd Lip09.sd Lip13a.sd
#> 1 4.91104e-06 2.340559e-06 2.023099e-06 5.343971e-06 4.067372e-06 1.338191e-05
#> Lip13b.sd Lip20.sd MM09.sd MM12.sd MM14.sd MM17.sd
#> 1 6.502036e-06 7.383159e-06 3.767183e-06 4.507066e-06 7.122518e-06 3.57925e-06
#> MM20.sd NAA.sd NAAG.sd PCh.sd PCr.sd sIns.sd
#> 1 8.280712e-06 1.021341e-06 1.289272e-06 1.998756e-06 3.162821e-06 7.079373e-07
#> Tau.sd tNAA.sd tCr.sd tCho.sd Glx.sd tLM09.sd
#> 1 3.741982e-06 7.137558e-07 5.844873e-07 2.125819e-07 2.883712e-06 9.731161e-07
#> tLM13.sd tLM20.sd phase lw shift asym
#> 1 1.520083e-06 2.886552e-06 10.83966 5.024143 -0.002971687 0.177138
#> res.deviance res.niter res.info
#> 1 7.455762e-05 27 2
#> res.message bl_ed_pppm
#> 1 Relative error between `par' and the solution is at most `ptol'. 1.969325
#> max_bl_flex_used full_res fit_pts ppm_range SNR SRR FQN
#> 1 FALSE 8.202624e-05 497 3.8 63.23665 51.27883 1.520763
#> tNAA_lw tCr_lw tCho_lw auto_bl_crit_7 auto_bl_crit_5.901
#> 1 0.04585123 0.05167911 0.05460797 -8.872611 -8.918514
#> auto_bl_crit_4.942 auto_bl_crit_4.12 auto_bl_crit_3.425 auto_bl_crit_2.844
#> 1 -8.954323 -8.980263 -8.99748 -9.009404
#> auto_bl_crit_2.364 auto_bl_crit_1.969 auto_bl_crit_1.647 auto_bl_crit_1.384
#> 1 -9.017234 -9.02016 -9.008892 -8.957937
#> auto_bl_crit_1.17 auto_bl_crit_0.997 auto_bl_crit_0.856 auto_bl_crit_0.743
#> 1 -8.841036 -8.684538 -8.555257 -8.478503
#> auto_bl_crit_0.654 auto_bl_crit_0.593 auto_bl_crit_0.558 auto_bl_crit_0.54
#> 1 -8.441093 -8.424849 -8.418126 -8.415349
#> auto_bl_crit_0.532 auto_bl_crit_0.529
#> 1 -8.414188 -8.413698
Spectral SNR:
$res_tab$SNR
fit_res#> [1] 63.23665
Linewidth of the tNAA resonance in PPM:
$res_tab$tNAA_lw
fit_res#> [1] 0.04585123