Mercurial > hg > webaudioevaluationtool
diff scripts/timeline_view_movement.py @ 2076:c235979c6197
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 | ae928dc90d39 |
children | 7576a4957680 |
line wrap: on
line diff
--- a/scripts/timeline_view_movement.py Wed Aug 12 10:31:10 2015 +0200 +++ b/scripts/timeline_view_movement.py Mon Aug 17 18:20:30 2015 +0200 @@ -69,6 +69,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 print "Skipping empty audioholder name from "+subject_id+"." @@ -139,6 +140,9 @@ # draw all segments except final one for event in move_events: + # mark this plot as not empty + plot_empty = False + # get time and final position of move event new_time = float(event.find("./time").text)-time_offset new_position = float(event.find("./position").text) @@ -223,31 +227,31 @@ last_audioholder_duration = audioholder_time-time_offset time_offset = audioholder_time - - # set plot parameters - plt.title('Timeline ' + file + ": "+page_name) - plt.xlabel('Time [seconds]') - plt.xlim(0, last_audioholder_duration) - plt.ylabel('Rating') # default - plt.ylim(0, 1) # rating between 0 and 1 + if not plot_empty: # if plot is not empty, show or store + # set plot parameters + plt.title('Timeline ' + file + ": "+page_name) + plt.xlabel('Time [seconds]') + plt.xlim(0, last_audioholder_duration) + plt.ylabel('Rating') # default + plt.ylim(0, 1) # rating between 0 and 1 - #y-ticks: labels on rating axis - label_positions = [] - label_text = [] - scale_tags = root.findall("./BrowserEvalProjectDocument/audioHolder/interface/scale") - scale_title = root.find("./BrowserEvalProjectDocument/audioHolder/interface/title") - for tag in scale_tags: - label_positions.append(float(tag.get('position'))/100) # on a scale from 0 to 100 - label_text.append(tag.text) - if len(label_positions) > 0: # if any labels available - plt.yticks(label_positions, label_text) # show rating axis labels - # set label Y-axis - if scale_title is not None: - plt.ylabel(scale_title.text) + #y-ticks: labels on rating axis + label_positions = [] + label_text = [] + scale_tags = root.findall("./BrowserEvalProjectDocument/audioHolder/interface/scale") + scale_title = root.find("./BrowserEvalProjectDocument/audioHolder/interface/title") + for tag in scale_tags: + label_positions.append(float(tag.get('position'))/100) # on a scale from 0 to 100 + label_text.append(tag.text) + if len(label_positions) > 0: # if any labels available + plt.yticks(label_positions, label_text) # show rating axis labels + # set label Y-axis + if scale_title is not None: + plt.ylabel(scale_title.text) - #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() \ No newline at end of file