Commit 6e3eef11 authored by William Clarke's avatar William Clarke
Browse files

Git add additional scaling option to results and fsl_mrs to allow for fixed...

Git add additional scaling option to results and fsl_mrs to allow for fixed water cencentration scaling.
parent 3dc441ef
...@@ -99,6 +99,8 @@ def main(): ...@@ -99,6 +99,8 @@ def main():
nargs='+', nargs='+',
help='Metabolite(s) used as an internal reference.' help='Metabolite(s) used as an internal reference.'
' Defaults to tCr (Cr+PCr).') ' Defaults to tCr (Cr+PCr).')
optional.add_argument('--h2o_scale', type=float, default=1.0,
help='Additional scaling modifier for external water referencing.')
optional.add_argument('--central_frequency', default=None, type=float, optional.add_argument('--central_frequency', default=None, type=float,
help='central frequency in Hz') help='central frequency in Hz')
optional.add_argument('--dwell_time', default=None, type=float, optional.add_argument('--dwell_time', default=None, type=float,
...@@ -329,20 +331,23 @@ def main(): ...@@ -329,20 +331,23 @@ def main():
' no absolute quantification will be performed.', ' no absolute quantification will be performed.',
UserWarning) UserWarning)
res.calculateConcScaling(mrs, referenceMetab=args.internal_ref) res.calculateConcScaling(mrs, referenceMetab=args.internal_ref)
elif args.tissue_frac is None: elif args.tissue_frac is not None:
res.calculateConcScaling(mrs, res.calculateConcScaling(mrs,
referenceMetab=args.internal_ref, referenceMetab=args.internal_ref,
waterRefFID=mrs.H2O, waterRefFID=mrs.H2O,
tissueFractions=None, tissueFractions=args.tissue_frac,
TE=echotime, TE=echotime,
verbose=args.verbose) verbose=args.verbose,
add_scale=args.h2o_scale)
else: else:
res.calculateConcScaling(mrs, res.calculateConcScaling(mrs,
referenceMetab=args.internal_ref, referenceMetab=args.internal_ref,
waterRefFID=mrs.H2O, waterRefFID=mrs.H2O,
tissueFractions=args.tissue_frac, tissueFractions=None,
TE=echotime, TE=echotime,
verbose=args.verbose) verbose=args.verbose,
add_scale=args.h2o_scale)
# Combine metabolites. # Combine metabolites.
if args.combine is not None: if args.combine is not None:
res.combine(args.combine) res.combine(args.combine)
......
...@@ -93,15 +93,24 @@ class FitRes(object): ...@@ -93,15 +93,24 @@ class FitRes(object):
self.combine([['Cr','PCr']]) self.combine([['Cr','PCr']])
self.calculateConcScaling(mrs) self.calculateConcScaling(mrs)
def calculateConcScaling(self, mrs,
referenceMetab=['Cr', 'PCr'],
waterRefFID=None,
tissueFractions=None,
TE=None,
T2='Default',
waterReferenceMetab='Cr',
wRefMetabProtons=5,
reflimits=(2, 5),
verbose=False,
Q=None,
add_scale=None):
def calculateConcScaling(self,mrs,referenceMetab=['Cr','PCr'],waterRefFID=None,tissueFractions=None,TE=None,T2='Default',waterReferenceMetab='Cr',wRefMetabProtons=5,reflimits=(2,5),verbose=False,Q=None):
self.intrefstr = '+'.join(referenceMetab) self.intrefstr = '+'.join(referenceMetab)
self.referenceMetab = referenceMetab self.referenceMetab = referenceMetab
self.waterReferenceMetab = waterReferenceMetab self.waterReferenceMetab = waterReferenceMetab
self.waterReferenceMetabProtons = wRefMetabProtons self.waterReferenceMetabProtons = wRefMetabProtons
internalRefScaling = quant.quantifyInternal(referenceMetab,self.getConc(),self.metabs) internalRefScaling = quant.quantifyInternal(referenceMetab,self.getConc(),self.metabs)
if (waterRefFID is not None) and ((TE is not None) or (Q is not None)): if (waterRefFID is not None) and ((TE is not None) or (Q is not None)):
...@@ -111,6 +120,10 @@ class FitRes(object): ...@@ -111,6 +120,10 @@ class FitRes(object):
Q = quant.loadDefaultQuantificationInfo(TE,tissueFractions,mrs.centralFrequency/1E6) Q = quant.loadDefaultQuantificationInfo(TE,tissueFractions,mrs.centralFrequency/1E6)
else: else:
Q = quant.QuantificationInfo(TE,T2,tissueFractions) Q = quant.QuantificationInfo(TE,T2,tissueFractions)
if add_scale is not None:
Q.additionalCorr *= add_scale
molalityScaling,molarityScaling,quant_info = quant.quantifyWater(mrs, molalityScaling,molarityScaling,quant_info = quant.quantifyWater(mrs,
waterRefFID, waterRefFID,
refFID, refFID,
......
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