bad += 1
ok = n - missed
hits = m - bad
+ # at this point, we must have ok = hits. if not we had
+ # - a case were one onset counted for two labels (ok>hits)
+ # - a case were one labels matched two onsets (hits>ok)
+ # bad hack for now (fails if both above cases have happened):
+ if ok > hits: bad += ok-hits; ok = hits
+ if hits > ok: missed += hits-ok; hits = ok
total = n
return ok,bad,missed,total,hits
# default values
fileo=None;filec=None;vmode=None;dmode=None;delay=0.
# default tolerance is 50 ms
-tol = 0.050
+#tol = 0.050
+tol = 0.048
while len(sys.argv) >=2:
option = sys.argv[1]; del sys.argv[1]
if option == '-v': vmode = 'verbose'
if option == '-d': dmode = 'debug'
if option == '-D': delay = float(sys.argv[1]); del sys.argv[1]
+ if option == '-tol': tol = float(sys.argv[1]); del sys.argv[1]
# arguments required
if (not fileo) or (not filec):
ltru, lres = read_datafile(fileo,depth=0),read_datafile(filec,depth=0)
# delay onsets as required with -D
-for i in range(len(lres)):
- lres[i] = lres[i] + delay
+if delay:
+ for i in range(len(lres)):
+ lres[i] = lres[i] + delay
# compute errors types
ok, bad, missed, total, hits = onset_roc(ltru,lres,tol)