Skip to content

Commit

Permalink
BF+TST: Handle None values in dicom datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
moloney committed Jun 5, 2024
1 parent 615a914 commit 27856f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dcmstack/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def _get_elem_value(self, elem):
value = elem.value

#Handle any conversions
if elem.VR in self.conversions:
if elem.VR in self.conversions and value is not None:
if n_vals == 1:
value = self.conversions[elem.VR](value)
else:
Expand Down
6 changes: 6 additions & 0 deletions test/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,9 @@ def test_non_reloc_private(self):
meta_dict = extractor(self.data)
assert meta_dict["CsaImage.EchoLinePosition"] == 64
assert meta_dict['CsaSeries.MrPhoenixProtocol.sEFISPEC.bEFIDataValid'] == 1

def test_none_vals(self):
extractor = extract.MetaExtractor()
self.data.PercentSampling = None
meta_data = extractor(self.data)
assert "PercentSampling" not in meta_data

0 comments on commit 27856f1

Please sign in to comment.