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

Add test for quantify set fractions. Update changelong with date.

parent a11b8a4e
This document contains the FSL-MRS release history in reverse chronological order.
1.1.5 (WIP)
-------------------------------
1.1.5 (Wednesday 11th August 2021)
----------------------------------
- Updated example MRSI data to conform to NIfTI-MRS standard.
- Quantification will not fail if volume fractions do not sum exactly to 1.0.
- Quantification will not fail if volume fractions do not sum exactly to 1.0 (to within 1E-3).
- fixed bug in fsl_mrsi looking for TE in wrong header structure.
- New mrs_tools command 'conjugate' to help fix NIfTI-MRS data with the wrong phase/frequency convention.
- basis_tools remove has number of HLSVD components reduced to stop odd broad resonance behaviour.
......
......@@ -8,6 +8,7 @@ Copyright Will Clarke, University of Oxford, 2021'''
import os.path as op
import numpy as np
import pytest
import fsl_mrs.utils.mrs_io as mrsio
from fsl_mrs.utils.fitting import fit_FSLModel
......@@ -67,6 +68,14 @@ def test_volumefraction_calc():
assert qci.f_WM == 0.40
assert qci.f_CSF == 0.15
with pytest.raises(ValueError) as exc_info:
qci.set_fractions({'GM': 0.44, 'WM': 0.40, 'CSF': 0.15})
assert exc_info.type is ValueError
assert exc_info.value.args[0] == "fractions must be a dict containing 'WM', 'GM', 'CSF' keys"\
", and must sum to 1. Currently they are:"\
" {'GM': 0.44, 'WM': 0.4, 'CSF': 0.15} (sum=0.9900)."
def test_molefraction_calc():
qci = quant.QuantificationInfo(0.010, 3, ['NAA'], 298)
......
......@@ -277,7 +277,7 @@ class QuantificationInfo(object):
else:
sum_value = np.sum([fractions['WM'], fractions['GM'], fractions['CSF']])
raise ValueError("fractions must be a dict containing 'WM', 'GM', 'CSF' keys"
f", and must sum to 1. Currently they are: {fractions} (sum={sum_value}).")
f", and must sum to 1. Currently they are: {fractions} (sum={sum_value:0.4f}).")
else:
raise TypeError(f'fractions must be a dict, not {type(fractions)}.')
......
Markdown is supported
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