def CI_training_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) (A_responding, A_iti) = cue_iti_responding(timecode, eventcode, 'ExcitorATrialStart', 'ExcitorATrialEnd', 'PokeOn1') (B_responding, B_iti) = cue_iti_responding(timecode, eventcode, 'ExcitorBTrialStart', 'ExcitorBTrialEnd', 'PokeOn1') df2 = pd.DataFrame([[ loaded_file['Subject'], loaded_file['MSN'], int(i + 1), float(A_responding), float(A_iti), float(B_responding), float(B_iti), float(dippers), float(dippers_retrieved), float(retrieval_latency) ]], columns=column_list) return df2
def PCER_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) cue_iti_responding(timecode, eventcode, 'StartTrial', 'EndTrial', 'PokeOn1') (ind_dur, tot_dur, ind_dur_iti, tot_dur_iti) = cue_responding_duration(timecode, eventcode, 'StartTrial', 'EndTrial', 'PokeOn1', 'PokeOff1') total_pokes = total_head_pokes(eventcode) (all_cue_length_poke_rates, all_iti_length_poke_rates, subtracted_poke_rates) = \ response_rate_across_cue_iti(timecode, eventcode, 'StartTrial', 'EndTrial', 'PokeOn1') new_cols = ['Subject'] + ['Cue_' + str(i + 1) for i in range(len(all_cue_length_poke_rates))] + \ ['ITI_' + str(i + 1) for i in range(len(all_cue_length_poke_rates))] + \ ['ES_' + str(i + 1) for i in range(len(all_cue_length_poke_rates))] across_cue_df = pd.DataFrame([([loaded_file['Subject']]+all_cue_length_poke_rates+all_iti_length_poke_rates+subtracted_poke_rates)], columns=new_cols) df2 = pd.DataFrame([[loaded_file['Subject'], int(i + 1), float(dippers), float(dippers_retrieved), float(retrieval_latency), float(ind_dur), float(tot_dur), float(total_pokes)]], columns=column_list) df2 = pd.merge(df2, across_cue_df, how='left', on=['Subject']) return df2
def test_cue_iti_responding(): assert cue_iti_responding([0, 1, 2, 3, 4, 5], [ 'StartSession', 'PokeOn1', 'LPressOn', 'PokeOn1', 'RPressOn', 'PokeOn1' ], 'LPressOn', 'RPressOn', 'PokeOn1') == (30.0, 30.0) assert cue_iti_responding([0, 1, 2, 3, 4, 5], [ 'StartSession', 'LPressOn', 'PokeOn1', 'PokeOn1', 'RPressOn', 'PokeOn1' ], 'LPressOn', 'RPressOn', 'PokeOn1') == (40.0, 0.0) assert cue_iti_responding([0, 1, 2, 3, 4, 5], [ 'StartSession', 'PokeOn1', 'PokeOn1', 'LPressOn', 'RPressOn', 'PokeOn1' ], 'LPressOn', 'RPressOn', 'PokeOn1') == (0.0, 60.0)
def CI_summation_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) (B_responding, B_iti) = cue_iti_responding(timecode, eventcode, 'ExcitorBTrialStart', 'ExcitorBTrialEnd', 'PokeOn1') (inhibitor_responding, inhibitor_iti) = cue_iti_responding(timecode, eventcode, 'InhibitorTrialStart', 'InhibitorTrialEnd', 'PokeOn1') (B_responding_5, B_iti_5) = binned_responding(timecode, eventcode, 'ExcitorBTrialStart', 'ExcitorBTrialEnd', 'PokeOn1', 5) (inhibitor_responding_5, inhibitor_iti_5) = binned_responding(timecode, eventcode, 'InhibitorTrialStart', 'InhibitorTrialEnd', 'PokeOn1', 5) df2 = pd.DataFrame([[loaded_file['Subject'], loaded_file['MSN'], int(i + 1), float(B_responding), float(B_iti), float(inhibitor_responding), float(inhibitor_iti), float(B_responding_5), float(B_iti_5), float(inhibitor_responding_5), float(inhibitor_iti_5)]], columns=column_list) return df2
def PIT_training_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) (A_responding, A_iti) = cue_iti_responding(timecode, eventcode, 'ExcitorATrialStart', 'ExcitorATrialEnd', 'PokeOn1') (B_responding, B_iti) = cue_iti_responding(timecode, eventcode, 'ExcitorBTrialStart', 'ExcitorBTrialEnd', 'PokeOn1') 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'], loaded_file['MSN'], int(i + 1), float(A_responding), float(A_iti), float(B_responding), float(B_iti), float(A_responding - A_iti), float(B_responding - B_iti), *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') 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), loaded_file['tts'], float(dippers), float(dippers_retrieved), float(retrieval_latency), float(total_presses), float(press_latency), float(lever_press_rate) ]], columns=column_list) return df2
def signtracking(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) (inactive_poke, inactive_iti_poke) = cue_iti_responding(timecode, eventcode, 'NoRewardTrialStart', 'NoRewardTrialEnd', 'PokeOn1') (inactive_press, inactive_iti_press) = cue_iti_responding( timecode, eventcode, 'NoRewardTrialStart', 'NoRewardTrialEnd', 'InactivePress') (active_poke, active_iti_poke) = cue_iti_responding(timecode, eventcode, 'RewardTrialStart', 'RewardTrialEnd', 'PokeOn1') (active_press, active_iti_press) = cue_iti_responding(timecode, eventcode, 'RewardTrialStart', 'RewardTrialEnd', 'ActivePress') df2 = pd.DataFrame([[ loaded_file['Subject'], int(i + 1), float(dippers), float(inactive_poke), float(inactive_press), float(active_poke), float(active_press) ]], columns=column_list) return df2
def CI_retardation_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) (X_responding, X_iti) = cue_iti_responding(timecode, eventcode, 'InhibitorTrialStart', 'InhibitorTrialEnd', 'PokeOn1') df2 = pd.DataFrame([[ loaded_file['Subject'], loaded_file['tts'], loaded_file['CI'], int(i + 1), float(X_responding), float(X_iti) ]], columns=column_list) return df2