Пример #1
0
def test_num_successful_go_nogo_trials():
    assert num_successful_go_nogo_trials([
        'StartSession', 'SuccessfulGoTrial', 'PokeOn1', 'RPressOn', 'PokeOn1'
    ]) == (1, 0)
    assert num_successful_go_nogo_trials([
        'StartSession', 'LPressOn', 'PokeOn1', 'PokeOn1', 'RPressOn', 'PokeOn1'
    ]) == (0, 0)
    assert num_successful_go_nogo_trials([
        'StartSession', 'SuccessfulNoGoTrial', 'SuccessfulNoGoTrial',
        'LPressOn', 'RPressOn', 'SuccessfulGoTrial'
    ]) == (1, 2)
def Go_NoGo(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)
    (go_trials, nogo_trials) = count_go_nogo_trials(eventcode)
    (successful_go_trials, successful_nogo_trials) = num_successful_go_nogo_trials(eventcode)
    go_latency = lever_press_lat_gng(timecode, eventcode, 'LLeverOn', 'SuccessfulGoTrial') + \
                 lever_press_lat_gng(timecode, eventcode, 'RLeverOn', 'SuccessfulGoTrial')

    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(successful_go_trials) / float(go_trials),
                         (float(nogo_trials) - float(successful_nogo_trials)) / float(nogo_trials),
                         float(successful_go_trials) / float(go_trials) - float(successful_nogo_trials) / float(nogo_trials),
                         float(go_latency), *group_ids]],
                       columns=column_list+file_keys)

    return df2
Пример #3
0
def Go_NoGo(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)
    (go_trials, nogo_trials) = count_go_nogo_trials(eventcode)
    (successful_go_trials,
     successful_nogo_trials) = num_successful_go_nogo_trials(eventcode)
    df2 = pd.DataFrame([[
        loaded_file['Subject'], loaded_file['tts'],
        int(i + 1),
        float(dippers),
        float(go_trials),
        float(successful_go_trials)
    ]],
                       columns=column_list)

    return df2