4 1) Read -R json_GT* and recup "Feature Refs" & labels (0: Infarctus, 1: No
5 2) store "Feature Refs" & labels
13 from os import listdir as ls
14 from os.path import getsize as size, join
15 from pprint import pprint
19 # json OLD may be it was just a separation for the copy, new -> no more that, stay in one directory
22 RT_PATH = '../../Data/Contours_updated/'
23 JSON_GTS = ['json_GT']
24 INFA_STR = 'Infarction'
26 ENDO_STR = 'Endocardic'
33 from os.path import isfile, join
35 def search(path, name, recursive=True, fsize=True):
39 :param recursive: Recursive or not
40 :param fsize: show the size of not
41 :return: {path: p, size: None}
46 return {'path': p, 'size': size(p) if fsize else None}
47 elif recursive and not isfile(p):# only enter if it's a directory
48 res = search(p, name)# stop if found
52 def merge(dirlist, root='', indice='Case'):
55 l += [e for e in ls(join(root, d)) if indice in e]
60 return merge(JSON_GTS, RT_PATH)
64 fill l with features references
65 use JSON_GTS, a little bit static in this sens
70 # #frefs += ls(RT_PATH + d)
71 # featurerefs += [e for e in ls(join(RT_PATH, d)) if "Case" in e]
73 featurerefs = sorted(mergejsons())
76 res = search(RT_PATH, fref)
77 b = search(res['path'], INFA_STR)
78 return (0, b['size']) if b else (1, None)
81 global labellist, details
82 for name in featurerefs:
83 lab, detail = label(name)
85 details.append(detail)
89 if __name__ == '__main__':
93 print('featurerefs:', len(featurerefs), featurerefs)
94 print('labels:', len(labellist), labellist)
95 print('details:', len(details), details)
97 # print( label('Case_02') )
98 # print( search(RT_PATH, INFA_STR) )