From 3f7a5fc3514b293b73c8f7c875902dbb237561a2 Mon Sep 17 00:00:00 2001 From: WillForan Date: Sat, 22 Mar 2025 15:42:35 -0400 Subject: [PATCH] fix: extra dcm file name types + message if unknown input Dicoms don't always end in .dcm. Sometimes .IMA others start with MR and have no extention This would be better as a switch to force dicom? Or maybe always try dicom if nii fails? --- med2image/med2image.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/med2image/med2image.py b/med2image/med2image.py index 9c3474d..3a45432 100755 --- a/med2image/med2image.py +++ b/med2image/med2image.py @@ -792,7 +792,9 @@ def inputFile_defineFromSubStr(astr_dir): b_niftiExt = (str_inputFileExtension == '.nii' or str_inputFileExtension == '.gz') - b_dicomExt = str_inputFileExtension == '.dcm' + b_dicomExt = (str_inputFileExtension == '.dcm' or + str_inputFileExtension == '.IMA' or + re.search(r"(^|/)MR\.",args.inputFile)) self.C_convert = None if b_niftiExt: @@ -812,7 +814,7 @@ def inputFile_defineFromSubStr(astr_dir): print('sliceToConvert:', args.sliceToConvert) - if b_dicomExt: + elif b_dicomExt: self.C_convert = med2image_dcm( inputFile = args.inputFile, inputDir = args.inputDir, @@ -828,3 +830,5 @@ def inputFile_defineFromSubStr(astr_dir): func = args.func, verbosity = args.verbosity ) + else: + print(f"ERROR: dont know what to do with {args.inputFile}. not dcm or nii?")