Mercurial > hg > webaudioevaluationtool
diff scripts/timeline_view.py @ 288:a00d0c8d5c74
Scripts: modification to timeline plots: do not save (/show) plot if empty, e.g. legacy result files with no timing data
author | Brecht De Man <b.deman@qmul.ac.uk> |
---|---|
date | Mon, 17 Aug 2015 18:20:30 +0200 |
parents | 4fb6448759a9 |
children |
line wrap: on
line diff
--- a/scripts/timeline_view.py Wed Aug 12 10:31:10 2015 +0200 +++ b/scripts/timeline_view.py Mon Aug 17 18:20:30 2015 +0200 @@ -73,6 +73,7 @@ # get list of all page names for audioholder in root.findall("./audioholder"): # iterate over pages page_name = audioholder.get('id') # get page name + plot_empty = True # check if any data is plotted if page_name is None: # ignore 'empty' audio_holders break @@ -96,7 +97,7 @@ # for page [page_name], print comments related to fragment [id] for tuple in data: - audioelement = tuple[1] + audioelement = tuple[1] if audioelement is not None: # Check it exists audio_id = str(audioelement.get('id')) audioelements_names.append(audio_id) @@ -104,6 +105,9 @@ # for this audioelement, loop over all listen events listen_events = audioelement.findall("./metric/metricresult/[@name='elementListenTracker']/event") for event in listen_events: + # mark this plot as not empty + plot_empty = False + # get testtime: start and stop start_time = float(event.find('testtime').get('start'))-time_offset stop_time = float(event.find('testtime').get('stop'))-time_offset @@ -133,21 +137,22 @@ if audioholder_time is not None and show_audioholder_time: time_offset = float(audioholder_time.text) - # set plot parameters - plt.title('Timeline ' + file + ": "+page_name) - plt.xlabel('Time [seconds]') - plt.ylabel('Fragment') - plt.ylim(0, N_audioelements+1) + if not plot_empty: + # set plot parameters + plt.title('Timeline ' + file + ": "+page_name) + plt.xlabel('Time [seconds]') + plt.ylabel('Fragment') + plt.ylim(0, N_audioelements+1) - #y-ticks: fragment IDs, top to bottom - plt.yticks(range(N_audioelements, 0, -1), audioelements_names) # show fragment names + #y-ticks: fragment IDs, top to bottom + plt.yticks(range(N_audioelements, 0, -1), audioelements_names) # show fragment names - #plt.show() # uncomment to show plot; comment when just saving - #exit() + #plt.show() # uncomment to show plot; comment when just saving + #exit() - plt.savefig(timeline_folder+subject_id+"-"+page_name+".pdf", bbox_inches='tight') - plt.close() + plt.savefig(timeline_folder+subject_id+"-"+page_name+".pdf", bbox_inches='tight') + plt.close() #TODO: if 'nonsensical' or unknown: dashed line until next event #TODO: Vertical lines for fragment looping point