def detect_and_reject_outliers(df, y):
    """Detects and rejects outliers in the distribution of within effect sizes.

    Studies with a within effect size out of the bounds are excluded.

    Parameters
    ----------
    df: pandas.DataFrame
        Dataframe containing all observations in rows, factors and also values to compute the effect size within subjects in columns. 
        It is obtained after the import of the csv file containing all data by ``import_csv_for_factors``.

    y: pandas.Series
       Effect size within subjects computed for each observation.

    Returns
    -------
    df: pandas.DataFrame
        Dataframe containing all observations with outliers excluded.

    y: pandas.Series
       Effect size within subjects with outliers excluded.
    
    """

    # Compute mean and standard deviation of all the within effect sizes
    mean_wES = y.mean()
    std_wES = y.std()

    # Compute the thresholds of acceptance
    bound_inf = mean_wES - 3*std_wES
    bound_sup = mean_wES + 3*std_wES

    # Detect outliers
    df_outlier = df[ (y < bound_inf) | (y > bound_sup) ]

    # Reject outlier
    df = df.drop(df_outlier.index.values, axis=0)
    y = y.drop(df_outlier.index.values, axis=0)

    return df, y