Showing the changes to python (2 of 2 files). Show all
Unified · Split
| @@ -53,6 +53,12 @@ def onset_roc(la, lb, eps): · 52 unmodified lines | |||
| 53 | bad += 1 | 53 | bad += 1 |
| 54 | ok = n - missed | 54 | ok = n - missed |
| 55 | hits = m - bad | 55 | hits = m - bad |
| 56 | # at this point, we must have ok = hits. if not we had | ||
| 57 | # - a case were one onset counted for two labels (ok>hits) | ||
| 58 | # - a case were one labels matched two onsets (hits>ok) | ||
| 59 | # bad hack for now (fails if both above cases have happened): | ||
| 60 | if ok > hits: bad += ok-hits; ok = hits | ||
| 61 | if hits > ok: missed += hits-ok; hits = ok | ||
| 56 | total = n | 62 | total = n |
| 57 | return ok,bad,missed,total,hits | 63 | return ok,bad,missed,total,hits |
| 58 | 64 | ||
| @@ -60,7 +60,8 @@ from aubio.txtfile import read_datafile · 59 unmodified lines | |||
| 60 | # default values | 60 | # default values |
| 61 | fileo=None;filec=None;vmode=None;dmode=None;delay=0. | 61 | fileo=None;filec=None;vmode=None;dmode=None;delay=0. |
| 62 | # default tolerance is 50 ms | 62 | # default tolerance is 50 ms |
| 63 | tol = 0.050 | 63 | #tol = 0.050 |
| 64 | tol = 0.048 | ||
| 64 | 65 | ||
| 65 | while len(sys.argv) >=2: | 66 | while len(sys.argv) >=2: |
| 66 | option = sys.argv[1]; del sys.argv[1] | 67 | option = sys.argv[1]; del sys.argv[1] |
| @@ -70,6 +71,7 @@ while len(sys.argv) >=2: · 3 unmodified lines | |||
| 70 | if option == '-v': vmode = 'verbose' | 71 | if option == '-v': vmode = 'verbose' |
| 71 | if option == '-d': dmode = 'debug' | 72 | if option == '-d': dmode = 'debug' |
| 72 | if option == '-D': delay = float(sys.argv[1]); del sys.argv[1] | 73 | if option == '-D': delay = float(sys.argv[1]); del sys.argv[1] |
| 74 | if option == '-tol': tol = float(sys.argv[1]); del sys.argv[1] | ||
| 73 | 75 | ||
| 74 | # arguments required | 76 | # arguments required |
| 75 | if (not fileo) or (not filec): | 77 | if (not fileo) or (not filec): |
| @@ -80,8 +82,9 @@ if (not fileo) or (not filec): · 4 unmodified lines | |||
| 80 | ltru, lres = read_datafile(fileo,depth=0),read_datafile(filec,depth=0) | 82 | ltru, lres = read_datafile(fileo,depth=0),read_datafile(filec,depth=0) |
| 81 | 83 | ||
| 82 | # delay onsets as required with -D | 84 | # delay onsets as required with -D |
| 83 | for i in range(len(lres)): | 85 | if delay: |
| 84 | lres[i] = lres[i] + delay | 86 | for i in range(len(lres)): |
| 87 | lres[i] = lres[i] + delay | ||
| 85 | # compute errors types | 88 | # compute errors types |
| 86 | ok, bad, missed, total, hits = onset_roc(ltru,lres,tol) | 89 | ok, bad, missed, total, hits = onset_roc(ltru,lres,tol) |
| 87 | 90 | ||