RegMaxS.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import sys
  2. from regmaxsn.core.iterativeRegistration import IterativeRegistration
  3. from regmaxsn.core.misc import parFileCheck
  4. import os
  5. def runRegMaxS(parFile, parNames):
  6. parsList = parFileCheck(parFile, parNames)
  7. for pars in parsList:
  8. print('Current Parameters:')
  9. for parN, parV in pars.iteritems():
  10. print('{}: {}'.format(parN, parV))
  11. resFile = pars['resFile']
  12. refSWC = pars['refSWC']
  13. testSWC = pars['testSWC']
  14. if os.path.isfile(resFile):
  15. ch = raw_input('File exists: ' + resFile + '\nDelete(y/n)?')
  16. if ch == 'y':
  17. os.remove(resFile)
  18. else:
  19. quit()
  20. resDir = os.path.split(resFile)[0]
  21. if not os.path.exists(resDir):
  22. raise(ValueError('Could not create result file in specified directory: {}'.format(resDir)))
  23. assert os.path.isfile(refSWC), 'Could not find {}'.format(refSWC)
  24. assert os.path.isfile(testSWC), 'Could not find {}'.format(testSWC)
  25. iterReg = IterativeRegistration(refSWC=pars['refSWC'],
  26. gridSizes=pars['gridSizes'],
  27. rotBounds=pars['rotBounds'],
  28. transBounds=pars['transBounds'],
  29. transMinRes=pars['transMinRes'],
  30. scaleMinRes=pars['minScaleStepSize'],
  31. rotMinRes=pars['rotMinRes'],
  32. nCPU=pars['nCPU'])
  33. iterReg.performReg(SWC2Align=pars['testSWC'],
  34. resFile=pars['resFile'],
  35. scaleBounds=pars['scaleBounds'],
  36. inPartsDir=pars['inPartsDir'],
  37. outPartsDir=pars['outPartsDir'],
  38. retainTempFiles=pars['retainTempFiles'])
  39. if __name__ == '__main__':
  40. from regmaxsn.core.RegMaxSPars import RegMaxSParNames
  41. assert len(sys.argv) == 2, 'Improper usage! Please use as \'python RegMaxS.py parFile\''
  42. parFile = sys.argv[1]
  43. runRegMaxS(parFile, RegMaxSParNames)