Mercurial > hg > webaudioevaluationtool
comparison scripts/timeline_view.py @ 1068:8eb0c24ea50a
Scripts: timeline view of marker movements
author | Brecht De Man <BrechtDeMan@users.noreply.github.com> |
---|---|
date | Tue, 11 Aug 2015 20:49:34 +0200 |
parents | 8d0061336b90 |
children | 4dd1cb18b77c |
comparison
equal
deleted
inserted
replaced
1067:8d0061336b90 | 1068:8eb0c24ea50a |
---|---|
7 import matplotlib.patches as patches # rectangles | 7 import matplotlib.patches as patches # rectangles |
8 | 8 |
9 # COMMAND LINE ARGUMENTS | 9 # COMMAND LINE ARGUMENTS |
10 | 10 |
11 assert len(sys.argv)<3, "timeline_view takes at most 1 command line argument\n"+\ | 11 assert len(sys.argv)<3, "timeline_view takes at most 1 command line argument\n"+\ |
12 "Use: python timeline_view.py [timeline_folder_location]" | 12 "Use: python timeline_view.py [XML_files_location]" |
13 | 13 |
14 # XML results files location | 14 # XML results files location |
15 if len(sys.argv) == 1: | 15 if len(sys.argv) == 1: |
16 folder_name = "../saves" # Looks in 'saves/' folder from 'scripts/' folder | 16 folder_name = "../saves" # Looks in 'saves/' folder from 'scripts/' folder |
17 print "Use: python timeline_view.py [timeline_folder_location]" | 17 print "Use: python timeline_view.py [XML_files_location]" |
18 print "Using default path: " + folder_name | 18 print "Using default path: " + folder_name |
19 elif len(sys.argv) == 2: | 19 elif len(sys.argv) == 2: |
20 folder_name = sys.argv[1] # First command line argument is folder | 20 folder_name = sys.argv[1] # First command line argument is folder |
21 | 21 |
22 # check if folder_name exists | 22 # check if folder_name exists |
88 | 88 |
89 N_audioelements = len(audioelements) # number of audio elements for this page | 89 N_audioelements = len(audioelements) # number of audio elements for this page |
90 increment = 0 # increased for every new audioelement | 90 increment = 0 # increased for every new audioelement |
91 audioelements_names = [] # store names of audioelements | 91 audioelements_names = [] # store names of audioelements |
92 | 92 |
93 # set plot parameters | |
94 plt.title('Timeline ' + file + ": "+page_name) | |
95 plt.xlabel('Time [seconds]') | |
96 plt.ylabel('Fragment') | |
97 plt.ylim(0, N_audioelements+1) | |
98 | |
99 # get axes handle | 93 # get axes handle |
100 fig = plt.figure(figsize=(fig_width, fig_height)) | 94 fig = plt.figure(figsize=(fig_width, fig_height)) |
101 ax = fig.add_subplot(111) #, aspect='equal' | 95 ax = fig.add_subplot(111) #, aspect='equal' |
102 | 96 |
103 # for page [page_name], print comments related to fragment [id] | 97 # for page [page_name], print comments related to fragment [id] |
136 | 130 |
137 # subtract total audioholder length from subsequent audioholder event times | 131 # subtract total audioholder length from subsequent audioholder event times |
138 audioholder_time = audioholder.find("./metric/metricresult/[@id='testTime']") | 132 audioholder_time = audioholder.find("./metric/metricresult/[@id='testTime']") |
139 if audioholder_time is not None and show_audioholder_time: | 133 if audioholder_time is not None and show_audioholder_time: |
140 time_offset = float(audioholder_time.text) | 134 time_offset = float(audioholder_time.text) |
141 | 135 |
142 #TODO: if 'nonsensical' or unknown: dashed line until next event | 136 # set plot parameters |
143 #TODO: Vertical lines for fragment looping point | 137 plt.title('Timeline ' + file + ": "+page_name) |
138 plt.xlabel('Time [seconds]') | |
139 plt.ylabel('Fragment') | |
140 plt.ylim(0, N_audioelements+1) | |
144 | 141 |
145 #y-ticks: fragment IDs, top to bottom | 142 #y-ticks: fragment IDs, top to bottom |
146 plt.yticks(range(N_audioelements, 0, -1), audioelements_names) # show fragment names | 143 plt.yticks(range(N_audioelements, 0, -1), audioelements_names) # show fragment names |
147 | 144 |
148 | 145 |
149 #plt.show() # uncomment to show plot; comment when just saving | 146 #plt.show() # uncomment to show plot; comment when just saving |
150 #exit() | 147 #exit() |
151 | 148 |
152 plt.savefig(timeline_folder+subject_id+"-"+page_name+".pdf", bbox_inches='tight') | 149 plt.savefig(timeline_folder+subject_id+"-"+page_name+".pdf", bbox_inches='tight') |
153 plt.close() | 150 plt.close() |
151 | |
152 #TODO: if 'nonsensical' or unknown: dashed line until next event | |
153 #TODO: Vertical lines for fragment looping point | |
154 |