Commit f36b6c2f authored by William Clarke's avatar William Clarke
Browse files

Added a add_water_peak method to mrs.

parent 6aeddf5b
......@@ -8,6 +8,7 @@ This document contains the FSL-MRS release history in reverse chronological orde
- fsl_mrsi now outputs fitting nuisance parameters: phases, and shifts & linewidths for each metabolite group.
- Add NIfTI-MRS reshape command
- Add basis_tools remove_peak option to run HLSVD, typical usage for removing TMS peak.
- Added an add_water_peak method to MRS class.
1.1.3 (Tuesday 29th June 2021)
------------------------------
......
......@@ -656,6 +656,25 @@ class MRS(object):
return len(ppmlist)
def add_water_peak(self, gamma=0.0, sigma=0.0, ppm=4.65, amp=1.0, name='H2O'):
"""Add a peak at 4.65 ppm to capture (residual) water.
:param gamma: Lorentzian broadening, defaults to 0
:type gamma: float, optional
:param sigma: Gaussian broadening, defaults to 0
:type sigma: float, optional
:param ppm: Peak position, defaults to 4.65
:type ppm: float, optional
:param amp: Peak amplitude, defaults to 1.0
:type amp: float, optional
:param name: Basis name, defaults to 'H2O'
:type name: str, optional
:return: Number of basis spectra added (1).
:rtype: int
"""
self._basis.add_peak(ppm, amp, name, gamma, sigma, conj=self.conj_Basis)
return 1
# Plotting functions
def plot(self, ppmlim=(0.2, 4.2)):
"""Plot the spectrum in the mrs object
......
......@@ -148,22 +148,29 @@ def test_basis_manipulations(synth_data):
assert mrs.numBasis == 6
assert mrs.names == ['ppm_2', 'MM09', 'MM12', 'MM14', 'MM17', 'MM21']
mrs.ignore = ['MM09']
mrs.add_water_peak(gamma=10, sigma=10, name='myh2o')
assert mrs.basis.shape == (2048, 7)
assert mrs.numBasis == 7
assert mrs.names == ['ppm_2', 'MM09', 'MM12', 'MM14', 'MM17', 'MM21', 'myh2o']
assert mrs.basis.shape == (2048, 5)
assert mrs.numBasis == 5
mrs.ignore = ['MM09']
assert mrs.basis.shape == (2048, 6)
assert mrs.numBasis == 6
mrs.ignore = []
# This suprising result is because mrs.keep is still populated.
assert mrs.basis.shape == (2048, 1)
assert mrs.numBasis == 1
mrs.keep = []
assert mrs.basis.shape == (2048, 7)
assert mrs.numBasis == 7
assert mrs.basis.shape == (2048, 8)
assert mrs.numBasis == 8
mrs.keep = None
mrs.ignore = None
assert mrs.basis.shape == (2048, 7)
assert mrs.numBasis == 7
assert mrs.basis.shape == (2048, 8)
assert mrs.numBasis == 8
def test_nucleus_identification():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment