From 6ae7bc59d30359c473e9c085530059c7c8589a74 Mon Sep 17 00:00:00 2001 From: Chance Sauley Date: Fri, 16 Jan 2026 13:23:59 -0600 Subject: [PATCH 1/3] ENH: Git ignore MacOS generated .DS_STORE files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index f4fbcc9..45aa949 100644 --- a/.gitignore +++ b/.gitignore @@ -549,3 +549,6 @@ dmypy.json # End of https://www.toptal.com/developers/gitignore/api/visualstudiocode **/__pycache__/** + +# MacOS generated files +.DS_STORE From d375a172e2662887b4e7cad817c72b05e221965a Mon Sep 17 00:00:00 2001 From: Chance Sauley Date: Wed, 28 Jan 2026 00:54:36 -0600 Subject: [PATCH 2/3] 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. --- src/dcm_classifier/image_type_inference.py | 5 ++++- .../without_contrast/no_contrastbolusagent_tag.dcm | 3 +++ .../integration_testing/classify_study_data/output.json | 4 ++-- tests/unit_testing/test_dicom_series.py | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 tests/testing_data/anonymized_testing_data/contrast_data/without_contrast/no_contrastbolusagent_tag.dcm diff --git a/src/dcm_classifier/image_type_inference.py b/src/dcm_classifier/image_type_inference.py index be15b69..cc19a38 100644 --- a/src/dcm_classifier/image_type_inference.py +++ b/src/dcm_classifier/image_type_inference.py @@ -223,7 +223,10 @@ def infer_contrast(self, feature_dict: dict = None) -> bool: return False # check if the volume has contrast - if "none" not in feature_dict[field].lower(): + if ( + "none" not in feature_dict[field].lower() + and feature_dict[field] != "-12345" + ): return True return False diff --git a/tests/testing_data/anonymized_testing_data/contrast_data/without_contrast/no_contrastbolusagent_tag.dcm b/tests/testing_data/anonymized_testing_data/contrast_data/without_contrast/no_contrastbolusagent_tag.dcm new file mode 100644 index 0000000..0f4c7fa --- /dev/null +++ b/tests/testing_data/anonymized_testing_data/contrast_data/without_contrast/no_contrastbolusagent_tag.dcm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d710631c61e7953e600b37d02ba3009ebe5b28f51b866cb7c29cca8e23a1468 +size 132604 diff --git a/tests/testing_data/integration_testing/classify_study_data/output.json b/tests/testing_data/integration_testing/classify_study_data/output.json index b180d2d..93352a1 100644 --- a/tests/testing_data/integration_testing/classify_study_data/output.json +++ b/tests/testing_data/integration_testing/classify_study_data/output.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0e3d723c3bd7976e68491d0674bdefffde8a378bb0cf49fbea01bf63bb22e89 -size 33747 +oid sha256:99fa8d35856d8674bb0eb9285c2827177aef458bcf0be0e3213dd78abe3be882 +size 32980 diff --git a/tests/unit_testing/test_dicom_series.py b/tests/unit_testing/test_dicom_series.py index 6d5b179..129f417 100644 --- a/tests/unit_testing/test_dicom_series.py +++ b/tests/unit_testing/test_dicom_series.py @@ -205,7 +205,9 @@ def test_dcm_series_no_contrast(no_contrast_file_path): study.run_inference() for series_number, series in study.series_dictionary.items(): - assert series.get_has_contrast() is False + assert ( + series.get_has_contrast() is False + ), f"File {series.get_volume_list()[0].get_one_volume_dcm_filenames()[0].name} came back with contrast" def test_dcm_series_has_contrast(contrast_file_path): From 5e7f5d1600afa09d2b212e7d525b4dd886401b8d Mon Sep 17 00:00:00 2001 From: iejohnson Date: Fri, 3 Apr 2026 12:24:03 -0500 Subject: [PATCH 3/3] BUG: fix infer_contrast by normalizing missing ContrastBolusAgent at sanitization layer The previous fix checked for the sentinel value "-12345" in infer_contrast(), but this left the raw sentinel flowing through the rest of the system. Instead, add "-12345" to the no_contrast_list in get_coded_dictionary_elements() so missing tags are normalized to "None" before reaching any downstream code. Regenerated the integration test baseline to match the corrected output. --- src/dcm_classifier/image_type_inference.py | 5 +---- src/dcm_classifier/utility_functions.py | 10 +++++++++- .../classify_study_data/output.json | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/dcm_classifier/image_type_inference.py b/src/dcm_classifier/image_type_inference.py index cc19a38..be15b69 100644 --- a/src/dcm_classifier/image_type_inference.py +++ b/src/dcm_classifier/image_type_inference.py @@ -223,10 +223,7 @@ def infer_contrast(self, feature_dict: dict = None) -> bool: return False # check if the volume has contrast - if ( - "none" not in feature_dict[field].lower() - and feature_dict[field] != "-12345" - ): + if "none" not in feature_dict[field].lower(): return True return False diff --git a/src/dcm_classifier/utility_functions.py b/src/dcm_classifier/utility_functions.py index 81d5cbc..ec6c058 100644 --- a/src/dcm_classifier/utility_functions.py +++ b/src/dcm_classifier/utility_functions.py @@ -766,7 +766,15 @@ def get_coded_dictionary_elements( else: dataset_dictionary[feature] = 0 elif name == "ContrastBolusAgent": - no_contrast_list = ["none", "no", "no contrast", "no_contrast", "n", ""] + no_contrast_list = [ + "none", + "no", + "no contrast", + "no_contrast", + "n", + "", + "-12345", + ] if str(value).lower() in no_contrast_list: dataset_dictionary["ContrastBolusAgent"] = "None" else: diff --git a/tests/testing_data/integration_testing/classify_study_data/output.json b/tests/testing_data/integration_testing/classify_study_data/output.json index 93352a1..e42308d 100644 --- a/tests/testing_data/integration_testing/classify_study_data/output.json +++ b/tests/testing_data/integration_testing/classify_study_data/output.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:99fa8d35856d8674bb0eb9285c2827177aef458bcf0be0e3213dd78abe3be882 -size 32980 +oid sha256:eac37171712b3b71e90a9f200e24f84f735ea9d50b48691a897d14b030c32e38 +size 32941