Commit 021b8e47 authored by ulc0011's avatar ulc0011

ENH: Highliting selected regions in tree, added legend to tree, average start...

ENH: Highliting selected regions in tree, added legend to tree, average start per region tables added, changed tables design
parent d223e62e
This diff is collapsed.
......@@ -105,6 +105,7 @@ class Window(QtWidgets.QDialog):
def change_sw(self):
self.sw = not self.sw
self.plot()
#pp.pprint(self.plot_data)
......
#!/usr/bin/env python3
import pydot
import matplotlib
from packaging import version
if version.parse(matplotlib.__version__) < version.parse("2.0.3"):
raise Exception("Matplotlib version must be >= 2.0.3, while yours is {}!".format(matplotlib.__version__))
from matplotlib import pyplot as pp
pp.switch_backend('Qt5Agg')
from matplotlib import image as mpimg
from matplotlib import patches as mp
import os
from runpy import run_path
import pprint
ppr = pprint.PrettyPrinter(indent=4)
def browse_dir(path):
d = run_path("get_data_for_gui.py")
D = d["all_nested_funcs_dic"]
chs_regs = list(D.keys())
ppr.pprint(chs_regs)
i = 0
main_reg = None
reg_structure = {}
for subdir, dirs, files in os.walk(path):
if not i:
i += 1
continue
#print(subdir.split('/')[-1], '{}/{}'.format(subdir,files[0]))
call_list = []
with open('{}/{}'.format(subdir,files[0])) as f:
for line in f:
line = line.strip()
line2 = line.split(';')
if line.startswith('# CALLTREE'):
#print(line)
#print(line2)
tmp = line2[-1].rsplit('_',1)[0]
#print(line2[-1].rsplit('_', 1))
#print(tmp)
if tmp not in call_list and tmp != 'init':
call_list.append(tmp)
#print(line.endswith('init_0'))
if main_reg is None and line.endswith('init_0'):
main_reg = subdir.split('/')[-1]
reg_structure[subdir.split('/')[-1]] = call_list
##print(reg_structure)
G = pydot.Dot(graph_type='digraph',dpi=400)
for k in reg_structure.keys():
if k == main_reg:
n = pydot.Node(k, style = '"rounded,filled"', fillcolor = '#ccaaff', shape = 'rectangle')
else:
if k in chs_regs:
n = pydot.Node(k, style = 'filled', fillcolor = '#fff000', shape = 'rectangle')
else:
n = pydot.Node(k, style = 'filled', fillcolor = '#d5e4f5', shape = 'rectangle')
G.add_node(n)
for k,v in reg_structure.items():
for e in v:
G.add_edge(pydot.Edge(e,k, arrowsize = 0.5))
G.write_png(os.path.abspath('../../output/pokus.png'))
tree_img = mpimg.imread(os.path.abspath('../../output/pokus.png'))
uselp = mp.Patch(color = '#d5e4f5', label = 'Unselected regions')
selp = mp.Patch(color = '#fff000', label = 'Selected regions')
mainp = mp.Patch(color = '#ccaaff', label = 'Main region')
pp.imshow(tree_img)
pp.legend(handles = [selp,uselp,mainp],loc="upper left",bbox_to_anchor=(0,1.4),fontsize = 'small')
pp.axis('off')
pp.show()
##print(main_reg)
if __name__=='__main__':
browse_dir('/home/david/SGS18-READEX/DATA/KRIPKE')
#plot_tree(tree,'test_tree')
#plot_test('test_tree')
#tree_img = mpimg.imread('test_tree.png')
#pp.imshow(tree_img)
#pp.axis('off')
#pp.show()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment