コード例 #1
0
def plotPerfSizeDist(foldername):
    rs = ReadSetupFile()
    dicoCost = {}
 
    for i in range(len(rs.sizeOfTarget)):
        name =  rs.CMAESpath + str(rs.sizeOfTarget[i]) + "/" + foldername + "/Cost/"

        costs = getCostData(name)

        for k, v in costs.items():
            for j in range(len(v)):
                distance = round(rs.getDistanceToTarget(v[j][0],v[j][1]),2)
                if not distance in dicoCost.keys():
                    dicoCost[distance] = {}
                if not rs.sizeOfTarget[i] in dicoCost[distance].keys():
                    dicoCost[distance][rs.sizeOfTarget[i]] = []
                dicoCost[distance][rs.sizeOfTarget[i]].append(v[j][2])

    plotTab = []
    fig = plt.figure(1, figsize=(16,9))
    plt.ylabel("performance")
    plt.xlabel("Target size (mm)")
    for key in sorted(dicoCost.keys()):
        plotTab.append(plt.plot([i for i in sorted(dicoCost[key].keys())], [np.mean(dicoCost[key][i]) for i in sorted(dicoCost[key].keys())], label = str("Distance: " + str(key))))
    plt.legend(loc = 0)
    plt.savefig("ImageBank/perfdist"+foldername+".png", bbox_inches='tight')
    plt.show(block = True)
コード例 #2
0
def plotPerfSizeDist(foldername):
    rs = ReadSetupFile()
    dicoCost = {}

    for i in range(len(rs.sizeOfTarget)):
        name = rs.CMAESpath + str(
            rs.sizeOfTarget[i]) + "/" + foldername + "/Cost/"

        costs = getCostData(name)

        for k, v in costs.items():
            for j in range(len(v)):
                distance = round(rs.getDistanceToTarget(v[j][0], v[j][1]), 2)
                if not distance in dicoCost.keys():
                    dicoCost[distance] = {}
                if not rs.sizeOfTarget[i] in dicoCost[distance].keys():
                    dicoCost[distance][rs.sizeOfTarget[i]] = []
                dicoCost[distance][rs.sizeOfTarget[i]].append(v[j][2])

    plotTab = []
    fig = plt.figure(1, figsize=(16, 9))
    plt.ylabel("performance")
    plt.xlabel("Target size (mm)")
    for key in sorted(dicoCost.keys()):
        plotTab.append(
            plt.plot([i for i in sorted(dicoCost[key].keys())], [
                np.mean(dicoCost[key][i]) for i in sorted(dicoCost[key].keys())
            ],
                     label=str("Distance: " + str(key))))
    plt.legend(loc=0)
    plt.savefig("ImageBank/perfdist" + foldername + ".png",
                bbox_inches='tight')
    plt.show(block=True)
コード例 #3
0
def plotFittsLaw(foldername, rbfn=False):
    rs = ReadSetupFile()

    timeDistWidth = []
    for i in range(len(rs.sizeOfTarget)):
        name = rs.CMAESpath + str(
            rs.sizeOfTarget[i]) + "/" + foldername + "/TrajTime/"

        trajTimes = getTrajTimeData(name)

        for k, v in trajTimes.items():
            for j in range(len(v)):
                distance = rs.getDistanceToTarget(v[j][0], v[j][1])
                trajtime = v[j][2]
                size = rs.sizeOfTarget[i]
                timeDistWidth.append((distance, size, trajtime))

    MT, DI = [], []
    for el in timeDistWidth:
        MT.append(el[2])
        DI.append(np.log2(el[0] / el[1]))
    slope, intercept, r_value, p_value, std_err = stats.linregress(DI, MT)
    yLR = slope * np.asarray(DI) + intercept
    plt.figure()

    for el in timeDistWidth:
        if el[0] <= 0.15:
            plt.scatter(np.log2(el[0] / el[1]), el[2], c='blue')
        elif el[0] <= 0.28:
            plt.scatter(np.log2(el[0] / el[1]), el[2], c='green')
        else:
            plt.scatter(np.log2(el[0] / el[1]), el[2], c='red')

    plt.plot(DI, yLR)
    plt.title("a = " + str(slope) + " b = " + str(intercept) + " r^2 = " +
              str(r_value**2))
    plt.xlabel("log(D/W)/log(2)")
    plt.ylabel("Movement time (s)")
    plt.savefig("ImageBank/fitts" + foldername + ".png", bbox_inches='tight')
    plt.show(block=True)
コード例 #4
0
def plotFittsLaw(foldername, rbfn = False):
    rs = ReadSetupFile()

    timeDistWidth = []
    for i in range(len(rs.sizeOfTarget)):
        name =  rs.CMAESpath + str(rs.sizeOfTarget[i]) + "/" + foldername + "/TrajTime/"

        trajTimes = getTrajTimeData(name)

        for k, v in trajTimes.items():
            for j in range(len(v)):
                distance = rs.getDistanceToTarget(v[j][0],v[j][1])
                trajtime = v[j][2]
                size = rs.sizeOfTarget[i]
                timeDistWidth.append((distance, size, trajtime))
            
    MT, DI = [], []
    for el in timeDistWidth:
        MT.append(el[2])
        DI.append(np.log2(el[0]/el[1]))
    slope, intercept, r_value, p_value, std_err = stats.linregress(DI,MT)
    yLR = slope * np.asarray(DI) + intercept
    plt.figure()

    for el in timeDistWidth:
            if el[0]<=0.15:
                plt.scatter(np.log2(el[0]/el[1]), el[2], c ='blue')
            elif el[0]<=0.28:
                plt.scatter(np.log2(el[0]/el[1]), el[2], c ='green')
            else:
                plt.scatter(np.log2(el[0]/el[1]), el[2], c ='red')
        
    plt.plot(DI, yLR)
    plt.title("a = " + str(slope) + " b = " + str(intercept) + " r^2 = " + str(r_value**2))
    plt.xlabel("log(D/W)/log(2)")
    plt.ylabel("Movement time (s)")
    plt.savefig("ImageBank/fitts"+foldername+".png", bbox_inches='tight')
    plt.show(block = True)