-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrecon.py
93 lines (87 loc) · 3.69 KB
/
recon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!python
'''
usage: recon.py [-h] [-c CONFIG] [-g GPU]
single thread hedm reconstruction
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
config file, .yml ,.yaml, h5, hdf5
-g GPU, --gpu GPU which gpu to use(0-4)
'''
import sys
sys.path.insert(0, '/home/heliu/work/dev/v0.2/HEXOMAP/')
import numpy as np
import os
import hexomap
from hexomap import reconstruction # g-force caller
from hexomap import MicFileTool # io for reconstruction rst
from hexomap import IntBin # io for binary image (reduced data)
from hexomap import config
import argparse
################# configuration #########################
Au_Config={
'micsize' : np.array([20, 20]),
'micVoxelSize' : 0.01,
'micShift' : np.array([0.0, 0.0, 0.0]),
'micMask' : None,
'expdataNDigit' : 6,
'energy' : 65.351, #55.587 # in kev
'sample' : 'gold',
'maxQ' : 9,
'etalimit' : 81 / 180.0 * np.pi,
'NRot' : 180,
'NDet' : 2,
'searchBatchSize' : 6000,
'reverseRot' : True, # for aero, is True, for rams: False
'detNJ': np.array([2048, 2048]),
'detNK': np.array([2048, 2048]),
'detPixelJ': np.array([0.00148, 0.00148]),
'detPixelK': np.array([0.00148, 0.00148]),
'detL' : np.array([[4.53571404, 6.53571404]]),
'detJ' : np.array([[1010.79405782, 1027.43844558]]),
'detK' : np.array([[2015.95118521, 2014.30163539]]),
'detRot' : np.array([[[89.48560133, 89.53313565, -0.50680978],
[89.42516322, 89.22570012, -0.45511278]]]),
'fileBin' : os.path.abspath(os.path.join(hexomap.__file__ ,"../..")) + '/examples/johnson_aug18_demo/Au_reduced_1degree/Au_int_1degree_suter_aug18_z',
'fileBinDigit' : 6,
'fileBinDetIdx' : np.array([0, 1]),
'fileBinLayerIdx' : 0,
'_initialString' : 'demo_gold_single_GPU'}
def main():
parser = argparse.ArgumentParser(description='single thread hedm reconstruction')
parser.add_argument('-c','--config', help='config file, .yml ,.yaml, h5, hdf5', default="no config")
parser.add_argument('-g','--gpu', help='which gpu to use(0-4)', default="0")
parser.add_argument('-r','--reconstructor_config', help='reconstructor config file, .yml ,.yaml, h5, hdf5', default="no config")
args = vars(parser.parse_args())
gpu=args['gpu']
print(gpu, args['config'])
if args['config'].endswith(('.yml','.yaml','h5','hdf5')):
c = config.Config().load(args['config'])
print(c)
print(f'===== loaded external config file: {sys.argv[1]} =====')
else:
c = config.Config(**Au_Config)
print(c)
print('============ loaded internal config ===================')
if args['reconstructor_config'].endswith(('.yml','.yaml','h5','hdf5')):
c_reconstructor = config.Config().load(args['reconstructor_config'])
print(c_reconstructor)
print(f"===== loaded external reconstructor config file: {args['reconstructor_config']} =====")
else:
c_reconstructor = None
print('============ loaded default reconstructor config ===================')
################# reconstruction #########################
try:
S.clean_up()
except NameError:
pass
S = reconstruction.Reconstructor_GPU(gpuID=gpu) # each run should contain just one reconstructor instance, other wise GPU memory may not be released correctly.
if c_reconstructor is not None:
S.load_reconstructor_config(c_reconstructor)
for i in range(1):
S.load_config(c)
S.serial_recon_multi_stage()
################# visualization #########################
#MicFileTool.plot_mic_and_conf(S.squareMicData, 0.5)
if __name__=="__main__":
main()