# Settings INCL_NEURONS = 'pass-QC' INCL_SESSIONS = 'aligned-behavior' ATLAS = 'beryl-atlas' MIN_NEURONS = 1 PLOT = True PRE_TIME = 0.6 POST_TIME = -0.1 TRIAL_CENTERS = np.arange(-10, 21, 3) TRIAL_WIN = 5 BASELINE_TRIAL_WIN = 5 COLORS = (sns.color_palette('colorblind', as_cmap=True)[0], sns.color_palette('colorblind', as_cmap=True)[3]) # Query session list eids, probes = query_sessions(selection=INCL_SESSIONS) results_df = pd.DataFrame() for i in range(len(eids)): print('\nProcessing session %d of %d' % (i+1, len(eids))) # Load in data eid = eids[i] try: spikes, clusters, channels = bbone.load_spike_sorting_with_channel( eid, aligned=True, one=one) ses_path = one.path_from_eid(eid) trials = load_trials(eid) except Exception as error_message: print(error_message) continue
VALIDATION = 'kfold-interleaved' INCL_NEURONS = 'all' # all or no_drift INCL_SESSIONS = 'aligned-behavior' # all, aligned, resolved, aligned-behavior or resolved-behavior NUM_SPLITS = 5 CHANCE_LEVEL = 'pseudo-sessions' # pseudo-blocks, phase-rand, shuffle or none ITERATIONS = 100 # for null distribution estimation DATA_PATH, FIG_PATH, SAVE_PATH = paths() FIG_PATH = join(FIG_PATH, 'WholeBrain') DOWNLOAD_TRIALS = False PRE_TIME = 0 POST_TIME = 0.3 # %% Initialize # Query session list sessions = query_sessions(selection=INCL_SESSIONS) # Detect data format if type(sessions) == pd.DataFrame: ses_type = 'datajoint' elif 'model' in sessions[0]: ses_type = 'insertions' else: ses_type = 'sessions' # Initialize decoder clf = MultinomialNB() def decode(pop_vector, trial_ids, num_splits, interleaved):
-1] = False # Exclude all rew. ommissions if 'neg' in target: incl_trials[trials['feedbackType'] == 1] = False # Exclude all rewards if '0' in target: incl_trials[ trials['signed_contrast'] != 0] = False # Only include 0% contrast if ('prior' in target) and ('stim' in target): incl_trials[ trials['signed_contrast'] != 0] = False # Only include 0% contrast incl_trials[trials['reaction_times'] < min_rt] = False # Exclude trials with fast rt return incl_trials # Query session list eids, probes, subjects = query_sessions(selection=INCL_SESSIONS, return_subjects=True) # Load in all trials if CHANCE_LEVEL == 'other-trials': all_trials = pd.read_pickle( join(SAVE_PATH, 'Ephys', 'Decoding', 'all_trials.p')) all_trials = all_trials[get_incl_trials(all_trials, TARGET, EXCL_5050, MIN_RT)] # trial selection # %% MAIN # Load in decoding done so far if required if OVERWRITE: decoding_result = pd.DataFrame( columns=['subject', 'date', 'eid', 'probe', 'region']) elif isfile(
""" import numpy as np import pandas as pd from os.path import join import matplotlib.pyplot as plt from behavior_models import utils from my_functions import query_sessions, paths, figure_style from models.expSmoothing_stimside import expSmoothing_stimside as exp_stimside from models.expSmoothing_prevAction import expSmoothing_prevAction as exp_prev_action # Save path _, fig_path, save_path = paths() # Query all sessions that are aligned and meet behavioral criterion eids, probes, subjects = query_sessions(selection='aligned-behavior', return_subjects=True) # Loop over subjects results = pd.DataFrame() for i, subject in enumerate(np.unique(subjects)): print('\nStarting subject %s [%d of %d]\n' % (subject, i + 1, len(np.unique(subjects)))) stimuli_arr, actions_arr, stim_sides_arr, pleft_arr, session_uuids = [], [], [], [], [] for j, eid in enumerate(eids[subjects == subject]): data = utils.load_session(eid) if data['choice'] is not None and data['probabilityLeft'][0] == 0.5: stim_side, stimuli, actions, pLeft_oracle = utils.format_data(data) stimuli_arr.append(stimuli) actions_arr.append(actions) stim_sides_arr.append(stim_side) pleft_arr.append(pLeft_oracle)