Commit 0bd0d2f4 authored by William Clarke's avatar William Clarke
Browse files

Merge branch 'bf/assorted_bf' into 'master'

BF:Assorted fixes

Closes #19, #20, #26, and #16

See merge request fsl/fsl_mrs!45
parents bc509a73 e7157ade
Pipeline #13854 waiting for manual action with stages
in 37 minutes and 19 seconds
......@@ -5,7 +5,8 @@ This document contains the FSL-MRS release history in reverse chronological orde
- Now able to choose the number of workers in fsl_mrs_sim.
- HSLVD routines now use dense (non-sparse) routine for better numerical stability
- Updates and corrections to documentation, references to new FSL Course MRS section added.
- Fixed bugs in LCModel basis set handling.
- Removed divide by zero warnings in quantification of voxels where fitting has failed.
1.1.10 (Thursday 12 January 2022)
---------------------------------
......
......@@ -140,7 +140,9 @@ def main():
hlsvd_group.add_argument('--ppm', type=float, nargs=2,
metavar='<lower-limit upper-limit>',
default=[4.5, 4.8],
help='ppm limits of removal window')
help='ppm limits of removal window.'
' Defaults to 4.5 to 4.8 ppm.'
' Includes (4.65 ppm) shift to TMS reference.')
hlsvdparser.set_defaults(func=remove)
add_common_args(hlsvdparser)
......
......@@ -28,7 +28,9 @@ def test_convert_lcmodel(tmp_path):
new_basis = mrs_io.read_basis(out_loc)
assert basis.names == new_basis.names
assert np.allclose(basis.original_basis_array, new_basis.original_basis_array)
# Check that a conjugation has taken place. This is an annoying hack at the moment because
# fsl_mrs_sim has the wrong handedness.
assert np.allclose(basis.original_basis_array, new_basis.original_basis_array.conj())
assert np.isclose(basis.original_bw, new_basis.original_bw)
assert np.isclose(basis.cf, new_basis.cf)
......
......@@ -38,7 +38,10 @@ def convert_lcm_basis(path_to_basis, output_location=None):
# 1. Read LCModel basis
basis = mrs_io.read_basis(path_to_basis)
# 2. Write to new location
# 2. Conjugate to preserve the sense w.r.t. FSL-MRS useage.
basis = conjugate_basis(basis)
# 3. Write to new location
sim_info = f'Converted from {str(path_to_basis)}'
if output_location is None:
basis.save(path_to_basis.stem, info_str=sim_info)
......
......@@ -187,16 +187,17 @@ def siv_basis_header(header):
"""
extracts metab names and ishift
"""
met_pattern = re.compile(r"\sMETABO\s*\=\s*'([^']+?)'\s*")
ishift_pattern = re.compile(r"\sISHIFT\s*\=\s*([0-9]+)\s*")
metabo = []
shifts = []
for txt in header:
if txt.lower().find('metabo') > 0:
if txt.lower().find('metabo_') < 0:
content = re.search(r"'\s*([^']+?)\s*'", txt).groups()[0]
metabo.append(content)
if txt.lower().find('ishift') > 0:
shifts.append(int(tidy(txt).split()[-1]))
metab_str = met_pattern.search(txt)
ishft_str = ishift_pattern.search(txt)
if metab_str:
metabo.append(metab_str.groups()[0])
if ishft_str:
shifts.append(int(ishft_str.groups()[0]))
return metabo, shifts
......
......@@ -518,7 +518,8 @@ def quantifyInternal(reference, concentrations, names):
raise ValueError(f'Internal reference {reference} is not a recognised metabolite.')
concSum += concentrations[names.index(reference)]
return 1 / concSum
with np.errstate(divide='ignore', invalid='ignore'):
return 1 / concSum
def quantifyWater(mrs, results, quant_info, verbose=False):
......
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