-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathreconstruct.py
68 lines (49 loc) · 1.76 KB
/
reconstruct.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
import argparse
import json
import os
import sys
sys.path.append(f"..{os.sep}..")
from core.Reconstruction import Reconstruction
acquisition_json_path = "../../conf/acquisition_parameters.json"
def read_json():
with open(acquisition_json_path, "r") as file:
acquisition_json_object = json.load(file)
return acquisition_json_object
def write_json(acquisition_json_object):
with open(acquisition_json_path, "w") as file:
json.dump(acquisition_json_object, file, indent=4)
def check_args(args):
acquisition_json_object = read_json()
print("\n")
for arg in vars(args):
value = getattr(args, arg)
if value is None:
# change argparser value per json value
print("-" * 100)
print(
f"{arg} not specified by user. Default value {acquisition_json_object[arg]} taken from conf/acquisition_parameters.json"
)
else:
acquisition_json_object[f"{arg}"] = value
print("-" * 100)
print("\n")
write_json(acquisition_json_object)
def main():
parser = argparse.ArgumentParser(
description="ONE-PIX reconstruction command line script",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("-n", "--filename", type=str, help="filename to save a reconstructed data")
parser.add_argument("-p", "--save_path", type=int, help="save path ")
args = parser.parse_args()
#check_args(args)
print("ONE-PIX reconstruction begginning")
print("-" * 100)
rec = Reconstruction()
rec.data_reconstruction()
rec.save_reconstructed_image(args.filename,args.save_path)
print("reconstruction completed !")
print("-" * 100)
print("\n")
if __name__ == "__main__":
main()