12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import os
- import sys
- import config
- def getDataset(db,setup,datasetName,qfilter=[]):
- ds=db.selectRows(setup['project'],setup['schemaName'],\
- setup[datasetName],qfilter)
- try:
- rows=ds['rows']
- except KeyError:
- rows=[]
- return rows
- def updateDataset(db,setup,datasetName,mode,rows):
- db.modifyRows(mode,setup['project'],setup['schemaName'],\
- setup[datasetName],rows)
-
- def getPatients(db,setup,qfilter=[]):
- return getDataset(db,setup,'queryName',qfilter)
- def getSegmentation(db,setup,qfilter=[]):
- return getDataset(db,setup,'segmentationQueryName',qfilter)
- def getSummary(db,setup,qfilter=[]):
- return getDataset(db,setup,'summaryQueryName',qfilter)
- def updatePatients(db,setup,mode,rows):
- updateDataset(db,setup,'queryName',mode,rows)
- def updateSegmentation(db,setup,mode,rows):
- updateDataset(db,setup,'segmentationQueryName',mode,rows)
- def updateSummary(db,setup,mode,rows):
- updateDataset(db,setup,'summaryQueryName',mode,rows)
- def downloadNode(fb,fileName,rPath,lPath):
- rPath1=rPath+'/'+fileName
- available=fb.entryExists(rPath1)
- if not available:
- print('Missing {}'.format(fileName))
- return
- lPath1=os.path.join(lPath,fileName)
- if os.path.isfile(lPath1):
- return
- print('Loading {}'.format(fileName))
- fb.readFileToFile(rPath1,lPath1)
-
- def downloadFiles(fb,r,setup):
- rPath=fb.formatPathURL(setup['project'],config.getOutputDir(r,setup))
- lPath=config.getLocalDir(r,setup)
- if not os.path.isdir(lPath):
- os.makedirs(lPath)
-
- #CT
- fileName=config.getNodeName(r,setup,'CT')+'.nrrd'
- downloadNode(fb,fileName,rPath,lPath)
-
- for i in range(20):
- fileName=config.getNodeName(r,setup,'NM',i)+'.nrrd'
- downloadNode(fb,fileName,rPath,lPath)
-
- fileName=config.getNodeName(r,setup,'Dummy')+'.mcsv'
- downloadNode(fb,fileName,rPath,lPath)
-
- def downloadPatientFiles(db,fb,setup):
- rows=getPatients(db,setup)
- for r in rows:
- #download
- downloadFiles(fb,r,setup)
-
|