Explorar o código

Wrapping time code generator in a separate function

Andrej Studen %!s(int64=5) %!d(string=hai) anos
pai
achega
1018bbbb4f
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      DICOMtools/exportDicom.py

+ 8 - 5
DICOMtools/exportDicom.py

@@ -234,15 +234,12 @@ class exportDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic
         f.write("{}".format(id))
         f.close()
         return forId
-
+  
   def generateSeriesUUID(self,type,baseUUID):
 
         x=datetime.datetime.now()
-        hour=x.strftime("%H")
-        hour=re.sub('^0','',hour)
-        ft=hour+x.strftime("%M%S")
         seriesInstanceUid=baseUUID+'.'+self.labelUUID['series']+'.'
-        seriesInstanceUid+=self.dataUUID[type]+'.'+x.strftime("%Y%m%d")+'.'+ft
+        seriesInstanceUid+=self.dataUUID[type]+'.'+x.strftime("%Y%m%d")+'.'+getTimeCode(x)
         return seriesInstanceUid
 
   def setAttribute(self,shn,itemId,label,metadata):
@@ -410,3 +407,9 @@ class exportDicomLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic
            remotePath=net.GetLabkeyPathFromRelativePath(relativePath)
            print("remotePath: {}").format(relativePath)
            net.copyLocalFileToRemote(localPath,remotePath)
+
+def getTimeCode(x):
+    hour=x.strftime("%H")
+    hour=re.sub('^0','',hour)
+    return hour+x.strftime("%M%S")
+