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
22 RT_PATH = '../../Data/json/'
23 JSON_GTS = ['json_GT', 'json_GT_part2']
31 from os.path import isfile, join
33 def search(path, name, recursive=True, fsize=True):
37 :param recursive: Recursive or not
38 :param fsize: show the size of not
39 :return: {path: p, size: None}
44 return {'path': p, 'size': size(p) if fsize else None}
45 elif recursive and not isfile(p):# only enter if it's a directory
46 res = search(p, name)# stop if found
50 def merge(dirlist, root='', indice='Case'):
53 l += [e for e in ls(join(root, d)) if indice in e]
58 return merge(JSON_GTS, RT_PATH)
62 fill l with features references
63 use JSON_GTS, a little bit static in this sens
68 # #frefs += ls(RT_PATH + d)
69 # featurerefs += [e for e in ls(join(RT_PATH, d)) if "Case" in e]
71 featurerefs = sorted(mergejsons())
74 res = search(RT_PATH, fref)
75 b = search(res['path'], INFA_STR)
76 return (0, b['size']) if b else (1, None)
79 global labellist, details
80 for name in featurerefs:
81 lab, detail = label(name)
83 details.append(detail)
87 if __name__ == '__main__':
91 print('featurerefs:', len(featurerefs), featurerefs)
92 print('labels:', len(labellist), labellist)
93 print('details:', len(details), details)
95 # print( label('Case_02') )
96 # print( search(RT_PATH, INFA_STR) )