Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

constructPCABasedRegParFile.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # Ajayrama Kumaraswamy, 2017, LMU Munich
  2. """
  3. Description: This script is used to generate a parameter file required to run pcaBased.py. This parameter file
  4. should contain a json string of a list of dictionaries. Each dictionary is one 'pcaBased' job
  5. that contains 'pcaBased' parameters.
  6. See core/RegMaxSPars.py for the description of the parameters.
  7. Usage: python constructPCABasedRegParFile.py
  8. Action: creates a parameter file for pcaBased.py
  9. Usage guidelines: There are a couple of cases with examples shown below.
  10. Read the comments therein.
  11. Essentially edit the values of some variables in this script and run it.
  12. """
  13. import os
  14. import json
  15. from regmaxsn.core.RegMaxSPars import pcaBasedParNames
  16. temp = os.path.split(os.path.abspath(__file__))[0]
  17. temp1 = os.path.split(temp)[0]
  18. # **********************************************************************************************************************
  19. # Default parameters
  20. # distances in um, angles in radians
  21. gridSizes = [40.0, 20.0, 10.0]
  22. usePartsDir = True
  23. # **********************************************************************************************************************
  24. # # User defined parameters
  25. # # distances in um, angles in radians
  26. # gridSizes = [40.0, 20.0, 10.0]
  27. # usePartsDir = False
  28. # **********************************************************************************************************************
  29. # # Case 1: Default or user defined parameters above and
  30. # # refSWC: the reference SWC
  31. # # testSWC: the test SWC
  32. # # resFile: the registered version of testSWC will be written into this file path when RegMaxS.py is run with the
  33. # # parameter file generated by this script
  34. # # parFile: the parameter file will be generated at this file path.
  35. # # Usage: Replace refSWC, testSWC, resFile and parFile as required and run this file to generate parFile
  36. # # Then run python <...>/pcaBased.py parFile
  37. #
  38. # refSWC = os.path.join(temp1, 'TestFiles', 'HSNR', 'HSN-fluoro01.CNG.swc')
  39. # testSWC = os.path.join(temp1, 'TestFiles', 'HSNR', 'HSN-fluoro04.CNG.swc')
  40. # resFile = os.path.join(temp1, 'Results', 'PCABased', 'HSNR', 'HSN-fluoro04.CNG.swc')
  41. # parFile = os.path.join(temp1, 'ParFiles', 'PCABased', 'HSNR1-4.json')
  42. #
  43. #
  44. # obtains the list of variables in the current work space
  45. # ns = vars()
  46. # forms the dictionary of parameters to be saved into the parameter file.
  47. # pars = [{k: ns[k] for k in pcaBasedParNames}]
  48. # **********************************************************************************************************************
  49. # # Case 2: Default or user defined parameters above, one reference SWC and several test SWCs, all in the same folder.
  50. # # dirPath: directory containing the reference SWC and the test SWCs
  51. # # refSWC: the reference SWC
  52. # # testSWCFiles: file names of test SWC files in dirPath
  53. # # parameter file generated by this script
  54. # # parFile: the parameter file will be generated at this file path.
  55. # # resPath: the testSWCs registered to the reference SWC will be generated in this directory when RegMaxS.py is run
  56. # # with the parameter file generated by this running this script.
  57. # # Usage: Replace dirPath, refSWC, expNames, resPath and parFile as required and run this file to generate parFile
  58. # # Then run python <...>/pcaBased.py parFile
  59. # -----------------------------------------------------------------------------------
  60. # dirPath = os.path.join(temp1, 'TestFiles', 'HSNR')
  61. # refSWC = os.path.join(dirPath, 'HSN-fluoro01.CNG.swc')
  62. # expNames = [
  63. # 'HSN-fluoro01.CNG',
  64. # 'HSN-fluoro04.CNG',
  65. # 'HSN-fluoro05.CNG',
  66. # 'HSN-fluoro07.CNG',
  67. # 'HSN-fluoro09.CNG',
  68. # ]
  69. # resPath = os.path.join(temp1, 'Results', 'PCABased', 'HSNR')
  70. # parFile = os.path.join(temp1, 'ParFiles', 'PCABased', 'HSNR.json')
  71. #
  72. # pars = []
  73. # for sfr in expNames:
  74. # testSWC = os.path.join(dirPath, sfr + '.swc')
  75. # resFile = os.path.join(resPath, sfr + '.swc')
  76. # # obtains the list of variables in the current work space
  77. # ns = vars()
  78. # # forms the dictionary of parameters to be saved into the parameter file.
  79. # pars.append({k: ns[k] for k in pcaBasedParNames})
  80. # -----------------------------------------------------------------------------------
  81. # dirPath = os.path.join(temp1, 'TestFiles', 'HSNL')
  82. # refSWC = os.path.join(dirPath, 'HSN-fluoro02.CNG.swc')
  83. # expNames = [
  84. # 'HSN-fluoro02.CNG',
  85. # 'HSN-fluoro03.CNG',
  86. # 'HSN-fluoro06.CNG',
  87. # 'HSN-fluoro08.CNG',
  88. # 'HSN-fluoro10.CNG',
  89. # ]
  90. # resPath = os.path.join(temp1, 'Results', 'PCABased', 'HSNL')
  91. # parFile = os.path.join(temp1, 'ParFiles', 'PCABased', 'HSNL.json')
  92. #
  93. # pars = []
  94. # for sfr in expNames:
  95. # testSWC = os.path.join(dirPath, sfr + '.swc')
  96. # resFile = os.path.join(resPath, sfr + '.swc')
  97. # # obtains the list of variables in the current work space
  98. # ns = vars()
  99. # # forms the dictionary of parameters to be saved into the parameter file.
  100. # pars.append({k: ns[k] for k in pcaBasedParNames})
  101. # # -----------------------------------------------------------------------------------
  102. dirPath = os.path.join(temp1, 'TestFiles', 'LLC')
  103. refSWC = os.path.join(dirPath, 'Gad1-F-000062.CNG.swc')
  104. expNames = [
  105. 'Gad1-F-000062.CNG',
  106. 'Cha-F-000012.CNG',
  107. 'Cha-F-300331.CNG',
  108. 'Gad1-F-600000.CNG',
  109. 'Cha-F-000018.CNG',
  110. 'Cha-F-300051.CNG',
  111. 'Cha-F-400051.CNG',
  112. 'Cha-F-200000.CNG'
  113. ]
  114. resPath = os.path.join(temp1, 'Results', 'PCABased', 'LLC')
  115. parFile = os.path.join(temp1, 'ParFiles', 'PCABased', 'LLC.json')
  116. pars = []
  117. for sfr in expNames:
  118. testSWC = os.path.join(dirPath, sfr + '.swc')
  119. resFile = os.path.join(resPath, sfr + '.swc')
  120. # obtains the list of variables in the current work space
  121. ns = vars()
  122. # forms the dictionary of parameters to be saved into the parameter file.
  123. pars.append({k: ns[k] for k in pcaBasedParNames})
  124. # -----------------------------------------------------------------------------------
  125. # **********************************************************************************************************************
  126. # write the parameters into the parameter file.
  127. with open(parFile, 'w') as fle:
  128. json.dump(pars, fle)