Переглянути джерело

Removing common dicom tools

Andrej Studen 5 роки тому
батько
коміт
19356643b9
2 змінених файлів з 0 додано та 638 видалено
  1. 0 360
      dataExplorer/exportDicom.py
  2. 0 278
      dataExplorer/importDicom.py

+ 0 - 360
dataExplorer/exportDicom.py

@@ -1,360 +0,0 @@
-import DICOMLib
-from slicer.ScriptedLoadableModule import *
-import slicerNetwork
-import qt,vtk,ctk,slicer
-import datetime
-import re
-import os
-import slicer.cli
-
-class exportDicom(slicer.ScriptedLoadableModule.ScriptedLoadableModule):
-  def __init__(self,parent):
-        slicer.ScriptedLoadableModule.ScriptedLoadableModule.__init__(self, parent)
-        self.className="exportDicom"
-        self.parent.title="exportDicom"
-        self.parent.categories = ["Examples"]
-        self.parent.dependencies = []
-        self.parent.contributors = ["Andrej Studen (University of Ljubljana)"] # replace with "Firstname Lastname (Organization)"
-        self.parent.helpText = """
-        This is an example of scripted loadable module bundled in an extension.
-        It adds hierarchy datat for reliable dicom export of a node
-        """
-        self.parent.helpText += self.getDefaultModuleDocumentationLink()
-        self.parent.acknowledgementText = """
-        This extension developed within Medical Physics research programe of ARRS
-        """ # replace with organization, grant and thanks.
-
-#
-# dataExplorerWidget
-
-
-
-class exportDicomWidget(ScriptedLoadableModuleWidget):
-  """Uses ScriptedLoadableModuleWidget base class, available at:
-  https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
-  """
-
-  def setup(self):
-      ScriptedLoadableModuleWidget.setup(self)
-      self.logic=exportDicomLogic(self)
-
-      try:
-           fhome=os.environ["HOME"]
-      except:
-              #in windows, the variable is called HOMEPATH
-           fhome=os.environ['HOMEDRIVE']+os.environ['HOMEPATH']
-
-      cfgPath=os.path.join(fhome,".labkey")
-      cfgPath=os.path.join(cfgPath,"onko-nix.json")
-
-      self.onkoNet=slicerNetwork.labkeyURIHandler()
-      self.onkoNet.parseConfig(cfgPath)
-      self.onkoNet.initRemote()
-
-      self.project='EMBRACE/Studija'
-
-      datasetCollapsibleButton = ctk.ctkCollapsibleButton()
-      datasetCollapsibleButton.text = "Node data"
-      self.layout.addWidget(datasetCollapsibleButton)
-      # Layout within the dummy collapsible button
-      datasetFormLayout = qt.QFormLayout(datasetCollapsibleButton)
-
-      self.volumeNode=qt.QLineEdit("Shifted_1_PTV N")
-      datasetFormLayout.addRow("volumeNode:",self.volumeNode)
-      self.patientId=qt.QLineEdit("LJU004")
-      datasetFormLayout.addRow("PatientId:",self.patientId)
-      self.studyInstanceUid=qt.QLineEdit("1.2.840.113704.1.1762661776.922.1250707615.8")
-      datasetFormLayout.addRow("StudyInstanceUid:",self.studyInstanceUid)
-      self.studyDescription=qt.QLineEdit("Segmentation:PTV N")
-      datasetFormLayout.addRow("StudyDescription:",self.studyDescription)
-
-      self.addHierarchyButton=qt.QPushButton("Add hierarchy")
-      self.addHierarchyButton.clicked.connect(self.onAddHierarchyButtonClicked)
-      datasetFormLayout.addRow("Volume:",self.addHierarchyButton)
-
-      self.exportButton=qt.QPushButton("Export")
-      self.exportButton.clicked.connect(self.onExportButtonClicked)
-      datasetFormLayout.addRow("Export:",self.exportButton)
-
-
-
-  def onAddHierarchyButtonClicked(self):
-      metadata={'patientId':self.patientId.text,
-                'studyDescription':self.studyDescription.text,
-                'studyInstanceUid':self.studyInstanceUid.text}
-      node=slicer.util.getFirstNodeByName(self.volumeNode.text)
-      if node==None:
-          return
-      self.logic.addHierarchy(node,metadata)
-
-  def onExportButtonClicked(self):
-      metadata={'patientId':self.patientId.text,
-                'studyDescription':self.studyDescription.text,
-                'studyInstanceUid':self.studyInstanceUid.text,
-                'seriesInstanceUid':self.logic.generateSeriesUUID('volume'),
-                'frameOfReferenceInstanceUid':self.logic.generateFrameOfReferenceUUID('volume')}
-      node=slicer.util.getFirstNodeByName(self.volumeNode.text)
-      if node==None:
-          return
-      self.logic.exportNode(self.onkoNet,self.project,node,metadata)
-
-
-
-class exportDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
-  def __init__(self,parent):
-       slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic.__init__(self, parent)
-       self.baseUUID='1.2.826.0.1.36800.43.10.248'
-       self.labelUUID={'series':'1','study':'2','instance':'3','frameOfReference':4}
-       self.dataUUID={'volume':'1','segmentation':'2','transformation':'3'}
-
-       try:
-           fhome=os.environ["HOME"]
-       except:
-              #in windows, the variable is called HOMEPATH
-           fhome=os.environ['HOMEDRIVE']+os.environ['HOMEPATH']
-
-
-       self.basePath=os.path.join(fhome,'.dicom')
-
-       if not os.path.isdir(self.basePath):
-           os.mkdir(self.basePath)
-
-       self.itemLabel={
-            'patientName': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMPatientNameAttributeName(),
-            'modality': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMSeriesModalityAttributeName(),
-            'patientId': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMPatientIDAttributeName(),
-            'patientSex': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMPatientSexAttributeName(),
-            'patientBirthDate': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMPatientBirthDateAttributeName(),
-            'patientComments': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMPatientCommentsAttributeName(),
-            'studyDescription': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMStudyDescriptionAttributeName(),
-            'studyInstanceUid': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMStudyInstanceUIDTagName(),
-            'studyDate': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMStudyDateAttributeName(),
-            'studyId': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMStudyIDTagName(),
-            'studyTime': slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMStudyTimeAttributeName()}
-
-
-
-
-
-
-
-  def generateStudyUUID(self,type):
-
-        x=datetime.datetime.now()
-        date=x.strftime("%Y%m%d")
-        studyFile=os.path.join(self.basePath,'studyCount'+date+'.txt')
-
-        try:
-            f=open(studyFile,"r")
-            id=int(f.readline())
-            id=id+1
-            f.close()
-        except:
-            id=0
-
-        studyId="{}.{}.{}.{}.{}".format(self.baseUUID,self.labelUUID['study'],
-                        self.dataUUID[type],date,id)
-
-        f=open(studyFile,"w")
-        f.write("{}".format(id))
-        f.close()
-        return studyId
-
-
-
-  def generateFrameOfReferenceUUID(self,type):
-
-        x=datetime.datetime.now()
-        date=x.strftime("%Y%m%d")
-        forFile=os.path.join(self.basePath,'frameCount'+date+'.txt')
-
-        try:
-            f=open(studyFile,"r")
-            id=int(f.readline())
-            id=id+1
-            f.close()
-        except:
-            id=0
-
-        forId="{}.{}.{}.{}.{}".format(self.baseUUID,self.labelUUID['frameOfReference'],
-                        self.dataUUID[type],date,id)
-
-        f=open(forFile,"w")
-        f.write("{}".format(id))
-        f.close()
-        return forId
-
-  def generateSeriesUUID(self,type):
-
-        x=datetime.datetime.now()
-        hour=x.strftime("%H")
-        hour=re.sub('^0','',hour)
-        ft=hour+x.strftime("%M%S")
-        seriesInstanceUid=self.baseUUID+'.'+self.labelUUID['series']+'.'
-        seriesInstanceUid+=self.dataUUID[type]+'.'+x.strftime("%Y%m%d")+'.'+ft
-        return seriesInstanceUid
-
-  def setAttribute(self,shn,itemId,label,metadata):
-        try:
-            shn.SetItemAttribute(itemId,self.itemLabel['modality'],metadata['modality'])
-        except KeyError:
-            pass
-
-  def addHierarchy(self,dataNode,metadata):
-        #convert dataNode to fully fledged DICOM object in hierarchy
-
-        #variation of addSeriesInSubjectHierarchy
-        shn=slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
-        sceneItemId=shn.GetSceneItemID()
-
-        #add the series for the data node
-        seriesItemId=shn.CreateItem(sceneItemId,dataNode)
-
-        x=datetime.datetime.now()
-        hour=x.strftime("%H")
-        hour=re.sub('^0','',hour)
-        ft=hour+x.strftime("%M%S")
-        seriesInstanceUid=self.baseUUID+'.'+self.labelUUID['series']+'.'
-        seriesInstanceUid+=self.dataUUID['volume']+'.'+x.strftime("%Y%m%d")+'.'+ft
-        shn.SetItemUID(seriesItemId,slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(),
-            seriesInstanceUid)
-
-        self.setAttribute(shn,seriesItemId,'modality',metadata)
-        self.setAttribute(shn,seriesItemId,'seriesNumber',metadata)
-
-        #add PatientId
-        try:
-            patientId=metadata['patientId']
-        except KeyError:
-            patientId='Unknown'
-
-        try:
-            studyInstanceUid=metadata['studyInstanceUid']
-        except KeyError:
-            studyInstanceUid=self.generateStudyUUID('volume')
-
-        slicer.vtkSlicerSubjectHierarchyModuleLogic.InsertDicomSeriesInHierarchy(shn,patientId,
-            studyInstanceUid,seriesInstanceUid)
-
-        patientItemId=shn.GetItemByUID(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(),patientId)
-
-        self.setAttribute(shn,patientItemId,'patientName',metadata)
-        self.setAttribute(shn,patientItemId,'patientId',metadata)
-        self.setAttribute(shn,patientItemId,'patientSex',metadata)
-        self.setAttribute(shn,patientItemId,'patientBirthDate',metadata)
-        self.setAttribute(shn,patientItemId,'patientComments',metadata)
-
-        patientItemName=patientId
-        shn.SetItemName(patientItemId,patientItemName)
-
-        studyItemId=shn.GetItemByUID(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMUIDName(),studyInstanceUid)
-
-        self.setAttribute(shn,studyItemId,'studyDescription',metadata)
-        self.setAttribute(shn,studyItemId,'studyInstanceUid',metadata)
-        self.setAttribute(shn,studyItemId,'studyId',metadata)
-        self.setAttribute(shn,studyItemId,'studyDate',metadata)
-        self.setAttribute(shn,studyItemId,'studyTime',metadata)
-
-        studyItemName=studyInstanceUid
-        shn.SetItemName(studyItemId,studyItemName)
-
-  def setTagValue(self,cliparameters,metadata,field):
-       try:
-           cliparameters[field]=metadata[field]
-       except KeyError:
-           pass
-
-  def setDirectoryValue(self,cliparameters,cliKey,metadata,key):
-       try:
-           cliparameters[cliKey]=metadata[key]
-       except KeyError:
-           pass
-
-
-
-  def generateDicom(self, volumeNode, metadata, fdir):
-
-       cliparameters={}
-       tagList=['patientName','patientComments','studyDate','studyTime','studyDescription',
-            'modality','manufacturer','model','seriesDescription',
-            'seriesNumber','seriesDate','seriesTime','contentDate','contentTime']
-
-       for tag in tagList:
-           self.setTagValue(cliparameters,metadata,tag)
-
-       valuePairs={'patientID':'patientId',
-                    'studyID':'studyId',
-                    'seriesInstanceUID':'seriesInstanceUid',
-                    'studyInstanceUID':'studyInstanceUid',
-                    'frameOfReferenceInstanceUID':'frameOfReferenceInstanceUid'}
-
-       for key in valuePairs:
-           self.setDirectoryValue(cliparameters,key,metadata,valuePairs[key])
-
-
-       cliparameters['dicomDirectory']=fdir
-       cliparameters['dicomPrefix']='IMG'
-       cliparameters['inputVolume']=volumeNode.GetID()
-
-       print("[CLI]SeriesInstanceUID: {}").format(cliparameters['seriesInstanceUID'])
-       print("[MeD]SeriesInstanceUID: {}").format(metadata['seriesInstanceUid'])
-
-       try:
-           dicomWrite=slicer.modules.createdicomseries
-       except AttributeError:
-           print("Missing dicom exporter")
-           return
-
-       cliNode=slicer.cli.run(dicomWrite,None,cliparameters,wait_for_completion=True)
-       status=cliNode.GetStatusString()
-       print("Status: {}").format(status)
-       if status.find("error")>-1:
-              print("Error: {}").format(cliNode.GetErrorText())
-              return False
-       return True
-
-
-  def exportNode(self,net, project,volumeNode,metadata):
-
-
-       #buffed up exportable is now ready to be stored
-       fdir=net.GetLocalCacheDirectory()
-       project=project.replace('/','\\')
-       fdir=os.path.join(fdir,project)
-       fdir=os.path.join(fdir,'%40files')
-       fdir=os.path.join(fdir,metadata['patientId'])
-       fdir=os.path.join(fdir,'Registration')
-
-       if not os.path.isdir(fdir):
-           os.mkdir(fdir)
-
-       relDir=net.GetRelativePathFromLocalPath(fdir)
-       remoteDir=net.GetLabkeyPathFromRelativePath(relDir)
-
-       if not net.isRemoteDir(remoteDir):
-            net.mkdir(remoteDir)
-
-       dirName=volumeNode.GetName();
-       dirName=dirName.replace(" ","_")
-       fdir=os.path.join(fdir,dirName)
-
-       if not os.path.isdir(fdir):
-           os.mkdir(fdir)
-
-       relDir=net.GetRelativePathFromLocalPath(fdir)
-       remoteDir=net.GetLabkeyPathFromRelativePath(relDir)
-
-       if not net.isRemoteDir(remoteDir):
-            net.mkdir(remoteDir)
-
-       if not self.generateDicom(volumeNode,metadata,fdir):
-           return
-
-       for f in os.listdir(fdir):
-           localPath=os.path.join(fdir,f)
-           print("localPath: {}").format(localPath)
-           relativePath=net.GetRelativePathFromLocalPath(localPath)
-           print("relativePath: {}").format(relativePath)
-           remotePath=net.GetLabkeyPathFromRelativePath(relativePath)
-           print("remotePath: {}").format(relativePath)
-           net.copyLocalFileToRemote(localPath,remotePath)

+ 0 - 278
dataExplorer/importDicom.py

@@ -1,278 +0,0 @@
-import dicom
-import vtkInterface as vi
-import os
-import vtk, qt, ctk, slicer
-from slicer.ScriptedLoadableModule import *
-import slicerNetwork
-import json
-import loadDicom
-import DICOMLib
-
-class importDicom(slicer.ScriptedLoadableModule.ScriptedLoadableModule):
-    def __init__(self,parent):
-        slicer.ScriptedLoadableModule.ScriptedLoadableModule.__init__(self, parent)
-        self.className="loadPatient"
-        self.parent.title="loadPatient"
-        self.parent.categories = ["LabKey"]
-        self.parent.dependencies = []
-        self.parent.contributors = ["Andrej Studen (UL/FMF)"] # replace with "Firstname Lastname (Organization)"
-        self.parent.helpText = """
-                utilities for parsing dicom entries
-                """
-        self.parent.acknowledgementText = """
-                Developed within the medical physics research programme of the Slovenian research agency.
-                """ # replace with organization, grant and thanks.
-#equivalent of loadable + labkey interface
-class dicomSeries():
-    def __init__(self):
-        self.data = []
-        self.idx = []
-        self.z = []
-        self.pixel_size = [0,0,0]
-        self.lpsOrigin = [0,0,0]
-        self.lpsOrigin[2]=1e30
-        self.lpsOrientation=[0,0,0,0,0,0]
-
-
-    def getfile(self,net,relativePath):
-        return net.readFileToBuffer(relativePath)
-
-    def addFile(self,f):
-        try:
-            self.files.append(f)
-        except:
-            self.files=[f]
-
-    def setLabel(self,label):
-        self.label=label
-
-    def getLabel(self):
-        try:
-            return self.label
-        except:
-            return None
-
-    def setMetadata(self,key,value):
-        try:
-            self.metadata[key]=value
-        except:
-            self.metadata={key:value}
-
-    def getMetadata(self):
-        try:
-            return self.metadata
-        except:
-            return {}
-
-    def load(self,net):
-
-        for f in self.files:
-            print '{}:'.format(f)
-            fileBuffer=self.getfile(net,f)
-            self.loadFile(fileBuffer)
-
-        nz=len(self.idx)
-        sh=self.data[-1].shape
-        sh_list=list(sh)
-        sh_list.append(nz)
-        data_array=np.zeros(sh_list)
-
-        for k in range(0,nz):
-            kp=int(np.round((self.z[k]-self.center[2])/self.pixel_size[2]))
-            data_array[:,:,kp]=np.transpose(self.data[k])
-
-        try:
-            nodeName='Series'+self.label
-        except:
-            print('Could not set series label')
-            nodeName='UnknownSeries'
-
-        newNode=slicer.vtkMRMLScalarVolumeNode()
-        newNode.SetName(nodeName)
-
-        ijkToRAS = vtk.vtkMatrix4x4()
-        #think how to do this with image orientation
-
-        rasOrientation=[-self.lpsOrientation[i] if (i%3 < 2) else self.lpsOrientation[i]
-          for i in range(0,len(self.lpsOrientation))]
-        rasOrigin=[-self.lpsOrigin[i] if (i%3<2) else self.lpsOrigin[i] for i in range(0,len(self.lpsOrigin))]
-
-        for i in range(0,3):
-             for j in range(0,3):
-                 ijkToRAS.SetElement(i,j,self.pixel_size[i]*rasOrientation[3*j+i])
-
-             ijkToRAS.SetElement(i,3,rasOrigin[i])
-
-        newNode.SetIJKToRASMatrix(ijkToRAS)
-
-        v=vtk.vtkImageData()
-        v.GetPointData().SetScalars(
-            vtk.util.numpy_support.numpy_to_vtk(
-                np.ravel(self.data,order='F'),deep=True, array_type=vtk.VTK_FLOAT))
-        v.SetOrigin(0,0,0)
-        v.SetSpacing(1,1,1)
-        v.SetDimensions(self.data.shape)
-
-        newNode.SetAndObserveImageData(v)
-        slicer.mrmlScene.AddNode(newNode)
-        volume={'node':newNode,'metadata':self.metadata}
-        return volume
-
-    def loadFile(self,fileBuffer):
-
-        plan=dicom.read_file(fileBuffer)
-
-        self.data.append(plan.pixel_array)
-        self.idx.append(plan.InstanceNumber)
-        self.z.append(plan.ImagePositionPatient[2])
-
-
-        #pixelSize
-        pixel_size=[plan.PixelSpacing[0],plan.PixelSpacing[1],
-                    plan.SliceThickness]
-
-        for i in range(0,3):
-            if self.pixel_size[i] == 0:
-                self.pixel_size[i] = float(pixel_size[i])
-            if abs(self.pixel_size[i]-pixel_size[i]) > 1e-3:
-                print 'Pixel size mismatch {.2f}/{.2f}'.format(self.pixel_size[i],
-                        pixel_size[i])
-
-        #origin
-        for i in range(0,2):
-            if self.lpsOrigin[i] == 0:
-                self.lpsOrigin[i] = float(plan.ImagePositionPatient[i])
-            if abs(self.lpsOrigin[i]-plan.ImagePositionPatient[i]) > 1e-3:
-                print 'Image center mismatch {.2f}/{.2f}'.format(self.lpsOrigin[i],
-                    plan.ImagePositionPatient[i])
-        #not average, but minimum (!) why??
-
-        if plan.ImagePositionPatient[2]<self.lpsOrigin[2]:
-            self.lpsOrigin[2]=plan.ImagePositionPatient[2]
-
-
-        #orientation
-        for i in range(0,6):
-            if self.lpsOrientation[i] == 0:
-                self.lpsOrientation[i] = float(plan.ImageOrientationPatient[i])
-            if abs(self.lpsOrientation[i]-plan.ImageOrientationPatient[i]) > 1e-3:
-                print 'Image orientation mismatch {0:.2f}/{1:.2f}'.format(self.lpsOrientation[i],
-                        plan.ImageOrientationPatient[i])
-
-        return True
-
-class importDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
-    def __init__(self,parent):
-       slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic.__init__(self, parent)
-       self.tag={
-        'studyInstanceUid':0x0020000d,
-        'seriesInstanceUid':0x0020000e,
-        'patientId':0x00100020,
-        'patientName':0x00100010,
-        'sequenceName':0x00180024,
-        'seriesNumber':0x00200011,
-        'percentPhaseFieldOfView':0x00180094,
-        'modality': 0x00080060,
-        'patientSex': 0x00100040,
-        'patientBirthDate': 0x00100030,
-        'patientComments': 0x00104000,
-        'studyDescription': 0x00081030,
-        'studyDate': 0x00080020,
-        'studyId': 0x00200010,
-        'studyTime': 0x00080030,
-        'frameOfReferenceInstanceUid':0x00200052}
-
-    def loadVolumes(self,net,directory,filter):
-        #mimic examineForImport
-        seriesList=self.examineForImport(net,directory,filter)
-        print("Got {} series").format(len(seriesList))
-        volumes=[]
-
-        for s in seriesList:
-            try:
-                volumes.append(s.load(net))
-                #often fails, e.g. JPEGLossles
-            except:
-                loadable=DICOMLib.DICOMLoadable()
-                loadable.name='Series'+str(s.getLabel())
-                print("Loading for {} number of files (pre-load) {}").format(loadable.name,len(s.files))
-                loadable.files=[net.DownloadFileToCache(f) for f in s.files]
-                print("Loading for {} number of files (pre-sort) {}").format(loadable.name,len(loadable.files))
-
-                loadable.files,distances,loadable.warning=DICOMLib.DICOMUtils.getSortedImageFiles(loadable.files,1e-3)
-
-                print("Loading for {} number of files {}").format(loadable.name,len(loadable.files))
-                try:
-                    volumeNode=self.volumePlugin.load(loadable)
-                except:
-                    self.volumePlugin=slicer.modules.dicomPlugins['DICOMScalarVolumePlugin']()
-                    volumeNode=self.volumePlugin.load(loadable)
-                volume={'node':volumeNode,'metadata':s.getMetadata()}
-                volumes.append(volume)
-
-
-        return volumes
-
-
-    def listdir(self,net,relativeDirectory):
-        return net.listRelativeDir(relativeDirectory)
-
-    def getfile(self,net,relativePath):
-        return net.readFileToBuffer(relativePath)
-
-    def examineForImport(self,net,directory,filter):
-        #split by series
-        files=self.listdir(net,directory)
-        seriesList=[]
-
-        seriesList.append(dicomSeries())
-        series=seriesList[0]
-
-        for f in files:
-            fileBuffer=self.getfile(net,f)
-            #validate
-            try:
-                plan = dicom.read_file(fileBuffer)
-            except:
-                print ("{}: Not a dicom file")
-                continue
-
-            #determine validity first
-            fileValid=True
-            seriesKey=None
-            for key in filter:
-                if filter[key]==None:
-                    continue
-                if filter[key]=='SeriesLabel':
-                    seriesTag=self.tag[key]
-                    continue
-
-                v=plan[self.tag[key]].value
-                if not v==filter[key]:
-                    print('Filter mismatch {}{:x}: {}/{}').format(key,self.tag[key],v,filter[key])
-                    fileValid=False
-
-            if not fileValid:
-                continue
-
-            #determine serieslabel second
-            seriesLabel=plan[seriesTag].value
-            if series.getLabel()==seriesLabel:
-                series.addFile(f)
-                continue
-
-            #add new series
-            if not series.getLabel()==None:
-                seriesList.append(dicomSeries())
-                series=seriesList[-1]
-
-            #set series parameters
-            series.addFile(f)
-            series.setLabel(seriesLabel)
-            for key in filter:
-                if not filter[key]==None:
-                    continue
-                v=plan[self.tag[key]].value
-                series.setMetadata(key,v)
-
-        return seriesList