def test_bin_by_time():
    assert bin_by_time([0, 1, 2, 3, 4, 5],
                       ['StartSession', 'PokeOn1', 'LPressOn', 'PokeOn1', 'RPressOn', 'PokeOn1'], 1, 'RPressOn') == [0, 0, 0, 0, 1]
    assert bin_by_time([0, 1, 2, 3, 4, 5],
                       ['StartSession', 'LPressOn', 'PokeOn1', 'PokeOn1', 'RPressOn', 'PokeOn1'], 2, 'RPressOn') == [0, 0, 1]
    assert bin_by_time([0, 1, 2, 3, 4, 5],
                       ['StartSession', 'PokeOn1', 'PokeOn1', 'LPressOn', 'RPressOn', 'PokeOn1'], 3, 'RPressOn') == [0, 1]
Пример #2
0
def DNAMIC_function(eventcode, timecode, fields_dictionary, 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)
    """
    left_count = bin_by_time(timecode, eventcode, 3600, ['LPokeOn'])
    right_count = bin_by_time(timecode, eventcode, 3600, ['RPokeOn'])
    middle_count = bin_by_time(timecode, eventcode, 3600, ['MPokeOn'])
    total_count = bin_by_time(timecode, eventcode, 3600,
                              ['LPokeOn', 'RPokeOn', 'MPokeOn'])
    print(sum(total_count))

    df2 = pd.DataFrame([[
        fields_dictionary['Subject'],
        int(i + 1), left_count, right_count, middle_count, total_count
    ]],
                       columns=column_list)

    return df2
Пример #3
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