Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
William Clarke
fsl_mrs
Commits
f36b6c2f
Commit
f36b6c2f
authored
Aug 03, 2021
by
William Clarke
Browse files
Added a add_water_peak method to mrs.
parent
6aeddf5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.rst
View file @
f36b6c2f
...
...
@@ -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)
------------------------------
...
...
fsl_mrs/core/mrs.py
View file @
f36b6c2f
...
...
@@ -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
...
...
fsl_mrs/tests/test_core_mrs.py
View file @
f36b6c2f
...
...
@@ -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
():
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment