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
9ed8e49e
Commit
9ed8e49e
authored
Jun 23, 2021
by
William Clarke
Browse files
First pass at mega default mm.
parent
9c756f11
Changes
4
Hide whitespace changes
Inline
Side-by-side
fsl_mrs/core/basis.py
View file @
9ed8e49e
...
...
@@ -384,7 +384,7 @@ class Basis:
self
.
_names
.
pop
(
index
)
self
.
_widths
.
pop
(
index
)
def
add_peak
(
self
,
ppm
,
amp
,
name
,
gamma
=
0.0
,
sigma
=
0.0
):
def
add_peak
(
self
,
ppm
,
amp
,
name
,
gamma
=
0.0
,
sigma
=
0.0
,
conj
=
False
):
"""Add Voigt peak to basis at specified ppm
:param ppm: The ppm position of the peak
...
...
@@ -397,12 +397,17 @@ class Basis:
:type gamma: float, optional
:param sigma: Guassian line broadening, defaults to 0
:type sigma: float, optional
:param conj: Conjugate fid, defaults to False
:type conj: Bool, optional
"""
# Calculate the time axis
time_axis
=
self
.
original_time_axis
time_axis
-=
time_axis
[
0
]
fid
=
misc
.
create_peak
(
time_axis
,
self
.
cf
,
ppm
,
amp
,
gamma
,
sigma
)[:,
None
]
width
=
None
# TO DO
if
conj
:
fid
=
fid
.
conj
()
self
.
add_fid_to_basis
(
fid
,
name
,
width
=
width
)
def
update_fid
(
self
,
new_fid
,
name
):
...
...
fsl_mrs/core/mrs.py
View file @
9ed8e49e
...
...
@@ -591,18 +591,49 @@ class MRS(object):
return
0
def
add_MM_peaks
(
self
,
ppmlist
=
None
,
amplist
=
None
,
gamma
=
0
,
sigma
=
0
):
"""Add default MM spectra to basis set
By default will use the defined shifts and amplitudes
def
add_default_MM_peaks
(
self
,
gamma
=
0
,
sigma
=
0
):
"""Add the default MM peaks to the basis set
These use the defined shifts and amplitudes
ppmlist : [0.9,1.2,1.4,1.7,[2.08,2.25,1.95,3.0]]
amplist : [3.0,2.0,2.0,2.0,[1.33,0.33,0.33,0.4]]
but these can be overridden using the kwargs
:param ppmlist: List of shifts, nested lists group into single basis, defaults to None
:type ppmlist: List of floats, optional
:param amplist: List of amplitudes, nested lists group into single basis, defaults to None
:type amplist: List of floats, optional
:param gamma: Lorentzian broadening, defaults to 0
:type gamma: int, optional
:param sigma: Gaussian broadening, defaults to 0
:type sigma: int, optional
"""
from
fsl_mrs.utils.constants
import
DEFAULT_MM_AMP
,
DEFAULT_MM_PPM
return
self
.
add_MM_peaks
(
DEFAULT_MM_PPM
,
DEFAULT_MM_AMP
,
gamma
=
gamma
,
sigma
=
sigma
)
def
add_default_MEGA_MM_peaks
(
self
,
gamma
=
0
,
sigma
=
0
):
"""Add the default MEGA-PRESS MM peaks to the basis set
These use the defined shifts and amplitudes
ppmlist : [[0.94, 3.0]]
amplist : [[3.0, 2.0]]
:param gamma: Lorentzian broadening, defaults to 0
:type gamma: int, optional
:param sigma: Gaussian broadening, defaults to 0
:type sigma: int, optional
"""
from
fsl_mrs.utils.constants
import
DEFAULT_MM_MEGA_AMP
,
DEFAULT_MM_MEGA_PPM
return
self
.
add_MM_peaks
(
DEFAULT_MM_MEGA_PPM
,
DEFAULT_MM_MEGA_AMP
,
gamma
=
gamma
,
sigma
=
sigma
)
def
add_MM_peaks
(
self
,
ppmlist
,
amplist
,
gamma
=
0
,
sigma
=
0
):
"""Add extra Gaussian peaks (normal MM spectra) to basis set
:param ppmlist: List of shifts, nested lists group into single basis.
:type ppmlist: List of floats
:param amplist: List of amplitudes, nested lists group into single basis.
:type amplist: List of floats
:param gamma: Lorentzian broadening, defaults to 0
:type gamma: int, optional
:param sigma: Gaussian broadening, defaults to 0
...
...
@@ -610,11 +641,6 @@ class MRS(object):
:return: Number of basis sets added
:rtype: int
"""
if
ppmlist
is
None
:
from
fsl_mrs.utils.constants
import
DEFAULT_MM_AMP
,
DEFAULT_MM_PPM
ppmlist
=
DEFAULT_MM_PPM
amplist
=
DEFAULT_MM_AMP
for
idx
,
_
in
enumerate
(
ppmlist
):
if
isinstance
(
ppmlist
[
idx
],
(
float
,
int
)):
ppmlist
[
idx
]
=
[
float
(
ppmlist
[
idx
]),
]
...
...
@@ -624,7 +650,7 @@ class MRS(object):
names
=
[
f
'MM
{
i
[
0
]
*
10
:
02.0
f
}
'
for
i
in
ppmlist
]
for
name
,
ppm
,
amp
in
zip
(
names
,
ppmlist
,
amplist
):
self
.
_basis
.
add_peak
(
ppm
,
amp
,
name
,
gamma
,
sigma
)
self
.
_basis
.
add_peak
(
ppm
,
amp
,
name
,
gamma
,
sigma
,
conj
=
self
.
conj_Basis
)
return
len
(
ppmlist
)
...
...
fsl_mrs/scripts/fsl_mrs
View file @
9ed8e49e
...
...
@@ -74,6 +74,8 @@ def main():
' or list of names for indept groups.'
)
fitting_args
.
add_argument
(
'--add_MM'
,
action
=
"store_true"
,
help
=
"include default macromolecule peaks"
)
fitting_args
.
add_argument
(
'--add_MM_MEGA'
,
action
=
"store_true"
,
help
=
"include default MEGA-PRESS macromolecule peaks"
)
fitting_args
.
add_argument
(
'--lorentzian'
,
action
=
"store_true"
,
help
=
'Enable purely lorentzian broadening'
' (default is Voigt)'
)
...
...
@@ -255,7 +257,13 @@ def main():
if
args
.
add_MM
:
if
args
.
verbose
:
print
(
'Adding macromolecules'
)
nMM
=
mrs
.
add_MM_peaks
(
gamma
=
10
,
sigma
=
20
)
nMM
=
mrs
.
add_default_MM_peaks
(
gamma
=
10
,
sigma
=
20
)
G
=
[
i
+
max
(
metab_groups
)
+
1
for
i
in
range
(
nMM
)]
metab_groups
+=
G
if
args
.
add_MM_MEGA
:
if
args
.
verbose
:
print
(
'Adding MEGA-PRESS macromolecules'
)
nMM
=
mrs
.
add_default_MEGA_MM_peaks
(
gamma
=
10
,
sigma
=
0
)
G
=
[
i
+
max
(
metab_groups
)
+
1
for
i
in
range
(
nMM
)]
metab_groups
+=
G
...
...
fsl_mrs/utils/constants.py
View file @
9ed8e49e
...
...
@@ -119,3 +119,6 @@ Shift and amplitude values for the default macromolecule basis set
'''
DEFAULT_MM_PPM
=
[
0.9
,
1.2
,
1.4
,
1.7
,
[
2.08
,
2.25
,
1.95
,
3.0
]]
DEFAULT_MM_AMP
=
[
3.0
,
2.0
,
2.0
,
2.0
,
[
1.33
,
0.33
,
0.33
,
0.4
]]
DEFAULT_MM_MEGA_PPM
=
[[
0.915
,
3.000
],
]
DEFAULT_MM_MEGA_AMP
=
[[
3.75
,
2.0
],
]
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