Beispiel #1
0
def test_lever_pressing():
    assert lever_pressing([
        'StartSession', 'PokeOn1', 'LPressOn', 'PokeOn1', 'RPressOn', 'PokeOn1'
    ], 'LPressOn', 'RPressOn') == (1, 1, 2)
    assert lever_pressing([
        'StartSession', 'LPressOn', 'PokeOn1', 'PokeOn1', 'RPressOn', 'PokeOn1'
    ], 'LPressOn') == (1, 0, 1)
    assert lever_pressing([
        'StartSession', 'PokeOn1', 'PokeOn1', 'LPressOn', 'RPressOn',
        'RPressOn', 'PokeOn1'
    ], 'LPressOn', 'RPressOn') == (1, 2, 3)
Beispiel #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')

    #    Use this code for latencies and rates
    #
    #    if 'LLeverOn' in eventcode:
    #        press_latency = lever_press_latency(timecode, eventcode, 'LLeverOn', 'LPressOn')
    #        (lever_press_rate, iti_rate) = cue_iti_responding(timecode, eventcode, 'StartSession', 'EndSession', 'LPressOn')
    #    elif 'RLeverOn' in eventcode:
    #        press_latency = lever_press_latency(timecode, eventcode, 'RLeverOn', 'RPressOn')
    #        (lever_press_rate, iti_rate) = cue_iti_responding(timecode, eventcode, 'StartSession', 'EndSession', 'RPressOn')

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

    return df2
def PIT_test_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)
    (csplus_presses, csmin_presses,
     total_presses) = lever_pressing(eventcode, 'ActivePress', 'InactivePress')

    file_keys = list(loaded_file.keys())
    for constant in [
            'File', 'Start Date', 'End Date', 'Subject', 'Experiment', 'Group',
            'Box', 'Start Time', 'End Time', 'MSN', 'W'
    ]:
        file_keys.remove(constant)

    # All that's left in the list file_keys should be any group labels.
    group_ids = []
    for group in file_keys:
        group_ids.append(loaded_file[group])

    df2 = pd.DataFrame([[
        loaded_file['Subject'],
        int(i + 1),
        float(csplus_presses),
        float(csmin_presses), *group_ids
    ]],
                       columns=column_list + file_keys)
    return df2
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')

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

    return df2
Beispiel #5
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')

    start_time = datetime.datetime.strptime(
        f'{loaded_file["Start Date"]} {loaded_file["Start Time"]}',
        '%m/%d/%y %H:%M:%S')
    end_time = datetime.datetime.strptime(
        f'{loaded_file["End Date"]} {loaded_file["End Time"]}',
        '%m/%d/%y %H:%M:%S')
    sess_length = end_time - start_time
    sess_length = sess_length.seconds

    #    Use this code for latencies and rates
    #
    #    if 'LLeverOn' in eventcode:
    #        press_latency = lever_press_latency(timecode, eventcode, 'LLeverOn', 'LPressOn')
    #        (lever_press_rate, iti_rate) = cue_iti_responding(timecode, eventcode, 'StartSession', 'EndSession', 'LPressOn')
    #    elif 'RLeverOn' in eventcode:
    #        press_latency = lever_press_latency(timecode, eventcode, 'RLeverOn', 'RPressOn')
    #        (lever_press_rate, iti_rate) = cue_iti_responding(timecode, eventcode, 'StartSession', 'EndSession', 'RPressOn')

    file_keys = list(loaded_file.keys())
    for constant in [
            'File', 'Start Date', 'End Date', 'Subject', 'Experiment', 'Group',
            'Box', 'Start Time', 'End Time', 'MSN', 'W'
    ]:
        file_keys.remove(constant)

    # All that's left in the list file_keys should be any group labels.
    group_ids = []
    for group in file_keys:
        group_ids.append(loaded_file[group])

    df2 = pd.DataFrame([[
        loaded_file['Subject'],
        int(i + 1),
        float(dippers),
        float(dippers_retrieved),
        float(retrieval_latency),
        float(left_presses),
        float(right_presses),
        float(total_presses),
        float(sess_length), *group_ids
    ]],
                       columns=column_list + file_keys)

    return df2
Beispiel #6
0
def habit_extinction_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)
    (left_presses, right_presses, total_presses) = lever_pressing(eventcode, 'LPressOn', 'RPressOn')
    pressing_across_test = bin_by_time(timecode, eventcode, (5 * 60), ['LPressOn', 'RPressOn'])

    df2 = pd.DataFrame([[loaded_file['Subject'], loaded_file['Sex'], int(i + 1), loaded_file['Training'],
                         float(total_presses), pressing_across_test]], columns=column_list)
    bins_df = df2['Bins'].apply(pd.Series)
    bins_df = bins_df.rename(columns=lambda x: (x + 1) * 5)
    df2 = pd.concat([df2[:], bins_df[:]], axis=1)
    return df2