Browse Source

Minor changes

Andrej Studen 5 years ago
parent
commit
b87c546f7c
1 changed files with 30 additions and 23 deletions
  1. 30 23
      dataExplorer/exportDicom.py

+ 30 - 23
dataExplorer/exportDicom.py

@@ -272,7 +272,7 @@ class exportDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic
 
 
 
-  def exportNode(self,net, project,volumeNode,metadata):
+  def generateDicom(self, volumeNode, metadata, fdir):
 
        cliparameters={}
        tagList=['patientName','patientComments','studyDate','studyTime','studyDescription',
@@ -292,6 +292,31 @@ class exportDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic
            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('/','\\')
@@ -309,7 +334,6 @@ class exportDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic
        if not net.isRemoteDir(remoteDir):
             net.mkdir(remoteDir)
 
-
        dirName=volumeNode.GetName();
        dirName=dirName.replace(" ","_")
        fdir=os.path.join(fdir,dirName)
@@ -317,31 +341,14 @@ class exportDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic
        if not os.path.isdir(fdir):
            os.mkdir(fdir)
 
-       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
-
        relDir=net.GetRelativePathFromLocalPath(fdir)
        remoteDir=net.GetLabkeyPathFromRelativePath(relDir)
 
        if not net.isRemoteDir(remoteDir):
-           net.mkdir(remoteDir)
+            net.mkdir(remoteDir)
+
+       if not self.generateDicom(volumeNode,metadata,fdir):
+           return
 
        for f in os.listdir(fdir):
            localPath=os.path.join(fdir,f)