Browse Source

Modifying loadDicom to deal with subsequence items

Andrej Studen 5 years ago
parent
commit
aafde2ef9d
1 changed files with 11 additions and 6 deletions
  1. 11 6
      labkeySlicerPythonExtension/loadDicom.py

+ 11 - 6
labkeySlicerPythonExtension/loadDicom.py

@@ -69,7 +69,7 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
               'studyId': {'tag':"0020,0010",'VR':'SH'},
               'seriesNumber': {'tag':"0020,0011",'VR':'IS'},
               'instanceNumber': {'tag':"0020,0013",'VR':'IS'},
-              'frameOfReferenceInstanceUid': {'tag':"0020,0052",'VR':'UI'},
+              'frameOfReferenceInstanceUid': {'tag':"0020,0052",'seqTag':"3006,0010",'VR':'UI'},
               'imageLaterality': {'tag':"0020,0062",'VR':'CS'},
               'imagesInAcquisition': {'tag':"0020,1002",'VR':'IS'},
               'photometricInterpretation': {'tag':"0028,0004",'VR':'CS'},
@@ -178,7 +178,10 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
             #    fileValue=plan[self.tag[key]].value
             #except KeyError:
             #        fileValue=None
-            fileValue=dicomValue(loadable.files[0],self.tag[key]['tag'])
+            try:
+                fileValue=dicomValue(loadable.files[0],self.tag[key]['tag'],self.tag[key]['seqTag'])
+            except KeyError:
+                fileValue=dicomValue(loadable.files[0],self.tag[key]['tag'])
 
 
             if filter[key]=="SeriesLabel":
@@ -308,15 +311,17 @@ def isDicom(file):
     return dt=='DICM'
 
 
-def dicomValue(file,tag):
-    dcmdump=os.path.join(os.environ['SLICER_HOME'],"bin")
-    dcmdump=os.path.join(dcmdump,"dcmdump")
+def dicomValue(file,tag,seqTag=None):
+    dcmdump=os.path.join(os.environ['SLICER_HOME'],"bin","dcmdump")
     try:
-        out=subprocess.check_output([dcmdump,'+p','+P',tag,file])
+        out=subprocess.check_output([dcmdump,'+p','+P',tag,file],shell=True)
         print("Tag {} Line '{}'").format(tag,out)
         if len(out)==0:
             return out
         tag1="^\({}\)".format(tag)
+        if not seqTag==None:
+            print("Tag:{} seqTag:{}").format(tag,seqTag)
+            tag1="^\({}\).\({}\)".format(seqTag,tag)
         lst=out.split('\n')
         rpl=[re.sub(r'^.*\[(.*)\].*$',r'\1',f) for f in lst]
         mtch=[re.match(tag1,f) for f in lst]