if batch in [324, 325]: ra = ra.and_mask(['HIT_TRIAL', 'CORRECT_REJECT_TRIAL', 'INCORRECT_HIT_TRIAL', 'MISS_TRIAL']) elif batch == 302: ra = ra.and_mask(['HIT_TRIAL', 'CORRECT_REJECT_TRIAL', 'INCORRECT_HIT_TRIAL', 'MISS_TRIAL']) elif batch == 307: ra = ra.and_mask(['HIT_TRIAL', 'MISS_TRIAL']) rp = rec.copy() rp = rp.create_mask(True) rp = rp.and_mask(['PASSIVE_EXPERIMENT']) # find / sort epoch names if batch in [324, 325]: targets = thelp.sort_targets([f for f in ra['resp'].epochs.name.unique() if 'TAR_' in f]) targets = [t for t in targets if (ra['resp'].epochs.name==t).sum()>=5] on_center = thelp.get_tar_freqs([f.strip('REM_') for f in ra['resp'].epochs.name.unique() if 'REM_' in f])[0] targets = [t for t in targets if str(on_center) in t] catch = [f for f in ra['resp'].epochs.name.unique() if 'CAT_' in f] catch = [c for c in catch if str(on_center) in c] targets_str = targets catch_str = catch elif batch == 307: params = manager.get_baphy_exptparams() params = [p for p in params if p['BehaveObjectClass']!='Passive'][0] tf = params['TrialObject'][1]['TargetHandle'][1]['Names'] targets = [f'TAR_{t}' for t in tf] if params['TrialObject'][1]['OverlapRefTar']=='Yes': snrs = params['TrialObject'][1]['RelativeTarRefdB'] else: snrs = ['Inf'] snrs = [s if (s!=np.inf) else 'Inf' for s in snrs]
targets_str = [ t + '+InfdB+Noise' for t in targets if (t.split('TAR_')[1] in rew) ] else: # find / sort epoch names targets = thelp.sort_targets( [f for f in _ra['resp'].epochs.name.unique() if 'TAR_' in f]) # only keep target presented at least 5 times targets = [ t for t in targets if (_ra['resp'].epochs.name == t).sum() >= 5 ] # remove "off-center targets" try: on_center = thelp.get_tar_freqs([ f.strip('REM_') for f in _ra['resp'].epochs.name.unique() if 'REM_' in f ])[0] targets = [t for t in targets if str(on_center) in t] except: pass if len(targets) == 0: # NOT ENOUGH REPS AT THIS SITE skip_site = True catch = [ f for f in _ra['resp'].epochs.name.unique() if 'CAT_' in f ] # remove off-center catches catch = [c for c in catch if str(on_center) in c] rem = [f for f in rec['resp'].epochs.name.unique() if 'REM_' in f] targets_str = targets catch_str = catch
ra = ra.create_mask(True) ra = ra.and_mask(['HIT_TRIAL', 'CORRECT_REJECT_TRIAL']) rp = rec.copy() rp = rp.create_mask(True) rp = rp.and_mask(['PASSIVE_EXPERIMENT']) # stim pairs targets = thelp.sort_targets( [f for f in ra['resp'].epochs.name.unique() if 'TAR_' in f]) targets = [ t for t in targets if (ra.apply_mask( reset_epochs=True)['resp'].epochs.name == t).sum() >= 5 ] on_center = thelp.get_tar_freqs([ f.strip('REM_') for f in ra['resp'].epochs.name.unique() if 'REM_' in f ])[0] targets = [t for t in targets if str(on_center) in t] catch = [f for f in ra['resp'].epochs.name.unique() if 'CAT_' in f] catch = [c for c in catch if str(on_center) in c] ref_stim = thelp.sort_refs( [f for f in ra['resp'].epochs.name.unique() if 'STIM_' in f]) rem = [f for f in rec['resp'].epochs.name.unique() if 'REM_' in f] sounds = targets + catch pairs = list(combinations(['REFERENCE'] + ref_stim + sounds, 2)) behavior_performance = manager.get_behavior_performance(**options) # Perform analysis for each cellid for cellid in ra['resp'].chans: print(f"Analyzing {cellid}")
manager = BAPHYExperiment(batch=batch, siteid=site) rec = manager.get_recording(recache=recache, **options) rec['resp'] = rec['resp'].rasterize() rec = rec.and_mask(['PASSIVE_EXPERIMENT', 'HIT_TRIAL', 'CORRECT_REJECT_TRIAL']) # mask appropriate trials ra = rec.and_mask(['HIT_TRIAL', 'CORRECT_REJECT_TRIAL']) rp = rec.and_mask(['PASSIVE_EXPERIMENT']) targets = thelp.sort_targets( [f for f in ra['resp'].epochs.name.unique() if 'TAR_' in f]) catch = thelp.sort_targets( [f for f in ra['resp'].epochs.name.unique() if 'CAT_' in f]) # keep only on-center tar / cat oncenter = thelp.get_tar_freqs([ f.strip('REM_') for f in ra['resp'].epochs.name.unique() if 'REM_' in f ])[0] targets = [t for t in targets if thelp.get_tar_freqs([t])[0] == oncenter] catch = [t for t in catch if thelp.get_tar_freqs([t])[0] == oncenter] all_stim = [s for s in ra['resp'].epochs.name.unique() if 'STIM_' in s ] + targets + catch # set up figure f, ax = plt.subplots(3, 4, figsize=(12, 9)) acov1, pcov1, dcov1, e1, acov2, pcov2, dcov2, e2, acov3, pcov3, dcov3, e3 = ax.flatten( ) EVECS = [] # ================================= TARGET ONLY ====================================== respa = [] respp = []