|
@@ -93,13 +93,15 @@ class loadDicomWidget(slicer.ScriptedLoadableModule.ScriptedLoadableModuleWidget
|
|
|
|
|
|
class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
def __init__(self,parent):
|
|
|
- slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic.__init__(self, parent)
|
|
|
+ slicer.ScriptedLoadableModule.\
|
|
|
+ ScriptedLoadableModuleLogic.__init__(self, parent)
|
|
|
|
|
|
self.tag={
|
|
|
'sopInstanceUid' : {'tag':"0008,0018",'VR':'UI'},
|
|
|
'studyDate': {'tag':"0008,0020",'VR':'DA'},
|
|
|
'studyTime': {'tag':"0008,0030",'VR':'TM'},
|
|
|
'seriesTime': {'tag':"0008,0031",'VR':'TM'},
|
|
|
+ 'acquisitionTime':{'tag':"0008,0032",'VR':'TM'},
|
|
|
'modality': {'tag':"0008,0060",'VR':'CS'},
|
|
|
'presentationIntentType': {'tag':"0008,0068",'VR':'CS'},
|
|
|
'manufacturer': {'tag':"0008,0070",'VR':'LO'},
|
|
@@ -119,10 +121,12 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
'xRayTubeCurrent': {'tag':"0018,1151",'VR':'IS'},
|
|
|
'exposure': {'tag':"0018,1152",'VR':'IS'},
|
|
|
'imagerPixelSpacing': {'tag':"0018,1164",'VR':'DS'},
|
|
|
+ 'anodeTargetMaterial':{'tag':"0018,1191",'VR':'CS'},
|
|
|
'bodyPartThickness': {'tag':"0018,11a0",'VR':'DS'},
|
|
|
'compressionForce': {'tag':"0018,11a2",'VR':'DS'},
|
|
|
'viewPosition': {'tag':"0018,5101",'VR':'CS'},
|
|
|
'fieldOfViewHorizontalFlip': {'tag':"0018,7034",'VR':'CS'},
|
|
|
+ 'filterMaterial':{'tag':"0018,7050",'VR':'CS'},
|
|
|
'studyInstanceUid': {'tag':"0020,000d",'VR':'UI'},
|
|
|
'seriesInstanceUid': {'tag':"0020,000e",'VR':'UI'},
|
|
|
'studyId': {'tag':"0020,0010",'VR':'SH'},
|
|
@@ -132,6 +136,8 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
'imageLaterality': {'tag':"0020,0062",'VR':'CS'},
|
|
|
'imagesInAcquisition': {'tag':"0020,1002",'VR':'IS'},
|
|
|
'photometricInterpretation': {'tag':"0028,0004",'VR':'CS'},
|
|
|
+ 'organDose':{'tag':"0040,0316",'VR':'DS'},
|
|
|
+ 'entranceDoseInmGy':{'tag':"0040,8302",'VR':'DS'},
|
|
|
'reconstructionMethod': {'tag':"0054,1103",'VR':'LO'}
|
|
|
}
|
|
|
self.tagPyDicom={
|
|
@@ -163,10 +169,6 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
'instanceNumber': 0x00200013,
|
|
|
'frameOfReferenceInstanceUid': 0x00200052
|
|
|
}
|
|
|
- #new_dict_items={
|
|
|
- # 0x001811a0: ('DS','BodyPartThickness','Body Part Thickness')
|
|
|
- #}
|
|
|
- #dicom.datadict.add_dict_entries(new_dict_items)
|
|
|
self.local=False
|
|
|
self.useDicomModify=False
|
|
|
|
|
@@ -254,7 +256,7 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
|
|
|
return self.applyFilterFile(loadable.files[0],filter,nodeMetadata)
|
|
|
|
|
|
- def applyFilterFile(self,file,filter,nodeMetadata,shell=False):
|
|
|
+ def applyFilterFile(self,file,filter,nodeMetadata,shell=False,debug=False):
|
|
|
#apply filter to file. Return true if file matches prescribed filter and
|
|
|
#false otherwise
|
|
|
|
|
@@ -278,8 +280,9 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
|
|
|
if not filter[key]==None:
|
|
|
if not fileValue==filter[key]:
|
|
|
- #print("File {} failed for tag {}: {}/{}").format(\
|
|
|
- # file,key,fileValue,filter[key])
|
|
|
+ if debug:
|
|
|
+ print("File {} failed for tag {}: {}/{}").format(\
|
|
|
+ file,key,fileValue,filter[key])
|
|
|
filterOK=False
|
|
|
break
|
|
|
|
|
@@ -309,9 +312,10 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
|
|
|
|
|
|
def loadVolumes(self,sNet,dir,filter,doRemove=True):
|
|
|
- #returns all series from the directory, each as a separate node in a node list
|
|
|
- #filter is a dictionary of speciifed dicom values, if filter(key)=None, that values
|
|
|
- #get set, if it isn't, the file gets checked for a match
|
|
|
+#returns all series from the directory, each as a separate node in a node list
|
|
|
+#filter is a dictionary of speciifed dicom values,
|
|
|
+#if filter(key)=None, that value
|
|
|
+#get set, if it isn't, the file gets checked for a match
|
|
|
|
|
|
print("Loading dir {}").format(dir)
|
|
|
dicomFiles=self.listdir(sNet,dir)
|
|
@@ -319,19 +323,25 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
filelist=[]
|
|
|
for f in dicomFiles:
|
|
|
localPath=self.getfile(sNet,f)
|
|
|
+ filelist.append(localPath)
|
|
|
+ if not self.useDicomModify:
|
|
|
+ continue
|
|
|
+ if dicomModify==None:
|
|
|
+ continue
|
|
|
+
|
|
|
f0=localPath
|
|
|
f1=f0+"1"
|
|
|
- if not dicomModify==None:
|
|
|
- try:
|
|
|
- subprocess.call(dicomModify+" "+f0+" "+f1+" && mv "+f1+" "+f0+";", shell=False)
|
|
|
- except OSError:
|
|
|
- print("dicomModify failed")
|
|
|
- filelist.append(localPath)
|
|
|
+ try:
|
|
|
+ cmd=dicomModify+" "+f0+" "+f1+" && mv "+f1+" "+f0+";"
|
|
|
+ subprocess.call(cmd, shell=False)
|
|
|
+ except OSError:
|
|
|
+ print("dicomModify failed")
|
|
|
|
|
|
try:
|
|
|
loadables=self.volumePlugin.examineForImport([filelist])
|
|
|
except AttributeError:
|
|
|
- self.volumePlugin=slicer.modules.dicomPlugins['DICOMScalarVolumePlugin']()
|
|
|
+ self.volumePlugin=\
|
|
|
+ slicer.modules.dicomPlugins['DICOMScalarVolumePlugin']()
|
|
|
loadables=self.volumePlugin.examineForImport([filelist])
|
|
|
|
|
|
|
|
@@ -367,6 +377,8 @@ class loadDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
volume={'node':volumeNode,'metadata':nodeMetadata}
|
|
|
volumeNodes.append(volume)
|
|
|
|
|
|
+ self.volumePlugin.loadableCache.clear()
|
|
|
+
|
|
|
if self.local:
|
|
|
return volumeNodes
|
|
|
|