本文整理汇总了Python中common.Common._annotsById方法的典型用法代码示例。如果您正苦于以下问题:Python Common._annotsById方法的具体用法?Python Common._annotsById怎么用?Python Common._annotsById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Common
的用法示例。
在下文中一共展示了Common._annotsById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: processPupilDisplacement
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import _annotsById [as 别名]
def processPupilDisplacement(tracking, dc, annotsl, annots):
lDiff, rDiff = [x["lDiff"] for x in tracking["pupilDisplacement"]], [x["rDiff"] for x in tracking["pupilDisplacement"]]
annotsD = Cmn._annotsById(annotsl)
fnLDiff, fnRDiff = {}, {}
for e in tracking["pupilDisplacement"]:
fnLDiff[e["fn"]] = e["lDiff"]
fnRDiff[e["fn"]] = e["rDiff"]
lbCaught, rbCaught, lMissed, rMissed = [], [], [], []
for diff, resList, checkRefs in [(fnLDiff, lbCaught, dc["bCaught"]), (fnRDiff, rbCaught, dc["bCaught"]),
(fnLDiff, lMissed, dc["lMissed"]), (fnRDiff, rMissed, dc["rMissed"]), ]:
for checkRef in checkRefs:
bs, be = annotsD[checkRef]["bs"], annotsD[checkRef]["be"]
s = sum(diff[c] for c in xrange(bs, be+1) if diff.has_key(c))/(float(be-bs) if (be-bs) > 0 else 1)
resList.append((checkRef, s, (bs, be)))
fpByOnlyL, fpByOnlyR = [], []
for diff, resList, checkRefs in [(fnLDiff, fpByOnlyL, dc["fpByOnlyL"]), (fnRDiff, fpByOnlyR, dc["fpByOnlyR"]), ]:
for checkRef in checkRefs:
bs, be = checkRef[1]["fs"], checkRef[1]["fe"]
s = sum(diff[c] for c in xrange(bs, be+1) if diff.has_key(c))/(float(be-bs) if (be-bs) > 0 else 1)
resList.append((checkRef, s, (bs, be)))
fpByBothEyesLR = []
for resList, checkRefs in [(fpByBothEyesLR, dc["fpByBothEyes"]), ]:
for checkRef in checkRefs:
ls, rs = 0, 0
l, r = checkRef[0], checkRef[1]
lbs, lbe, rbs, rbe = l[1]["fs"], l[1]["fe"], r[1]["fs"], r[1]["fe"]
ls = sum(fnLDiff[c] for c in xrange(lbs, lbe+1) if fnLDiff.has_key(c))/(float(lbe-lbs) if (lbe-lbs) > 0 else 1)
rs = sum(fnRDiff[c] for c in xrange(rbs, rbe+1) if fnRDiff.has_key(c))/(float(rbe-rbs) if (rbe-rbs) > 0 else 1)
resList.append((checkRef, ls, rs, (lbs, lbe), (rbs, rbe)))
lMissedByDisplacement = sorted([x[0] for x in lMissed if x[1] > 13])
rMissedByDisplacement = sorted([x[0] for x in rMissed if x[1] > 13])
aMissedByDisplacement = sorted(list(set([x[0] for x in lMissed if x[1] > 13]+[x[0] for x in rMissed if x[1] > 13])))
bMissedByDisplacement = sorted(list(set.intersection(*[set([x[0] for x in lMissed if x[1] > 13]), set([x[0] for x in rMissed if x[1] > 13])])))
loMissedByDisplacement = [x for x in lMissedByDisplacement if x not in bMissedByDisplacement]
roMissedByDisplacement = [x for x in rMissedByDisplacement if x not in bMissedByDisplacement]
lOnlyFpByDisplacement = sorted([x for x in fpByOnlyL], key=lambda x:x[1])
rOnlyFpByDisplacement = sorted([x for x in fpByOnlyR], key=lambda x:x[1])
bothFpByDisplacement = sorted(fpByBothEyesLR, key=lambda y:(y[1]+y[2]))
lOutliers = [(x["fn"], x["lDiff"]) for x in tracking["pupilDisplacement"] if x["lDiff"] > 12]
rOutliers = [(x["fn"], x["rDiff"]) for x in tracking["pupilDisplacement"] if x["rDiff"] > 12]
lPercent = (len(lOutliers)/float(len(tracking["pupilDisplacement"]))*100) if len(tracking["pupilDisplacement"]) >0 else -1
rPercent = (len(rOutliers)/float(len(tracking["pupilDisplacement"]))*100) if len(tracking["pupilDisplacement"]) >0 else -1
return {
"lMissed":lMissed, "rMissed":rMissed,
"lMissedByDisplacement":lMissedByDisplacement, "rMissedByDisplacement":rMissedByDisplacement,
"loMissedByDisplacement":loMissedByDisplacement, "roMissedByDisplacement":roMissedByDisplacement,
"bMissedByDisplacement":bMissedByDisplacement, "aMissedByDisplacement":aMissedByDisplacement,
"lOnlyFpByDisplacement":lOnlyFpByDisplacement, "rOnlyFpByDisplacement":rOnlyFpByDisplacement,
"bothFpByDisplacement":bothFpByDisplacement,
"lOutliers":lOutliers, "rOutliers":rOutliers, "lPercent":lPercent, "rPercent":rPercent,
}