Mercurial > hg > webaudioevaluationtool
comparison scripts/generate_report.py @ 1076:1d4d4d50ce62
Scripts: generate_report slightly more robust against missing duration values
author | Brecht De Man <BrechtDeMan@users.noreply.github.com> |
---|---|
date | Tue, 22 Sep 2015 18:19:38 +0200 |
parents | 056a8454500e |
children | 2bbf813c0e61 235594325b84 |
comparison
equal
deleted
inserted
replaced
1075:056a8454500e | 1076:1d4d4d50ce62 |
---|---|
28 assert sys.argv[2] in ('no_render','-nr'), "Second argument not recognised. \n" +\ | 28 assert sys.argv[2] in ('no_render','-nr'), "Second argument not recognised. \n" +\ |
29 "Use: python generate_report.py [results_folder] [no_render | -nr]" | 29 "Use: python generate_report.py [results_folder] [no_render | -nr]" |
30 # Second command line argument is [no_render | -nr] | 30 # Second command line argument is [no_render | -nr] |
31 render_figures = False | 31 render_figures = False |
32 | 32 |
33 def isNaN(num): | |
34 return num != num | |
35 | |
33 # Turn number of seconds (int) to '[minutes] min [seconds] s' (string) | 36 # Turn number of seconds (int) to '[minutes] min [seconds] s' (string) |
34 def seconds2timestr(time_in_seconds): | 37 def seconds2timestr(time_in_seconds): |
35 time_in_minutes = int(time_in_seconds/60) | 38 if time_in_seconds is not None and not isNaN(time_in_seconds): |
36 remaining_seconds = int(time_in_seconds%60) | 39 time_in_minutes = int(time_in_seconds/60) |
37 return str(time_in_minutes) + " min " + str(remaining_seconds) + " s" | 40 remaining_seconds = int(time_in_seconds%60) |
41 return str(time_in_minutes) + " min " + str(remaining_seconds) + " s" | |
42 else: | |
43 return 'N/A' | |
38 | 44 |
39 # stats initialisation | 45 # stats initialisation |
40 number_of_XML_files = 0 | 46 number_of_XML_files = 0 |
41 number_of_pages = 0 | 47 number_of_pages = 0 |
42 number_of_fragments = 0 | 48 number_of_fragments = 0 |
72 \usepackage{geometry} | 78 \usepackage{geometry} |
73 \geometry{a4paper} | 79 \geometry{a4paper} |
74 \usepackage[parfill]{parskip} % empty line instead of indent | 80 \usepackage[parfill]{parskip} % empty line instead of indent |
75 \usepackage{graphicx} % figures | 81 \usepackage{graphicx} % figures |
76 \usepackage{hyperref} | 82 \usepackage{hyperref} |
77 \usepackage{tikz} % pie charts | 83 \usepackage{tikz} % pie charts |
78 \title{Report} | 84 \title{Report} |
79 \author{'''+\ | 85 \author{'''+\ |
80 user+\ | 86 user+\ |
81 r'''} | 87 r'''} |
82 \graphicspath{{'''+\ | 88 \graphicspath{{'''+\ |
135 gender.append('UNAVAILABLE') | 141 gender.append('UNAVAILABLE') |
136 # get age | 142 # get age |
137 this_subjects_age = root.find("./posttest/number/[@id='age']") | 143 this_subjects_age = root.find("./posttest/number/[@id='age']") |
138 if this_subjects_age is not None: | 144 if this_subjects_age is not None: |
139 age.append(this_subjects_age.text) | 145 age.append(this_subjects_age.text) |
140 #TODO add plot of age | 146 #TODO add plot of age |
141 | 147 |
142 # get list of all page names | 148 # get list of all page names |
143 for audioholder in root.findall("./audioholder"): # iterate over pages | 149 for audioholder in root.findall("./audioholder"): # iterate over pages |
144 page_name = audioholder.get('id') # get page name | 150 page_name = audioholder.get('id') # get page name |
145 | 151 |
146 if page_name is None: # ignore 'empty' audio_holders | 152 if page_name is None: # ignore 'empty' audio_holders |
150 number_of_comments = 0 # for this page | 156 number_of_comments = 0 # for this page |
151 number_of_missing_comments = 0 # for this page | 157 number_of_missing_comments = 0 # for this page |
152 not_played = [] # for this page | 158 not_played = [] # for this page |
153 not_moved = [] # for this page | 159 not_moved = [] # for this page |
154 | 160 |
155 # 'testTime' keeps total duration: subtract time so far for duration of this audioholder | 161 if audioholder.find("./metric/metricresult[@id='testTime']") is not None: # check if time is included |
156 duration = float(audioholder.find("./metric/metricresult[@id='testTime']").text) - total_duration | 162 # 'testTime' keeps total duration: subtract time so far for duration of this audioholder |
157 | 163 duration = float(audioholder.find("./metric/metricresult[@id='testTime']").text) - total_duration |
158 # total duration of test | 164 |
159 total_duration += duration | 165 # total duration of test |
166 total_duration += duration | |
167 else: | |
168 duration = float('nan') | |
169 total_duration = float('nan') | |
160 | 170 |
161 # number of audio elements | 171 # number of audio elements |
162 audioelements = audioholder.findall("./audioelement") # get audioelements | 172 audioelements = audioholder.findall("./audioelement") # get audioelements |
163 number_of_fragments += len(audioelements) # add length of this list to total | 173 number_of_fragments += len(audioelements) # add length of this list to total |
164 | 174 |
406 \begin{center} | 416 \begin{center} |
407 \includegraphics[width=.65\textwidth]{'''+\ | 417 \includegraphics[width=.65\textwidth]{'''+\ |
408 folder_name+"/subjects_per_audioholder.pdf"+\ | 418 folder_name+"/subjects_per_audioholder.pdf"+\ |
409 r'''} | 419 r'''} |
410 \caption{Number of subjects per audioholder.} | 420 \caption{Number of subjects per audioholder.} |
411 \label{fig:avgtimeperaudioholder} | 421 \label{fig:subjectsperaudioholder} |
412 \end{center} | 422 \end{center} |
413 \end{figure} | 423 \end{figure} |
414 | 424 |
415 ''' | 425 ''' |
416 #TODO add error bars | 426 #TODO add error bars |
427 folder_name+"/ratings/"+audioholder_name+'-ratings-box.pdf'+\ | 437 folder_name+"/ratings/"+audioholder_name+'-ratings-box.pdf'+\ |
428 r'''} | 438 r'''} |
429 \caption{Box plot of ratings for audioholder '''+\ | 439 \caption{Box plot of ratings for audioholder '''+\ |
430 audioholder_name+' ('+str(subject_count[real_page_names.index(audioholder_name)])+\ | 440 audioholder_name+' ('+str(subject_count[real_page_names.index(audioholder_name)])+\ |
431 ''' participants).} | 441 ''' participants).} |
432 \label{fig:avgtimeperpage} | 442 \label{fig:boxplot'''+audioholder_name.replace(" ", "")+'''} |
433 \end{center} | 443 \end{center} |
434 \end{figure} | 444 \end{figure} |
435 | 445 |
436 ''' | 446 ''' |
437 | 447 |