diff --git a/src/dcmstack/extract.py b/src/dcmstack/extract.py index 38142d0..0d3059b 100644 --- a/src/dcmstack/extract.py +++ b/src/dcmstack/extract.py @@ -9,7 +9,7 @@ from collections import OrderedDict except ImportError: from ordereddict import OrderedDict - + try: import pydicom from pydicom.datadict import keyword_for_tag @@ -410,7 +410,9 @@ def _get_elem_value(self, elem): else: #Otherwise, just take a copy if the value is a list n_vals = elem.VM - if n_vals > 1: + if n_vals == 0: + return None + elif n_vals > 1: value = elem.value[:] else: value = elem.value diff --git a/test/test_extract.py b/test/test_extract.py index ea54429..4d2edad 100644 --- a/test/test_extract.py +++ b/test/test_extract.py @@ -53,7 +53,7 @@ def test_parse_phx_line(self): assert extract._parse_phoenix_line("test = 0x2") == ('test', 2) assert extract._parse_phoenix_line("test = 2.") == ('test', 2.0) - + with pytest.raises(extract.PhoenixParseError): extract._parse_phoenix_line('test = blah') with pytest.raises(extract.PhoenixParseError): @@ -89,7 +89,9 @@ def test_get_elem_value(self): extractor = extract.MetaExtractor(ignore_rules=ignore_rules) for elem in self.data: value = extractor._get_elem_value(elem) - if elem.VM > 1: + if elem.VM == 0: + assert(value is None) + elif elem.VM > 1: assert(isinstance(value, list)) if elem.VR in list(extract.unpack_vr_map) + ['DS', 'IS']: if elem.VM == 1: