doPixelAnalysis.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import analysis
  2. import sys
  3. import os
  4. import getData
  5. import json
  6. import config
  7. import segmentation
  8. def main(configFile):
  9. with open(configFile,'r') as f:
  10. xsetup=json.load(f)
  11. db,fb=getData.connectDB(xsetup['network'])
  12. qfilter=config.getFilter(xsetup)
  13. rows=getData.getPatients(db,xsetup,qfilter)
  14. mode=['global','IVF']
  15. print('doPixelAnalysis...starting')
  16. for r in rows:
  17. segmentation.loadSegmentation(db,fb,r,xsetup)
  18. getData.downloadCenters(fb,r,xsetup)
  19. for m in mode:
  20. getData.downloadFitParFinal(fb,r,xsetup,m)
  21. pixelFitMode='IVF'
  22. for r in rows:
  23. code=config.getCode(r,xsetup)
  24. nc=segmentation.getNC(r,xsetup)
  25. files=[]
  26. for s2 in xsetup['sigma2']:
  27. files.extend(config.printPixelFitParFinalRowNames(r,xsetup,nc,s2,pixelFitMode))
  28. fullFiles=[getData.getLocalPath(r,xsetup,f) for f in files]
  29. print(fullFiles)
  30. filesPresent=[os.path.isfile(f) for f in fullFiles]
  31. print(filesPresent)
  32. #check if we need to run analysis
  33. if not all(filesPresent):
  34. analysis.doPixelAnalysisRow(db,r,xsetup)
  35. getData.copyToServer(fb,r,xsetup,files)
  36. getData.updateStatus(db,r,xsetup,'doPixelAnalysis')
  37. #
  38. #getData.uploadPixelFitParFinal(fb,r,xsetup,pixelFitMode)
  39. if __name__=="__main__":
  40. main(sys.argv[1])