示例#1
0
def copyFiles(serie):
    logging.debug("In Importer::copyFiles()")
    basePath = os.path.join(constant.INSTALL_DIR, "data")
    patientPath = os.path.join(basePath, hashStr(serie["patientUID"]))
    seriePath = os.path.join(patientPath,"{0}{1}".format(hashStr(serie["uid"]), hashStr(serie["serieDescription"])))
    imagePath = os.path.join(patientPath,hashStr(serie["uid"]), "images/")
    serie["path"] = seriePath
    serie["patientPath"] = patientPath
    if not os.path.exists(imagePath):
        os.makedirs(imagePath)
    for i, dicomPath in enumerate(serie["files"]):
        filePath = os.path.join(imagePath, "{0}.dcm".format(i))
        shutil.copy(dicomPath, filePath)
示例#2
0
def createYAMLFile(serie):
    logging.debug("In Importer::createYAMLFile()")
    outputFile = os.path.join(serie["path"], "{0}{1}".format(hashStr(serie["uid"]), ".yaml"))
    serie["yaml"] = os.path.join(
                        "{0}{1}".format(hashStr(serie["uid"]), hashStr(serie["serieDescription"])), 
                        "{0}{1}".format(hashStr(serie["uid"]),".yaml"))
    vtiPath  = "{0}{1}/main/main.vti".format(hashStr(serie["uid"]),hashStr(serie["serieDescription"]))
    matrix = [[1, 0, 0, 0],
              [0, 1, 0, 0],
              [0, 0, 1, 0],
              [0, 0, 0, 1]]
    mScreens = [] 
    save = {"vti": vtiPath,
            "mScreens" : mScreens}
    mScreens.append({"name": QtGui.QApplication.translate("Importer", 
                                                     "Main", 
                                                     None, 
                                                     QtGui.QApplication.UnicodeUTF8)})

    f = file(outputFile, "w")
    yaml.dump(save, f)   
    f.close()