Mercurial > hg > webaudioevaluationtool
comparison scripts/timeline_view.py @ 1065:b2492aeafe8b
Scripts: show which and how many markers not clicked or moved; option to plot timelines against 'audioholder time' (default) or 'total test time' (previously the only possibility)
author | Brecht De Man <BrechtDeMan@users.noreply.github.com> |
---|---|
date | Mon, 10 Aug 2015 18:45:45 +0200 |
parents | e67a76e9ba7a |
children | a2a245542ae6 |
comparison
equal
deleted
inserted
replaced
1064:99cb3436759e | 1065:b2492aeafe8b |
---|---|
29 plt.rc('font', **font) | 29 plt.rc('font', **font) |
30 | 30 |
31 # Colormap for to cycle through | 31 # Colormap for to cycle through |
32 colormap = ['b', 'r', 'g', 'c', 'm', 'y', 'k'] | 32 colormap = ['b', 'r', 'g', 'c', 'm', 'y', 'k'] |
33 | 33 |
34 # x-axis shows time per audioholder, not total test time | |
35 show_audioholder_time = True | |
36 | |
34 | 37 |
35 # CODE | 38 # CODE |
36 | 39 |
37 # create timeline_folder if not yet created | 40 # create timeline_folder if not yet created |
38 if not os.path.exists(timeline_folder): | 41 if not os.path.exists(timeline_folder): |
42 for file in os.listdir(folder_name): | 45 for file in os.listdir(folder_name): |
43 if file.endswith(".xml"): | 46 if file.endswith(".xml"): |
44 tree = ET.parse(folder_name + '/' + file) | 47 tree = ET.parse(folder_name + '/' + file) |
45 root = tree.getroot() | 48 root = tree.getroot() |
46 subject_id = file[:-4] # drop '.xml' | 49 subject_id = file[:-4] # drop '.xml' |
50 | |
51 time_offset = 0 # test starts at zero | |
47 | 52 |
48 # ONE TIMELINE PER PAGE - make new plot per page | 53 # ONE TIMELINE PER PAGE - make new plot per page |
49 | 54 |
50 # get list of all page names | 55 # get list of all page names |
51 for audioholder in root.findall("./audioholder"): # iterate over pages | 56 for audioholder in root.findall("./audioholder"): # iterate over pages |
76 | 81 |
77 # for this audioelement, loop over all listen events | 82 # for this audioelement, loop over all listen events |
78 listen_events = audioelement.findall("./metric/metricresult/[@name='elementListenTracker']/event") | 83 listen_events = audioelement.findall("./metric/metricresult/[@name='elementListenTracker']/event") |
79 for event in listen_events: | 84 for event in listen_events: |
80 # get testtime: start and stop | 85 # get testtime: start and stop |
81 start_time = event.find('testtime').get('start') | 86 start_time = float(event.find('testtime').get('start')) |
82 stop_time = event.find('testtime').get('stop') | 87 stop_time = float(event.find('testtime').get('stop')) |
83 # event lines: | 88 # event lines: |
84 plt.plot([start_time, start_time], # x-values | 89 plt.plot([start_time-time_offset, start_time-time_offset], # x-values |
85 [0, N_audioelements+1], # y-values | 90 [0, N_audioelements+1], # y-values |
86 color='k' | 91 color='k' |
87 ) | 92 ) |
88 plt.plot([stop_time, stop_time], # x-values | 93 plt.plot([stop_time-time_offset, stop_time-time_offset], # x-values |
89 [0, N_audioelements+1], # y-values | 94 [0, N_audioelements+1], # y-values |
90 color='k' | 95 color='k' |
91 ) | 96 ) |
92 # plot time: | 97 # plot time: |
93 plt.plot([start_time, stop_time], # x-values | 98 plt.plot([start_time-time_offset, stop_time-time_offset], # x-values |
94 [N_audioelements-increment, N_audioelements-increment], # y-values | 99 [N_audioelements-increment, N_audioelements-increment], # y-values |
95 color=colormap[increment%len(colormap)], | 100 color=colormap[increment%len(colormap)], |
96 linewidth=6 | 101 linewidth=6 |
97 ) | 102 ) |
98 | 103 |
99 increment+=1 | 104 increment+=1 |
105 | |
106 # subtract total audioholder length from subsequent audioholder event times | |
107 audioholder_time = audioholder.find("./metric/metricresult/[@id='testTime']") | |
108 if audioholder_time is not None and show_audioholder_time: | |
109 time_offset = float(audioholder_time.text) | |
100 | 110 |
101 #TODO: if 'nonsensical' or unknown: dashed line until next event | 111 #TODO: if 'nonsensical' or unknown: dashed line until next event |
102 #TODO: Vertical lines for fragment looping point | 112 #TODO: Vertical lines for fragment looping point |
103 | 113 |
104 plt.title('Timeline ' + file) #TODO add song too | 114 plt.title('Timeline ' + file) #TODO add song too |