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.15388554
#> Asp 0.54901257
#> Cr 0.66227503
#> GABA 0.27768802
#> Glc 0.06608543
#> Gln 0.07780282
#> GSH 0.35696179
#> Glu 1.10909506
#> GPC 0.26539808
#> Ins 0.99223489
#> Lac 0.09773796
#> Lip09 0.38611255
#> Lip13a 0.04661353
#> Lip13b 0.00000000
#> Lip20 0.00000000
#> MM09 0.16559678
#> MM12 0.11274447
#> MM14 0.44654596
#> MM17 0.42514419
#> MM20 1.55949356
#> NAA 0.98019156
#> NAAG 0.26060757
#> PCh 0.00000000
#> PCr 0.33772497
#> sIns 0.10907916
#> Tau 0.00000000
#> tNAA 1.24079913
#> tCr 1.00000000
#> tCho 0.26539808
#> Glx 1.18689788
#> tLM09 0.55170934
#> tLM13 0.60590396
#> tLM20 1.55949356
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
#> 1 1 1 1 1 1 0 9.343299e-06 3.333379e-05 4.021062e-05
#> GABA Glc Gln GSH Glu GPC
#> 1 1.686008e-05 4.012436e-06 4.723868e-06 2.167326e-05 6.73397e-05 1.611388e-05
#> Ins Lac Lip09 Lip13a Lip13b Lip20 MM09
#> 1 6.024443e-05 5.934248e-06 2.344317e-05 2.830183e-06 0 0 1.005436e-05
#> MM12 MM14 MM17 MM20 NAA NAAG
#> 1 6.845382e-06 2.711244e-05 2.581301e-05 9.468605e-05 5.951321e-05 1.582302e-05
#> PCh PCr sIns Tau tNAA tCr tCho
#> 1 0 2.050527e-05 6.622839e-06 0 7.533623e-05 6.07159e-05 1.611388e-05
#> Glx tLM09 tLM13 tLM20 X.CrCH2.sd Ala.sd
#> 1 7.206357e-05 3.349753e-05 3.6788e-05 9.468605e-05 2.365865e-06 4.358582e-06
#> Asp.sd Cr.sd GABA.sd Glc.sd Gln.sd GSH.sd
#> 1 8.965963e-06 3.745167e-06 4.443291e-06 4.324169e-06 4.89224e-06 2.01775e-06
#> Glu.sd GPC.sd Ins.sd Lac.sd Lip09.sd Lip13a.sd
#> 1 4.904508e-06 2.485735e-06 2.021386e-06 5.353013e-06 4.069682e-06 1.340823e-05
#> Lip13b.sd Lip20.sd MM09.sd MM12.sd MM14.sd MM17.sd
#> 1 6.514836e-06 7.381742e-06 3.769422e-06 4.490832e-06 7.118537e-06 3.582288e-06
#> MM20.sd NAA.sd NAAG.sd PCh.sd PCr.sd sIns.sd
#> 1 8.255787e-06 1.018031e-06 1.239149e-06 2.126367e-06 3.164552e-06 7.094298e-07
#> Tau.sd tNAA.sd tCr.sd tCho.sd Glx.sd tLM09.sd
#> 1 3.714842e-06 7.075155e-07 5.852307e-07 2.122005e-07 2.894735e-06 9.740532e-07
#> tLM13.sd tLM20.sd phase lw shift asym
#> 1 1.527125e-06 2.881585e-06 10.6878 5.024704 -0.003553099 0.1745246
#> res.deviance res.niter res.info
#> 1 7.46864e-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.21836e-05 497 3.8 63.11156 51.11142 1.524691
#> tNAA_lw tCr_lw tCho_lw auto_bl_crit_7 auto_bl_crit_5.901
#> 1 0.04573567 0.05174083 0.05459455 -8.897184 -8.940906
#> auto_bl_crit_4.942 auto_bl_crit_4.12 auto_bl_crit_3.425 auto_bl_crit_2.844
#> 1 -8.9744 -8.997882 -9.012252 -9.020869
#> auto_bl_crit_2.364 auto_bl_crit_1.969 auto_bl_crit_1.647 auto_bl_crit_1.384
#> 1 -9.025829 -9.026291 -9.013371 -8.962017
#> auto_bl_crit_1.17 auto_bl_crit_0.997 auto_bl_crit_0.856 auto_bl_crit_0.743
#> 1 -8.846434 -8.691289 -8.562198 -8.484761
#> auto_bl_crit_0.654 auto_bl_crit_0.593 auto_bl_crit_0.558 auto_bl_crit_0.54
#> 1 -8.446482 -8.429622 -8.422568 -8.419634
#> auto_bl_crit_0.532 auto_bl_crit_0.529
#> 1 -8.418403 -8.417882
Spectral SNR:
$res_tab$SNR
fit_res#> [1] 63.11156
Linewidth of the tNAA resonance in PPM:
$res_tab$tNAA_lw
fit_res#> [1] 0.04573567