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

New options in fsl_mrs.

parent f3c6e63b
......@@ -252,13 +252,13 @@ class MRS(object):
# Helper functions
def processForFitting(self,ppmlim=(.2,4.2),):
def processForFitting(self,ppmlim=(.2,4.2),ind_scaling=None):
""" Apply rescaling and run the conjugation checks"""
self.check_FID(ppmlim=ppmlim,repair=True)
self.check_Basis(ppmlim=ppmlim,repair=True)
self.rescaleForFitting()
self.rescaleForFitting(ind_scaling=ind_scaling)
def rescaleForFitting(self,scale=100):
def rescaleForFitting(self,scale=100,ind_scaling=None):
""" Apply rescaling across data, basis and H20"""
scaledFID,scaling = misc.rescale_FID(self.FID,scale=scale)
......@@ -267,7 +267,17 @@ class MRS(object):
self.H2O *= scaling
if self.basis is not None:
self.basis,scaling_basis = misc.rescale_FID(self.basis,scale=scale)
if ind_scaling is None:
self.basis,scaling_basis = misc.rescale_FID(self.basis,scale=scale)
else:
index = [self.names.index(n) for n in ind_scaling]
mask = np.zeros_like(self.names,dtype=bool)
mask[index] = True
self.basis[:,~mask],scaling_basis = misc.rescale_FID(self.basis[:,~mask],scale=scale)
scaling_basis = [scaling_basis]
for idx in index:
self.basis[:,idx],tmp = misc.rescale_FID(self.basis[:,idx],scale=scale)
scaling_basis.append(tmp)
else:
scaling_basis = None
......
......@@ -77,6 +77,12 @@ def main():
fitting_args.add_argument('--lorentzian', action="store_true",
help='Enable purely lorentzian broadening'
' (default is Voigt)')
fitting_args.add_argument('--ind_scale', default=None, type=str,
nargs='+',
help='List of basis spectra to scale'
' independently of other basis spectra.')
fitting_args.add_argument('--disable_MH_priors', action="store_true",
help="Disable MH priors.")
# ADDITIONAL OPTIONAL ARGUMENTS
optional.add_argument('--t1', type=str, default=None, metavar='IMAGE',
......@@ -244,7 +250,7 @@ def main():
# Rescale FID, H2O and basis to have nice range
if not args.no_rescale:
mrs.rescaleForFitting()
mrs.rescaleForFitting(ind_scaling=args.ind_scale)
# Do phase correction
if args.phase_correct:
......@@ -278,18 +284,21 @@ def main():
G = [i+max(metab_groups)+1 for i in range(nMM)]
metab_groups += G
# Choose fitting lineshape model.
if args.lorentzian:
Fitargs = {'ppmlim': ppmlim,
'method': args.algo,
'baseline_order': args.baseline_order,
'metab_groups': metab_groups,
'model': 'lorentzian'}
'model': 'lorentzian',
'disable_mh_priors': args.disable_MH_priors}
else:
Fitargs = {'ppmlim': ppmlim,
'method': args.algo,
'baseline_order': args.baseline_order,
'metab_groups': metab_groups,
'model': 'voigt'}
'model': 'voigt',
'disable_mh_priors': args.disable_MH_priors}
if args.verbose:
print(mrs)
......
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