Esempio n. 1
0
def load_data(path):
    def get_realXY_from_trial(trial):
        if scapp_report[trial]['ExpcResp'] == 0:
            realX = scapp_report[trial]['X2']+51
            realY = scapp_report[trial]['Y2']+55
        elif scapp_report[trial]['ExpcResp'] == 1:
            realX = scapp_report[trial]['X1']+51
            realY = scapp_report[trial]['Y1']+55
        else:
            raise "Missing Value on Report"
        return (K.SCREEN_WIDTH_PX-realX, realY)    
    
    realXY = [get_realXY_from_trial(i) for i in range(len(scapp_report))]

    by_trial = []
    all_gaze = []
    all_real = []
    mus = []
    clusters = np.load(path)
    for cluster in clusters:
        gaze_by_trial = []
        real_by_trial = []
        for gaze in cluster:
            g = gaze['norm_pos']
            r = get_realXY_from_trial(gaze['trial'])
            gaze_by_trial.append(g)
            real_by_trial.append(r)
            all_gaze.append(g)
            all_real.append(r)
        
        real_by_trial = np.vstack(real_by_trial)

        gaze_by_trial = np.vstack(gaze_by_trial)
        gaze_by_trial = normalized_to_pixel(gaze_by_trial)

        gmeanX = np.mean(gaze_by_trial[:,0])
        gmeanY = np.mean(gaze_by_trial[:,1])

        rmeanX = np.mean(real_by_trial[:,0])
        rmeanY = np.mean(real_by_trial[:,1])

        # intermediate accuracy defined as the mean 
        # difference of the real positions and the reported positions
        by_trial.append({'g':gaze_by_trial,'r':real_by_trial}) 
        mus.append(np.array([gmeanX,gmeanY,rmeanX,rmeanY]))

    # vertical stack
    realXY = np.vstack(set(realXY))
    all_gaze = np.vstack(all_gaze)
    all_real = np.vstack(all_real)

    all_gaze = normalized_to_pixel(all_gaze)

    meanX = np.mean(all_gaze[:,0])
    meanY = np.mean(all_gaze[:,1])

    MU = [meanX, meanY]
    return MU, mus, all_gaze, all_real, realXY, by_trial 
Esempio n. 2
0
def load_data(path):
    all_gaze = []
    clusters = np.load(path)
    sds = []
    for cluster in clusters:
        by_trial = []
        for gaze in cluster:
            by_trial.append(gaze['norm_pos'])

        by_trial = np.vstack(by_trial)
        by_trial = move_mean_to_zero(by_trial)
        by_trial = normalized_to_pixel(by_trial)
        #by_trial = normalized_to_degree(by_trial)
        #by_trial = normalized_to_pixel(by_trial)
        by_trial = pixel_to_degree(by_trial)

        # intermediate precision defined as the Standard Deviation of observations in the cluster/trial 
        sds.append(np.std(by_trial, ddof=1, dtype=np.float64))
        all_gaze.append(by_trial)

    # overall precision defined as the Standard Deviation of all observations
    all_gaze = np.vstack(all_gaze)
    
    sd = np.std(all_gaze, ddof=0, dtype=np.float64)
    print 'sd:',round(sd,3)

    # overall variance
    var = np.var(all_gaze,ddof=0, dtype=np.float64)

    # overall precision defined as the RMS of all observations (should be equal to SD when the mean = zero)
    rms = root_mean_square(all_gaze)
    print 'rms:',rms
    print ''

   
    return var, sd, sds, all_gaze