Learn R Programming

⚠️There's a newer version (3.9.0) of this package.Take me there.

spant (version 1.5.0)

MR Spectroscopy Analysis Tools

Description

Tools for reading, visualising and processing Magnetic Resonance Spectroscopy data. .

Copy Link

Version

Install

install.packages('spant')

Monthly Downloads

692

Version

1.5.0

License

GPL-3

Maintainer

Martin Wilson

Last Published

May 11th, 2020

Functions in spant (1.5.0)

append_coils

Append MRS data across the coil dimension, assumes they matched across the other dimensions.
Ny

Return the total number of y locations in an MRS dataset.
def_N

Return the default number of data points in the spectral dimension.
apply_pvc

Convert default LCM/TARQUIN concentration scaling to molal units with partial volume correction.
calc_spec_diff

Calculate the sum of squares differences between two mrs_data objects.
apply_mrs

Apply a function across given dimensions of a MRS data object.
append_basis

Combine a pair of basis set objects.
decimate_mrs

Downsample an MRS signal by a factor.
def_ft

Return the default transmitter frequency in Hz.
calc_spec_snr

Calculate the spectral SNR.
align

Align spectra to a reference frequency using a convolution based method.
apodise_xy

Apodise MRSI data in the x-y direction with a k-space hamming filter.
Re.mrs_data

Apply Re operator to an MRS dataset.
auto_phase

Perform zeroth-order phase correction based on the minimisation of the squared difference between the real and magnitude components of the spectrum.
back_extrap

Back extrapolate time-domain points using the Burg autoregressive model
calc_coil_noise_sd

Calculate the noise standard deviation for each coil element.
Nz

Return the total number of z locations in an MRS dataset.
basis2mrs_data

Convert a basis object to an mrs_data object - where basis signals are spread across the dynamic dimension.
bbase

Generate a spline basis, slightly adapted from : "Splines, knots, and penalties", Eilers 2010.
calc_ed_from_lambda

Calculate the effective dimensions of a spline smoother from lambda.
def_ref

Return the default reference value for ppm scale.
abfit_opts

Return a list of options for an ABfit analysis.
acquire

Simulate pulse sequence acquisition.
collapse_to_dyns

Collapse MRS data by concatenating spectra along the dynamic dimension.
gen_F

Generate the F product operator.
gen_F_xy

Generate the Fxy product operator with a specified phase.
calc_coil_noise_cor

Calculate the noise correlation between coil elements.
calc_peak_info_vec

Calculate the FWHM of a peak from a vector of intensity values.
calc_sd_poly

Perform a polynomial fit, subtract and return the standard deviation of the residuals.
beta2lw

Covert a beta value in the time-domain to an equivalent linewidth in Hz: x * exp(-i * t * t * beta).
comb_coils

Combine coil data based on the first data point of a reference signal.
comb_metab_ref

Combine a reference and metabolite mrs_data object.
append_dyns

Append MRS data across the dynamic dimension, assumes they matched across the other dimensions.
comb_fits

Combine a list of fit_result objects into a single fit object containing a dynamic series.
conv_mrs

Convolve two MRS data objects.
fp_phase

Return the phase of the first data point in the time-domain.
fit_amps

Extract the fit amplitudes from an object of class fit_result.
fit_res2csv

Write fit results table to a csv file.
get_even_dyns

Return even numbered dynamic scans starting from 1 (2,4,6...).
fd_conv_filt

Frequency-domain convolution based filter.
get_fit_map

Get a data array from a fit result.
crop_spec

Crop mrs_data object based on a frequency range.
apply_axes

Apply a function over specified array axes.
get_uncoupled_mol

Generate a mol_parameters object for a simple spin system with one resonance.
ift_shift_mat

Perform an ifft and ifftshift on a matrix with each column replaced by its shifted ifft.
get_td_amp

Return an array of amplitudes derived from fitting the initial points in the time domain and extrapolating back to t=0.
get_fit_table

Combine all fitting data points into a single dataframe.
get_mrsi_voxel_xy_psf

Generate a MRSI voxel PSF from an mrs_data object.
get_fp

Return the first time-domain data point.
get_fh_dyns

Return the first half of a dynamic series.
get_odd_dyns

Return odd numbered dynamic scans starting from 1 (1,3,5...).
est_noise_sd

Estimate the standard deviation of the noise from a segment of an mrs_data object.
get_guassian_pulse

Generate a gaussian pulse shape.
bc_als

Baseline correction using the ALS method.
get_svs_voi

Generate a SVS acquisition volume from an mrs_data object.
get_subset

Extract a subset of MRS data.
check_tqn

Check the TARQUIN binary can be run
comb_csv_results

Combine the results from multiple csv format files into a table.
bc_constant

Remove a constant baseline offset based on a reference spectral region.
comb_coils_fp_pc

Combine coil data following phase correction based on the first data point in the FID.
get_voi_seg_psf

Return the white matter, gray matter and CSF composition of a volume.
check_lcm

Check LCModel can be run
fd2td

Transform frequency-domain data to the time-domain.
crop_xy

Crop an MRSI dataset in the x-y direction
get_voxel

Return a single voxel from a larger mrs dataset.
crop_td_pts

Crop mrs_data object data points in the time-domain.
mask_xy_mat

Mask a 2D MRSI dataset in the x-y dimension.
def_fs

Return the default sampling frequency in Hz.
def_acq_paras

Return (and optionally modify using the input arguments) a list of the default acquisition parameters.
image.mrs_data

Image plot method for objects of class mrs_data.
mat2mrs_data

Convert a matrix (with spectral points in the row dimension and dynamics in the column dimensions) into a mrs_data object.
is_fd

Check if the chemical shift dimension of an MRS data object is in the frequency domain.
l2_reg

Perform l2 regularisation artefact suppression using the method proposed by Bilgic et al. JMRI 40(1):181-91 2014.
max_mrs

Apply the max operator to an MRS dataset.
fp_phase_correct

Perform a zeroth order phase correction based on the phase of the first data point in the time-domain.
get_acq_paras

Return acquisition parameters from a MRS data object.
fs

Return the sampling frequency in Hz of an MRS dataset.
plot.fit_result

Plot the fitting results of an object of class fit_result.
max_mrs_interp

Apply the max operator to an interpolated MRS dataset.
print.mrs_data

Print a summary of mrs_data parameters.
peak_info

Search for the highest peak in a spectral region and return the frequency, height and FWHM.
ortho3_int

Display an interactive orthographic projection plot of a nifti object.
phase

Apply phasing parameters to MRS data.
diff_mrs

Apply the diff operator to an MRS dataset in the FID/spectral dimension.
qn_states

Get the quantum coherence matrix for a spin system.
fit_mrs

Perform a fit based analysis of MRS data.
get_2d_psf

Get the point spread function (PSF) for a 2D phase encoded MRSI scan.
get_mrsi_voi

Generate a MRSI VOI from an mrs_data object.
get_1h_brain_basis_paras_v2

Return a list of mol_parameter objects suitable for 1H brain MRS analyses.
get_mrsi_voxel

Generate a MRSI voxel from an mrs_data object.
fit_diags

Calculate diagnostic information for object of class fit_result.
get_voi_cog

Calculate the centre of gravity for an image containing 0 and 1's.
get_voi_seg

Return the white matter, gray matter and CSF composition of a volume.
ecc

Eddy current correction.
int_spec

Integrate a spectral region.
ft_shift

Perform a fft and ffshift on a vector.
lw2beta

Covert a linewidth in Hz to an equivalent beta value in the time-domain ie: x * exp(-t * t * beta).
mean_dyn_blocks

Calculate the mean of adjacent dynamic scans.
mrsi2d_img2kspace

Transform 2D MRSI data to k-space in the x-y direction.
mean_dyns

Calculate the mean dynamic data.
mean_dyn_pairs

Calculate the pairwise means across a dynamic data set.
interleave_dyns

Interleave the first and second half of a dynamic series.
mean.mrs_data

Calculate the mean spectrum from an mrs_data object.
mask_xy

Mask an MRSI dataset in the x-y direction
mrsi2d_kspace2img

Transform 2D MRSI data from k-space to image space in the x-y direction.
mvfftshift

Perform a fftshift on a matrix, with each column replaced by its shifted result.
mvifftshift

Perform an ifftshift on a matrix, with each column replaced by its shifted result.
read_ima_dyn_dir

Read a directory containing Siemens MRS IMA files and combine along the dynamic dimension. Note that the coil ID is inferred from the sorted file name and should be checked when consistency is required.
plot_voi_overlay

Plot a volume as an image overlay.
ft_shift_mat

Perform a fft and fftshift on a matrix with each column replaced by its shifted fft.
get_metab

Extract the metabolite component from an mrs_data object.
plot_voi_overlay_seg

Plot a volume as an overlay on a segmented brain volume.
get_dyns

Extract a subset of dynamic scans.
get_seg_ind

Get the indices of data points lying between two values (end > x > start).
get_ref

Extract the reference component from an mrs_data object.
get_mol_names

Return a character array of names that may be used with the get_mol_paras function.
get_1h_brain_basis_paras

Return a list of mol_parameter objects suitable for 1H brain MRS analyses.
plot_slice_fit

Plot a 2D slice from an MRSI fit result object.
read_lcm_coord

Read an LCModel formatted coord file containing fit information.
grid_shift_xy

Grid shift MRSI data in the x/y dimension.
seq_mega_press_ideal

MEGA-PRESS sequence with ideal localisation pulses and Gaussian shaped editing pulse.
scale_amp_molar

Apply water reference scaling to a fitting results object to yield metabolite quantities in millimolar (mM) units (mol/litre).
read_mrs_dpt

Read MRS data stored in dangerplot (dpt) v3 format.
set_lw

Apply line-broadening to an mrs_data object to achieve a specified linewidth.
sim_mol

Simulate a mol_parameter object.
seq_press_ideal

PRESS sequence with ideal pulses.
scale_amp_molal_pvc

Apply partial volume correction to a fitting result object.
set_ref

Set the ppm reference value (eg ppm value at 0Hz).
read_mrs

Read MRS data from a file.
get_1h_brain_basis_paras_v1

Return a list of mol_parameter objects suitable for 1H brain MRS analyses.
get_mol_paras

Get a mol_parameters object for a named molecule.
get_mrsi2d_seg

Calculate the partial volume estimates for each voxel in a 2D MRSI dataset.
hsvd_filt

HSVD based signal filter.
lb

Apply line-broadening (apodisation) to MRS data or basis object.
sd

Standard Deviation
read_tqn_fit

Reader for csv fit results generated by TARQUIN.
seq_pulse_acquire

Simple pulse and acquire sequence with ideal pulses.
sd.mrs_data

Calculate the standard deviation spectrum from an mrs_data object.
seq_pulse_acquire_31p

Simple pulse and acquire sequence with ideal pulses.
read_tqn_result

Reader for csv results generated by TARQUIN.
get_sh_dyns

Return the second half of a dynamic series.
sim_basis_1h_brain

Simulate a basis-set suitable for 1H brain MRS analysis acquired with a PRESS sequence. Note, ideal pulses are assumed.
get_slice

Return a single slice from a larger MRSI dataset.
sim_basis_1h_brain_press

Simulate a basis-set suitable for 1H brain MRS analysis acquired with a PRESS sequence. Note, ideal pulses are assumed.
hz

Return the frequency scale of an MRS dataset in Hz.
n2coord

Print fit coordinates from a single index.
mrs_data2basis

Convert an mrs_data object to basis object - where basis signals are spread across the dynamic dimension in the MRS data.
median_dyns

Calculate the median dynamic data.
nifti_flip_lr

Flip the x data dimension order of a nifti image. This corresponds to flipping MRI data in the left-right direction, assuming the data in save in neurological format (can check with fslorient program).
inv_even_dyns

Invert even numbered dynamic scans starting from 1 (2,4,6...).
ift_shift

Perform an iffshift and ifft on a vector.
lw2alpha

Covert a linewidth in Hz to an equivalent alpha value in the time-domain ie: x * exp(-t * alpha).
plot_slice_fit_inter

Plot a 2D slice from an MRSI fit result object.
inv_odd_dyns

Invert odd numbered dynamic scans starting from 1 (1,3,5...).
plot.mrs_data

Plotting method for objects of class mrs_data.
rats

Robust Alignment to a Target Spectrum (RATS).
sim_noise

Simulate a time-domain mrs_data object containing simulated Gaussian noise.
write_mrs_lcm_raw

Write MRS data object to file in a RAW format compatible with LCModel.
mrs_data2vec

Convert mrs_data object to a vector.
stackplot.fit_result

Plot the fitting results of an object of class fit_result with individual basis set components shown.
mrs_data2mat

Convert mrs_data object to a matrix, with spectral points in the column dimension and dynamics in the row dimension.
write_mrs_dpt_v2

Write MRS data object to file in dangerplot (dpt) v2 format.
stackplot.mrs_data

Stackplot plotting method for objects of class mrs_data.
plot_bc

Convenience function to plot a baseline estimate with the original data.
ppm

Return the ppm scale of an MRS dataset or fit result.
re_weighting

Apply a weighting to the FID to enhance spectral resolution.
plot_slice_map_inter

Plot an interactive slice map from a data array where voxels can be selected to display a corresponding spectrum.
read_basis

Read a basis file in LCModel .basis format.
ortho3

Display an orthographic projection plot of a nifti object.
read_ima_coil_dir

Read a directory containing Siemens MRS IMA files and combine along the coil dimension. Note that the coil ID is inferred from the sorted file name and should be checked when consistency is required between two directories.
plot_slice_map

Plot a slice from a 7 dimensional array.
norm_mrs

Normalise mrs_data to a spectral region.
reexports

Objects exported from other packages
read_siemens_txt_hdr

Read the text format header found in Siemens IMA and TWIW data files.
read_mrs_tqn

Read MRS data using the TARQUIN software package.
print.fit_result

Print a summary of an object of class fit_result.
reslice_to_mrs

Reslice a nifti object to match the orientation of mrs data.
rep_array_dim

Repeat an array over a given dimension.
rm_dyns

Remove a subset of dynamic scans.
sim_resonances

Simulate a MRS data object containing a set of simulated resonances.
seq_spin_echo_ideal_31p

Spin echo sequence with ideal pulses.
spant-package

spant: spectroscopy analysis tools.
rep_dyn

Replicate a scan in the dynamic dimension.
rep_mrs

Replicate a scan over a given dimension.
varpro_opts

Return a list of options for VARPRO based fitting.
seq_steam_ideal

STEAM sequence with ideal pulses.
vec2mrs_data

Convert a vector into a mrs_data object.
set_td_pts

Set the number of time-domain data points, truncating or zero-filling as appropriate.
seconds

Return a time scale vector to match the FID of an MRS data object.
resample_img

Resample an image to match a target image space.
set_def_acq_paras

Set the default acquisition parameters.
resample_voi

Resample a VOI to match a target image space using nearest-neighbour interpolation.
seq_cpmg_ideal

CPMG style sequence with ideal pulses.
set_tqn_cmd

Set the command to run the TARQUIN command-line program.
set_lcm_cmd

Set the command to run the LCModel command-line program.
spant_mpress_drift

Example MEGA-PRESS data with significant B0 drift.
spin_sys

Create a spin system object for pulse sequence simulation.
spm_pve2categorical

Convert SPM style segmentation files to a single categorical image where the numerical values map as: 0) Other, 1) CSF, 2) GM and 3) WM.
sum_coils

Calculate the sum across receiver coil elements.
scale_amp_ratio

Scale fitted amplitudes to a ratio of signal amplitude.
stackplot

Produce a plot with multiple traces.
varpro_3_para_opts

Return a list of options for VARPRO based fitting with 3 free parameters:
  • zero'th order phase correction

  • global damping

  • global frequency shift.

tdsr

Time-domain spectral registration.
sum_dyns

Calculate the sum of data dynamics.
write_basis_tqn

Generate a basis file using TARQUIN.
write_basis

Write a basis object to an LCModel .basis formatted file.
zf

Zero-fill MRS data in the time domain.
sim_basis

Simulate a basis set object.
seq_slaser_ideal

sLASER sequence with ideal pulses.
scale_amp_water_ratio

Scale metabolite amplitudes as a ratio to the unsuppressed water amplitude.
seq_spin_echo_ideal

Spin echo sequence with ideal pulses.
shift

Apply a frequency shift to MRS data.
sim_basis_tqn

Simulate a basis file using TARQUIN.
sim_brain_1h

Simulate MRS data with a similar appearance to normal brain (by default).
td2fd

Transform time-domain data to the frequency-domain.
td_conv_filt

Time-domain convolution based filter.
write_mrs_rda

Write MRS data object to file in rds format.
zero_nzoc

Zero all non-zero-order coherences.
zf_xy

Zero-fill MRSI data in the k-space x-y direction.
Arg.mrs_data

Apply Arg operator to an MRS dataset.
Conj.mrs_data

Apply Conj operator to an MRS dataset.
Ncoils

Return the total number of coil elements in an MRS dataset.
Ndyns

Return the total number of dynamic scans in an MRS dataset.
Im.mrs_data

Apply Im operator to an MRS dataset.
Mod.mrs_data

Apply Mod operator to an MRS dataset.
Nspec

Return the total number of spectra in an MRS dataset.
Npts

Return the number of data points in an MRS dataset.
Nx

Return the total number of x locations in an MRS dataset.