Note this function is still under development and liable to changes.

fit_svs(
  metab,
  w_ref = NULL,
  output_dir = NULL,
  external_basis = NULL,
  p_vols = NULL,
  format = NULL,
  pul_seq = NULL,
  TE = NULL,
  TR = NULL,
  TE1 = NULL,
  TE2 = NULL,
  TE3 = NULL,
  TM = NULL,
  append_basis = NULL,
  remove_basis = NULL,
  pre_align = TRUE,
  dfp_corr = TRUE,
  output_ratio = "tCr",
  ecc = FALSE,
  hsvd_width = NULL,
  fit_opts = NULL,
  fit_subset = NULL,
  legacy_ws = FALSE,
  w_att = 0.7,
  w_conc = 35880,
  use_basis_cache = "auto",
  summary_measures = NULL,
  dyn_av_block_size = NULL,
  dyn_av_scheme = NULL,
  verbose = FALSE
)

Arguments

metab

path or mrs_data object containing MRS metabolite data.

w_ref

path or mrs_data object containing MRS water reference data.

output_dir

directory path to output fitting results.

external_basis

precompiled basis set object to use for analysis.

p_vols

a numeric vector of partial volumes expressed as percentages. Defaults to 100% white matter. A voxel containing 100% gray matter tissue would use : p_vols = c(WM = 0, GM = 100, CSF = 0).

format

Override automatic data format detection. See format argument in read_mrs() for permitted values.

pul_seq

Pulse sequence to use for basis simulation. Can be one of the following values : "press", "press_ideal", "press_shaped", "steam" or "slaser". If "press" then "press_ideal" will be assumed unless the magnetic field is stronger that 2.8 Tesla, "press_shaped" will be assumed for 2.9 Tesla and above.

TE

metabolite mrs data echo time in seconds. If not supplied this will be guessed from the metab data file.

TR

metabolite mrs data repetition time in seconds. If not supplied this will be guessed from the metab data file.

TE1

PRESS or sLASER sequence timing parameter in seconds.

TE2

PRESS or sLASER sequence timing parameter in seconds.

TE3

sLASER sequence timing parameter in seconds.

TM

STEAM mixing time parameter in seconds.

append_basis

names of extra signals to add to the default basis. Eg append_basis = c("peth", "cit"). Cannot be used with precompiled basis sets.

remove_basis

grep expression to match names of signals to remove from the basis. For example: use "*" to remove all signals, "^mm|^lip" to remove all macromolecular and lipid signals, "^lac" to remove lactate. This operation is performed before signals are added with append_basis. Cannot be used with precompiled basis sets.

pre_align

perform simple frequency alignment to known reference peaks.

dfp_corr

perform dynamic frequency and phase correction using the RATS method.

output_ratio

optional string to specify a metabolite ratio to output. Defaults to "tCr" and multiple metabolites may be specified for multiple outputs. Set as NULL to omit.

ecc

option to perform water reference based eddy current correction, defaults to FALSE.

hsvd_width

set the width of the HSVD filter in Hz. Note the applied width is between -width and +width Hz, with 0 Hz being defined at the centre of the spectral width. Default is disabled (set to NULL), 30 Hz is a reasonable value.

fit_opts

options to pass to ABfit.

fit_subset

specify a subset of dynamics to analyse, for example 1:16 would only fit the first 16 dynamic scans.

legacy_ws

perform and output legacy water scaling compatible with default LCModel and TARQUIN behaviour. See w_att and w_conc arguments to change the default assumptions. Default value is FALSE.

w_att

water attenuation factor (default = 0.7) for legacy water scaling. Assumes water T2 of 80ms and a TE = 30 ms. exp(-30ms / 80ms) ~ 0.7.

w_conc

assumed water concentration (default = 35880) for legacy water scaling. Default value corresponds to typical white matter. Set to 43300 for gray matter, and 55556 for phantom measurements.

use_basis_cache

Pre-cache basis sets to reduce analysis speed. Can be one of the following : "auto", "all" or "none". The default value of "auto" will only use the cache for 3T PRESS - which generally requires more detailed simulation due to high CSD.

summary_measures

output an additional table with a subset of metabolite levels, eg c("tNAA", "tNAA/tCr", "tNAA/tCho", "Lac/tNAA").

dyn_av_block_size

perform temporal averaging with the specified block size. Defaults to NULL, eg average across all dynamic scans.

dyn_av_scheme

a numerical vector of sequential integers starting at 1, with the same length as the number of dynamic scans in the metabolite data. For example: c(1, 1, 2, 1, 1, 3, 1, 1).

verbose

output potentially useful information.

Examples

metab <- system.file("extdata", "philips_spar_sdat_WS.SDAT",
                     package = "spant")
w_ref <- system.file("extdata", "philips_spar_sdat_W.SDAT",
                     package = "spant")
if (FALSE) { # \dontrun{
fit_result <- svs_1h_brain_analysis(metab, w_ref, "fit_res_dir")
} # }