Esempio n. 1
0
def plot_pulled_prob_MF_agent(data_path):

    subjectd_IDs = get_directory_names(data_path)
    for id in subjectd_IDs:

        repeat, common_rewarded, unique_rewarded = extract_MF_behavior_data(data_path, id)
        common1_unique0, common0_unique1, common0_unique0, common1_unique1 = \
            find_repeat_probs_MF(repeat, common_rewarded, unique_rewarded)

        fig = plt.figure('MF agent repeat probabilities')
        xs = [0, 1]
        ys = [common1_unique0, common1_unique1]
        plt.scatter(xs, ys, c='b', linewidths=0.5, marker='.', s=3)
        ys = [common0_unique0, common0_unique1]
        plt.scatter(xs, ys, c='r', linewidths=0.5, marker='.', s=3)

        plt.xticks(range(2), ['U=0', 'U=1'])
        plt.ylim([0, 1])

    mean_c1u1, std_c1u1, mean_c1u0, std_c1u0, mean_c0u1, std_c0u1, mean_c0u0, std_c0u0 = \
        extract_MF_probabilities(data_path)

    plt.errorbar(xs, [mean_c0u0, mean_c0u1], yerr=[std_c0u0, std_c0u1], label='common 0')
    plt.errorbar(xs, [mean_c1u0, mean_c1u1], yerr=[std_c1u0, std_c1u1], label='common 1')
    plt.legend()
    plt.ylabel('Prob(repeat)')

    plt.show()
Esempio n. 2
0
def extract_data_MF_glmfit(data_path):

    pulled_dataframe = pd.DataFrame({
        'repeat': [],
        'common_reward': [],
        'unique_reward': [],
        'subject_id': []
    })
    subject_models, subject_results, pulled_model, pulled_results = [], [], None, None

    subjectd_IDs = get_directory_names(data_path)
    for id in subjectd_IDs:
        model, result, subject_df = glmfit_for_single_subject(data_path, id)
        subject_models.append(model)
        subject_results.append(result)
        pulled_dataframe = pulled_dataframe.append(subject_df,
                                                   ignore_index=True)

    pulled_model, pulled_results = mixedlm(
        pulled_dataframe, 'repeat ~ common_reward*unique_reward', {
            'a': '0+C(subject_id)',
            'b': '0+C(subject_id)*common_reward',
            'c': '0+C(subject_id)*unique_reward'
        })

    return subject_models, subject_results, pulled_model, pulled_results
Esempio n. 3
0
    def _find_new_subject_id_():

        dir_names = get_directory_names(TaskParams.data_dir)
        if dir_names:
            subject_ids = [int(name) for name in dir_names]
            return max(subject_ids) + 1
        else:
            return 1
Esempio n. 4
0
def extract_MB_probabilities(data_path):

    subjectd_IDs = get_directory_names(data_path)
    c1s, c0s = [], []
    for id in subjectd_IDs:

        repeat, common_rewarded, _ = extract_MB_behavior_data(data_path, id)
        common1, common0 = find_repeat_probs(repeat, common_rewarded)

        c1s.append(common1)
        c0s.append(common0)

    return np.mean(c1s), sem(c1s), np.mean(c0s), sem(c0s)
Esempio n. 5
0
def extract_MF_probabilities(data_path):

    subjectd_IDs = get_directory_names(data_path)
    c1u1s, c1u0s, c0u1s, c0u0s = [], [], [], []
    for id in subjectd_IDs:

        repeat, common_rewarded, unique_rewarded = extract_MF_behavior_data(
            data_path, id)
        common1_unique0, common0_unique1, common0_unique0, common1_unique1 = \
            find_repeat_probs(repeat, common_rewarded, unique_rewarded)

        c1u1s.append(common1_unique1)
        c1u0s.append(common1_unique0)
        c0u1s.append(common0_unique1)
        c0u0s.append(common0_unique0)

    return np.mean(c1u1s), sem(c1u1s), np.mean(c1u0s), sem(c1u0s),\
        np.mean(c0u1s), sem(c0u1s), np.mean(c0u0s), sem(c0u0s)
Esempio n. 6
0
def plot_pulled_prob_MB_agent(data_path):

    subjectd_IDs = get_directory_names(data_path)
    for id in subjectd_IDs:

        repeat, common_rewarded, _ = extract_MB_behavior_data(data_path, id)
        common1, common0 = find_repeat_probs_MB(repeat, common_rewarded)

        fig = plt.figure('MB agent repeat probabilities')
        xs = [0, 1]
        ys = [common0, common1]
        plt.scatter(xs, ys, c='b', linewidths=0.5, marker='.', s=3)

    plt.xticks(range(2), ['C=0', 'C=1'])
    plt.ylim([0, 1])

    mean_c1, std_c1, mean_c0, std_c0 = extract_MB_probabilities(data_path)

    plt.errorbar(xs, [mean_c0, mean_c1], yerr=[std_c0, std_c1])
    plt.ylabel('Prob(repeat)')

    plt.show()