예제 #1
0
def RVI_Go_NoGo_P1(loaded_file, i):
    """
    :param loaded_file: file output from operant box
    :param i: number of days analyzing
    :return: data frame of all analysis extracted from file (one animal)
    """
    (timecode, eventcode) = extract_info_from_file(loaded_file, 500)
    (small_go_trials, large_go_trials, small_go_success,
     large_go_success) = (eventcode.count('GoTrialBegSmallReward'),
                          eventcode.count('GoTrialBegLargeReward'),
                          eventcode.count('GoTrialSuccessSmallReward'),
                          eventcode.count('GoTrialSuccessLargeReward'))
    small_go_latency = lever_press_latency(timecode, eventcode,
                                           'GoTrialBegSmallReward',
                                           'GoTrialSuccessSmallReward')
    large_go_latency = lever_press_latency(timecode, eventcode,
                                           'GoTrialBegLargeReward',
                                           'GoTrialSuccessLargeReward')

    df2 = pd.DataFrame([[
        loaded_file['Subject'],
        int(i + 1),
        float(small_go_trials),
        float(large_go_trials),
        float(small_go_success),
        float(large_go_success),
        float(small_go_latency),
        float(large_go_latency)
    ]],
                       columns=column_list)

    return df2
예제 #2
0
def crf_function(loaded_file, i):
    """
    :param loaded_file: file output from operant box
    :param i: number of days analyzing
    :return: data frame of all analysis extracted from file (one animal)
    """
    (timecode, eventcode) = extract_info_from_file(loaded_file, 500)
    (dippers, dippers_retrieved,
     retrieval_latency) = reward_retrieval(timecode, eventcode)
    (left_presses, right_presses,
     total_presses) = lever_pressing(eventcode, 'LPressOn', 'RPressOn')

    if 'LLeverOn' in eventcode:
        press_latency = lever_press_latency(timecode, eventcode, 'LLeverOn',
                                            'LPressOn')
    elif 'RLeverOn' in eventcode:
        press_latency = lever_press_latency(timecode, eventcode, 'RLeverOn',
                                            'RPressOn')

    df2 = pd.DataFrame([[
        loaded_file['Subject'],
        int(i + 1),
        float(dippers),
        float(dippers_retrieved),
        float(retrieval_latency),
        float(total_presses),
        float(press_latency)
    ]],
                       columns=column_list)

    return df2
예제 #3
0
def test_lever_press_latency():
    assert lever_press_latency([0, 1, 2, 3, 4, 5, 6], [
        'StartSession', 'PokeOn1', 'PokeOn1', 'LPressOn', 'LPressOn',
        'RPressOn', 'EndSession'
    ], 'LPressOn', 'RPressOn') == 1
    assert lever_press_latency([0, 1, 2, 3, 4, 5, 6], [
        'StartSession', 'PokeOn1', 'PokeOn1', 'LPressOn', 'LPressOn',
        'PokeOn1', 'EndSession'
    ], 'LPressOn', 'RPressOn') == 0
    assert lever_press_latency([0, 1, 2, 3, 4, 5, 6], [
        'StartSession', 'PokeOn1', 'PokeOn1', 'LPressOn', 0, 'RPressOn',
        'EndSession'
    ], 'LPressOn', 'RPressOn') == 2