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
#!/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
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("")
D = d["all_nested_funcs_dic"]
chs_regs = list(D.keys())
i = 0
main_reg = None
reg_structure = {}
for subdir, dirs, files in os.walk(path):
if not i:
i += 1
#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'):
tmp = line2[-1].rsplit('_',1)[0]
#print(line2[-1].rsplit('_', 1))
if tmp not in call_list and tmp != 'init':
if main_reg is None and line.endswith('init_0'):
main_reg = subdir.split('/')[-1]
reg_structure[subdir.split('/')[-1]] = call_list
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')
if k in chs_regs:
n = pydot.Node(k, style = 'filled', fillcolor = '#fff000', shape = 'rectangle')
n = pydot.Node(k, style = 'filled', fillcolor = '#d5e4f5', shape = 'rectangle')
for k,v in reg_structure.items():
for e in v:
G.add_edge(pydot.Edge(e,k, arrowsize = 0.5))
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.legend(handles = [selp,uselp,mainp],loc="upper left",bbox_to_anchor=(0,1.4),fontsize = 'small')
if __name__=='__main__':
#tree_img = mpimg.imread('test_tree.png')
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