Exemple #1
0
def test_complete_compile_experiment_data_3():
    df = get_csv_as_df('experiment', 3)
    data = compile_data.compile_experiment_data(df)

    # effort and discomfort ratings
    assert data['prop_effort_ups'] == 0.166666667  # 3/6
    assert data['prop_effort_downs'] == 0.333333333  # 2/6
    assert data['prop_effort_sames'] == 0.500000000  # 1/6

    assert data['prop_discomfort_ups'] == 0.333333333  # 2/6
    assert data['prop_discomfort_downs'] == 0.333333333  # 2/6
    assert data['prop_discomfort_sames'] == 0.333333333  # 2/6
Exemple #2
0
def test_complete_compile_experiment_data_1():
    df = get_csv_as_df('experiment', 1)
    data = compile_data.compile_experiment_data(df)
    assert data['condition'] == 5

    assert data['block_order'] == ('medium,medium,hard,medium,easy,'
                                   'medium,medium,medium,medium')
    assert data['num_blocks'] == 9
    assert data['block_hard'] == 3
    assert data['block_easy'] == 5

    assert data['anticipated_enjoyment'] == 3
    assert data['anticipated_performance'] == 4
    assert data['anticipated_effort'] == 4
    assert data['anticipated_discomfort'] == 4
    assert data['anticipated_fatigue'] == 4

    # real-time data for each block
    assert data['accuracy_1'] == 0.571428571
    assert data['accuracy_2'] == 0.428571429
    assert data['accuracy_3'] == 0.357142857
    assert data['accuracy_4'] == 0.5
    assert data['accuracy_5'] == 0.571428571
    assert data['accuracy_6'] == 0.285714286
    assert data['accuracy_7'] == 0.357142857
    assert data['accuracy_8'] == 0.428571429
    assert data['accuracy_9'] == 0.357142857
    assert 'accuracy_10' not in data.keys()

    assert data['effort_1'] == 5
    assert data['effort_2'] == 4
    assert data['effort_3'] == 4
    assert data['effort_4'] == 4
    assert data['effort_5'] == 4
    assert data['effort_6'] == 7
    assert data['effort_7'] == 1
    assert data['effort_8'] == 2
    assert data['effort_9'] == 7
    assert 'effort_10' not in data.keys()

    assert data['discomfort_1'] == 5
    assert data['discomfort_2'] == 4
    assert data['discomfort_3'] == 4
    assert data['discomfort_4'] == 4
    assert data['discomfort_5'] == 4
    assert data['discomfort_6'] == 7
    assert data['discomfort_7'] == 1
    assert data['discomfort_8'] == 2
    assert data['discomfort_9'] == 7
    assert 'discomfort_10' not in data.keys()

    # minimum/maximum discomfort and effort ratings
    assert data['min_effort'] == 1
    assert data['max_effort'] == 7
    assert data['min_discomfort'] == 1
    assert data['max_discomfort'] == 7

    # slope and intercept values for all blocks
    assert data['accuracy_slope'] == -0.012189013
    assert data['accuracy_intercept'] == 0.525361222
    assert data['effort_slope'] == -0.011834331
    assert data['effort_intercept'] == 4.316195575
    assert data['discomfort_slope'] == -0.011834331
    assert data['discomfort_intercept'] == 4.316195575

    # real-time data by block type
    assert data['medium_accuracy'] == 0.418367347
    assert data['medium_effort'] == 4.285714286
    assert data['medium_discomfort'] == 4.285714286

    assert data['medium_accuracy_slope'] == -0.014672245
    assert data['medium_accuracy_intercept'] == 0.541020328
    assert data['medium_effort_slope'] == -0.019802768
    assert data['medium_effort_intercept'] == 4.451256
    assert data['medium_discomfort_slope'] == -0.019802768
    assert data['medium_discomfort_intercept'] == 4.451256

    assert data['hard_accuracy'] == 0.357142857
    assert data['hard_effort'] == 4
    assert data['hard_discomfort'] == 4
    assert data['easy_accuracy'] == 0.571428571
    assert data['easy_effort'] == 4
    assert data['easy_discomfort'] == 4

    assert data['start_discomfort'] == 5
    assert data['peak_discomfort'] == 7
    assert data['end_discomfort'] == 7
    assert data['avg_discomfort'] == 4.222222222

    assert data['start_effort'] == 5
    assert data['peak_effort'] == 7
    assert data['end_effort'] == 7
    assert data['avg_effort'] == 4.222222222

    assert data['avg_accuracy'] == 0.428571429
    assert data['max_accuracy'] == 0.571428571
    assert data['min_accuracy'] == 0.285714286
    assert data['start_accuracy'] == 0.571428571
    assert data['end_accuracy'] == 0.357142857

    assert data['auc_accuracy'] == 3.392857143
    assert data['auc_effort'] == 32.0
    assert data['auc_discomfort'] == 32.0

    assert data['time_experiment_ms'] == 831136
Exemple #3
0
def test_complete_compile_experiment_data():
    pid = "104"
    df = get_csv_as_df('experiment', pid)
    ed = compile_data.compile_experiment_data(df)

    assert ed['num_trials'] == 646
    assert ed['trials_per_block'] == 82
    assert ed['num_blocks'] == 8

    assert ed['forecasted_enjoyment'] == 5
    assert ed['forecasted_performance'] == 4
    assert ed['forecasted_effort'] == 6
    assert ed['forecasted_discomfort'] == 5
    assert ed['forecasted_fatigue'] == 2
    assert ed['forecasted_motivation'] == 4

    # check keys for each block's real-time data
    blk_summary_keys = [
        'anticipated', 'nogo_next4_avg', 'nogo_prev4_avg', 'go_errors',
        'effort', 'num_trials', 'discomfort', 'rt_avg', 'nogo_errors',
        'accuracy'
        ]
    for i in range(1, 9):
        blk_key_prefix = "blk{}".format(i)
        blk_keys = [k for k in ed.keys() if k.startswith(blk_key_prefix)]
        assert len(blk_keys) == 13
        for k in blk_summary_keys:
            expected_blk_key = "{}_{}".format(blk_key_prefix, k)
            assert expected_blk_key in blk_keys

    # effort and discomfort ratings
    assert ed['prop_effort_ups'] == 0.428571429  # 3/7
    assert ed['prop_effort_downs'] == 0.571428571  # 4/7
    assert ed['prop_effort_sames'] == 0.0  # 0/7

    assert ed['prop_discomfort_ups'] == 0.285714286  # 2/7
    assert ed['prop_discomfort_downs'] == 0.142857143  # 1/7
    assert ed['prop_discomfort_sames'] == 0.571428571  # 4/7

    # no-go error variable weighted averages
    assert ed['nogo_num_errors'] == 43
    assert ed['nogo_error_prev_rt_avg'] == 346.66257668704293
    assert ed['nogo_error_next_rt_avg'] == 336.88535031840127

    # regression variables for blocks
    assert ed['accuracy_slope'] == 0.002454737
    assert ed['accuracy_intercept'] == 0.829650186
    assert ed['effort_slope'] == 0.022726243
    assert ed['effort_intercept'] == 3.92036912
    assert ed['discomfort_slope'] == 0.202292011
    assert ed['discomfort_intercept'] == 3.178529021

    # peak-end calculations
    assert ed['start_effort'] == 2
    assert ed['peak_effort'] == 7
    assert ed['min_effort'] == 2
    assert ed['end_effort'] == 3
    assert ed['avg_effort'] == 4.125

    assert ed['start_discomfort'] == 4
    assert ed['peak_discomfort'] == 7
    assert ed['min_discomfort'] == 4
    assert ed['end_discomfort'] == 6
    assert ed['avg_discomfort'] == 5

    assert ed['avg_accuracy'] == 0.851393189
    assert ed['max_accuracy'] == 0.951219512
    assert ed['min_accuracy'] == 0.62195122
    assert ed['start_accuracy'] == 0.865853659
    assert ed['end_accuracy'] == 0.875

    assert ed['auc_accuracy'] == 5.943597561
    assert ed['auc_effort'] == 30.5
    assert ed['auc_discomfort'] == 35.0

    # post-experiment evaluation of valence and arousal
    assert ed['arousal_post_mind_body'] == '2'
    assert ed['arousal_post_feeling'] == '5'

    assert ed['time_experiment_ms'] == 940644