Przeglądaj źródła

Correcting syntax error

Andrej Studen 5 lat temu
rodzic
commit
473bb22ea5
1 zmienionych plików z 9 dodań i 7 usunięć
  1. 9 7
      DICOMtools/loadDicom.py

+ 9 - 7
DICOMtools/loadDicom.py

@@ -423,6 +423,12 @@ def dicomValue(file,tag,seqTag=None,shell=False):
     except subprocess.CalledProcessError as e:
         return None
     
+    if debug:
+        print("Tag {} Line '{}'").format(tag,out)
+    if len(out)==0:
+        return out
+
+    #parse multi-match outputs which appear as several lines
     lst=out.split('\n')
     return getTagValue(lst,tag,seqTag)
     
@@ -431,11 +437,6 @@ def getTagValue(lst,tag,seqTag=None):
     
     debug=False
     
-    if debug:
-        print("Tag {} Line '{}'").format(tag,out)
-    if len(out)==0:
-        return out
-
     #parse output
     longTag="^\({}\)".format(tag)
     #combine sequence and actual tags to long tags
@@ -443,12 +444,13 @@ def getTagValue(lst,tag,seqTag=None):
         if debug:
             print("Tag:{} seqTag:{}").format(tag,seqTag)
         longTag="^\({}\).\({}\)".format(seqTag,tag)
-    #parse multi-match outputs which appear as several lines
-    lst=out.split('\n')
+    
     #pick the values
     pattern=r'^.*\[(.*)\].*$'
+    
     #extract tag values
     rpl=[re.sub(pattern,r'\1',f) for f in lst]
+    
     #logical whether the line can be matched to typical dcmdump output
     mtchPattern=[re.match(pattern,f) for f in lst]
     #find matching tags