-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathparse_registration_json.py
executable file
·91 lines (73 loc) · 2.6 KB
/
parse_registration_json.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
import json
class ParserRegistrationJson:
def __init__(self,filename):
self.filename = filename
self.dict = None
self.version = None
self.method = None
self.studies = None
self.ToProcess = None
self.study_filenames = None
self.output_path= None
self.do_affine = True
self.do_deformable = None
self.fast_execution= None
self.use_imaging_constraints = None
self.do_reconstruction = None
self.ReadJson()
def ReadJson(self):
with open(self.filename) as f:
self.dict = json.load(f)
try:
self.version = self.dict['version']
except Exception as e:
print(e)
try:
self.method = self.dict['method']
try:
self.do_affine = self.dict['method']['do_affine']
except Exception as e:
print(e)
try:
self.do_deformable = self.dict['method']['do_deformable']
except Exception as e:
print(e)
try:
self.do_reconstruction = self.dict['method']['do_reconstruction']
except Exception as e:
print(e)
try:
self.fast_execution = self.dict['method']['fast_execution']
except Exception as e:
print(e)
try:
self.use_imaging_constraints = self.dict['method']['use_imaging_constraints']
except Exception as e:
print(e)
except Exception as e:
print(e)
try:
self.study_filenames = self.dict['studies']
self.studies = {}
for s in self.study_filenames:
fn = self.study_filenames[s]
try:
print("Reading", s, "Study Json",fn)
with open(fn) as fs:
studyDict = json.load(fs)
self.studies[s]=studyDict
except Exception as ee:
print(ee)
except Exception as e:
print(e)
try:
self.output_path = self.dict['output_path']
except Exception as e:
print(e)
try:
self.ToProcess = self.dict['studies2process']
except Exception as e:
print(e)
def PrintJson(self):
for d in self.dict:
print(d,self.dict[d])