Skip to content

Commit d375a17

Browse files
committed
BUG: fix infer_contrast() when the tag was missing
This function worked (and validated by a test) when ContrastBolusAgent tag existed and had the value of "NONE". However, if the tag never existed in the source it's value would be set to -12345 during sanitation. This would cause all series without the tag present to be infered as having contrast. Add a check for the default value and a test to validate functionality. The test file is a copy of the existing test file with the ContrastBolusAgent tag removed and UIDs changed. The integration test reference file was changed to reflect the correct result.
1 parent 6ae7bc5 commit d375a17

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/dcm_classifier/image_type_inference.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ def infer_contrast(self, feature_dict: dict = None) -> bool:
223223
return False
224224

225225
# check if the volume has contrast
226-
if "none" not in feature_dict[field].lower():
226+
if (
227+
"none" not in feature_dict[field].lower()
228+
and feature_dict[field] != "-12345"
229+
):
227230
return True
228231
return False
229232

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:5d710631c61e7953e600b37d02ba3009ebe5b28f51b866cb7c29cca8e23a1468
3+
size 132604
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:c0e3d723c3bd7976e68491d0674bdefffde8a378bb0cf49fbea01bf63bb22e89
3-
size 33747
2+
oid sha256:99fa8d35856d8674bb0eb9285c2827177aef458bcf0be0e3213dd78abe3be882
3+
size 32980

tests/unit_testing/test_dicom_series.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ def test_dcm_series_no_contrast(no_contrast_file_path):
205205
study.run_inference()
206206

207207
for series_number, series in study.series_dictionary.items():
208-
assert series.get_has_contrast() is False
208+
assert (
209+
series.get_has_contrast() is False
210+
), f"File {series.get_volume_list()[0].get_one_volume_dcm_filenames()[0].name} came back with contrast"
209211

210212

211213
def test_dcm_series_has_contrast(contrast_file_path):

0 commit comments

Comments
 (0)