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.

constructRegMaxSParFile.py 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # Ajayrama Kumaraswamy, 2017, LMU Munich
  2. """
  3. Description: This script is used to generate a parameter file required to run RegMaxS.py. This parameter file
  4. should contain a json string of a list of dictionaries. Each dictionary is one Reg-MaxS job that
  5. contains Reg-MaxS parameters. See core/RegMaxSPars.py for the description of the parameters.
  6. Usage: python <path to file>constructRegMaxSParFile.py
  7. Action: creates a parameter file for RegMaxS.py
  8. Usage guidelines: There are a couple of cases with examples shown below.
  9. Read the comments therein.
  10. Essentially edit the values of some variables in this script and run it.
  11. """
  12. from numpy import pi, deg2rad
  13. import os
  14. import json
  15. from regmaxsn.core.RegMaxSPars import RegMaxSParNames
  16. import pathlib as pl
  17. # obtaining the directory path containing the folder containing this file
  18. temp = os.path.split(os.path.abspath(__file__))[0]
  19. temp1 = os.path.split(temp)[0]
  20. # **********************************************************************************************************************
  21. # Default parameters
  22. # distances in um, angles in radians
  23. gridSizes = [40.0, 20.0, 10.0]
  24. transBounds = [[-30, 30], [-30, 30], [-30, 30]]
  25. transMinRes = 1
  26. rotBounds = [[-pi / 6, pi / 6], [-pi / 6, pi / 6], [-pi / 6, pi / 6]]
  27. rotMinRes = deg2rad(1).round(4)
  28. scaleBounds = [[0.5, 1 / 0.5], [0.5, 1 / 0.5], [0.5, 1 / 0.5]]
  29. minScaleStepSize = 1.005
  30. retainTempFiles = False
  31. inPartsDir = None
  32. outPartsDir = None
  33. nCPU = 6
  34. # **********************************************************************************************************************
  35. # # User defined parameters
  36. # # distances in um, angles in radians
  37. # gridSizes = [40.0, 20.0, 10.0]
  38. # transBounds = [[-30, 30], [-30, 30], [-30, 30]]
  39. # transMinRes = 1
  40. # rotBounds = [[-pi / 6, pi / 6], [-pi / 6, pi / 6], [-pi / 6, pi / 6]]
  41. # rotMinRes = deg2rad(1).round(4)
  42. # scaleBounds = [[0.5, 1 / 0.5], [0.5, 1 / 0.5], [0.5, 1 / 0.5]]
  43. # minScaleStepSize = 1.005
  44. # **********************************************************************************************************************
  45. # # Case 1: Default or user defined parameters above and
  46. # # refSWC: the reference SWC
  47. # # testSWC: the test SWC
  48. # # resFile: the registered version of testSWC will be written into this file path when RegMaxS.py is run with the
  49. # # parameter file generated by this script
  50. # # parFile: the parameter file will be generated at this file path.
  51. # # Usage: Replace refSWC, testSWC, resFile and parFile as required and run this file to generate parFile.
  52. # # Then run python <...>/RegMaxS.py parFile
  53. #
  54. # -------------------------------------------
  55. # # Example 1
  56. refSWC = os.path.join(temp1, 'TestFiles', 'HSN-fluoro01.CNG.swc')
  57. testSWC = os.path.join(temp1, 'TestFiles', 'HSN-fluoro01.CNGRandTrans1.swc')
  58. resFile = os.path.join(temp1, 'Results', 'Tests', 'HSN-fluoro01.CNGRandTrans1.swc')
  59. parFile = os.path.join(temp1, 'ParFiles', 'Reg-MaxS', 'HSN-fluoro01.CNGRandTrans1.json')
  60. # -------------------------------------------
  61. # # Example 2
  62. # refSWC = os.path.join(temp1, 'TestFiles', 'HSN-fluoro01.CNG.swc')
  63. # testSWC = os.path.join(temp1, 'TestFiles', 'HSN-fluoro01.CNGRandRot0.swc')
  64. # resFile = os.path.join(temp1, 'Results', 'Tests', 'HSN-fluoro01.CNGRandRot0.swc')
  65. # parFile = os.path.join(temp1, 'ParFiles', 'Reg-MaxS', 'HSN-fluoro01.CNGRandRot0.json')
  66. # -------------------------------------------
  67. # # Example 3
  68. # refSWC = os.path.join(temp1, 'TestFiles', 'HSN-fluoro01.CNG.swc')
  69. # testSWC = os.path.join(temp1, 'TestFiles', 'HSN-fluoro01.CNGRandTranslate0.swc')
  70. # resFile = os.path.join(temp1, 'Results', 'Tests', 'HSN-fluoro01.CNGRandTranslate0.swc')
  71. # parFile = os.path.join(temp1, 'ParFiles', 'Reg-MaxS', 'HSN-fluoro01.CNGRandTranslate0.json')
  72. # -------------------------------------------
  73. # # Example 4
  74. # refSWC = os.path.join(temp1, 'TestFiles', 'HSN-fluoro01.CNG.swc')
  75. # testSWC = os.path.join(temp1, 'TestFiles', 'HSN-fluoro01.CNGRandScale0.swc')
  76. # resFile = os.path.join(temp1, 'Results', 'Tests', 'HSN-fluoro01.CNGRandScale0.swc')
  77. # parFile = os.path.join(temp1, 'ParFiles', 'Reg-MaxS', 'HSN-fluoro01.CNGRandScale0.json')
  78. # -------------------------------------------
  79. # Example 5
  80. # refSWC = os.path.join(temp1, 'TestFiles', 'LLC', 'Gad1-F-000062.CNG.swc')
  81. # testSWC = os.path.join(temp1, 'TestFiles', 'LLC', 'Cha-F-400051.CNG.swc')
  82. # resFile = os.path.join(temp1, 'Results', 'Reg-MaxS', 'LLC', 'Cha-F-400051.CNG.swc')
  83. # parFile = os.path.join(temp1, 'ParFiles', 'Reg-MaxS', 'LLC1.json')
  84. # inPartsDir = os.path.join(temp1, 'TestFiles', 'LLC', 'Cha-F-400051.CNG')
  85. # outPartsDir = os.path.join(temp1, 'Results', 'Tests', 'LLC', 'Cha-F-400051.CNG')
  86. #
  87. # -------------------------------------------
  88. # # obtains the list of variables in the current work space
  89. ns = vars()
  90. # forms the dictionary of parameters to be saved into the parameter file.
  91. pars = [{k: ns[k] for k in RegMaxSParNames}]
  92. # **********************************************************************************************************************
  93. # # Case 2: Default or user defined parameters above, one reference SWC and several test SWCs, all in the same folder.
  94. # # dirPath: directory containing the reference SWC and the test SWCs
  95. # # refSWC: the reference SWC
  96. # # testSWCFiles: file names of test SWC files in dirPath
  97. # # parameter file generated by this script
  98. # # parFile: the parameter file will be generated at this file path.
  99. # # resPath: the testSWCs registered to the reference SWC will be generated in this directory when RegMaxS.py is run
  100. # # with the parameter file generated by this running this script.
  101. #
  102. # # Usage: Replace dirPath, refSWC, expNames, resPath and parFile as required and run this file to generate parFile
  103. # # Then run python <...>/RegMaxS.py parFile
  104. # -------------------------------------------
  105. # dirPath = os.path.join(temp1, 'TestFiles')
  106. # refSWC = os.path.join(dirPath, 'HSN-fluoro01.CNG.swc')
  107. # testSWCFiles = [
  108. # 'HSN-fluoro01.CNGRandTrans0.swc',
  109. # 'HSN-fluoro01.CNGRandTrans1.swc',
  110. # 'HSN-fluoro01.CNGRandTrans2.swc',
  111. # 'HSN-fluoro01.CNGRandTrans3.swc',
  112. # 'HSN-fluoro01.CNGRandTrans4.swc',
  113. # 'HSN-fluoro01.CNGRandTrans5.swc',
  114. # 'HSN-fluoro01.CNGRandTrans6.swc',
  115. # 'HSN-fluoro01.CNGRandTrans7.swc',
  116. # 'HSN-fluoro01.CNGRandTrans8.swc',
  117. # 'HSN-fluoro01.CNGRandTrans9.swc',
  118. # # 'HSN-fluoro01.CNGNoiseStd1RandTrans.swc',
  119. # # 'HSN-fluoro01.CNGNoiseStd2RandTrans.swc',
  120. # # 'HSN-fluoro01.CNGNoiseStd3RandTrans.swc',
  121. # # 'HSN-fluoro01.CNGNoiseStd4RandTrans.swc',
  122. # # 'HSN-fluoro01.CNGNoiseStd5RandTrans.swc',
  123. # # 'HSN-fluoro01.CNGNoiseStd6RandTrans.swc',
  124. # # 'HSN-fluoro01.CNGNoiseStd7RandTrans.swc',
  125. # # 'HSN-fluoro01.CNGNoiseStd8RandTrans.swc',
  126. # # 'HSN-fluoro01.CNGNoiseStd9RandTrans.swc',
  127. # ]
  128. # resPath = os.path.join(temp1, 'Results', 'Tests')
  129. # parFile = os.path.join(temp1, 'ParFiles', 'Reg-MaxS', 'HSN-fluoro01.CNGRandTrans0-9.json')
  130. #
  131. # pars = []
  132. # for sfr in testSWCFiles:
  133. # testSWC = os.path.join(dirPath, sfr)
  134. # resFile = os.path.join(resPath, sfr)
  135. # # obtains the list of variables in the current work space
  136. # ns = vars()
  137. # # forms the dictionary of parameters to be saved into the parameter file.
  138. # pars.append({k: ns[k] for k in RegMaxSParNames})
  139. # # -------------------------------------------
  140. # **********************************************************************************************************************
  141. # write the parameters into the parameter file.
  142. pl.Path(parFile).parent.mkdir(exist_ok=True)
  143. with open(parFile, 'w') as fle:
  144. json.dump(pars, fle)