time_bins = twin[batch]
    sites = [s for s in sites if (s!='CRD013b') & ('gus' not in s)]
    if batch == 302:
        sites1 = [s+'.e1:64' for s in sites]
        sites2 = [s+'.e65:128' for s in sites]
        sites = sites1 + sites2
    for site in sites:
        if batch == 307:
            rawid = which_rawids(site)
        else:
            rawid = None
        manager = BAPHYExperiment(batch=batch, siteid=site[:7], rawid=rawid)
        rec = manager.get_recording(recache=recache, **options)
        rec['resp'] = rec['resp'].rasterize()
        if batch == 302:
            c, _ = parse_cellid({'cellid': site, 'batch': batch})
            rec['resp'] = rec['resp'].extract_channels(c)

        behavior_performance = manager.get_behavior_performance(**options)
        allop = copy.deepcopy(options)
        allop['keep_following_incorrect_trial'] = True
        allop['keep_cue_trials'] = True
        allop['keep_early_trials'] = True
        behavior_performance_all = manager.get_behavior_performance(**allop)

        # regress out first order pupil
        if regress_pupil & regress_task:
            rec = preproc.regress_state(rec, state_sigs=['pupil', 'behavior'])
        elif regress_pupil:
            rec = preproc.regress_state(rec, state_sigs=['pupil'])
        elif regress_task:
Beispiel #2
0
    r'$\mathbf{PC}_{1} \cdot \mathbf{\beta}_{2}$',
    r'$\mathbf{\beta}_{1} \cdot \mathbf{\beta}_{2}$'
])

# ============================= LOAD / ANALYZE / PLOT EXAMPLE SITE ==============================
site = 'DRX006b.e65:128'  #'DRX006b.e65:128'
batch = 289
fs = 4
ops = {'batch': batch, 'cellid': site}
xmodel = 'ns.fs{}.pup-ld-st.pup-hrc-psthfr_sdexp.SxR.bound_jk.nf10-basic'.format(
    fs)
path = '/auto/users/hellerc/results/nat_pupil_ms/pr_recordings/'
low = 0.5
high = 2

cells, _ = parse_cellid(ops)
rec = generate_state_corrected_psth(batch=batch,
                                    modelname=xmodel,
                                    cellids=cells,
                                    siteid=site,
                                    cache_path=path,
                                    recache=False)
ff_residuals = rec['resp']._data - rec['psth_sp']._data
nan_idx = np.isnan(ff_residuals[0, :])
ff_residuals[:, nan_idx] = 0
ff_residuals = bandpass_filter_resp(ff_residuals,
                                    low,
                                    high,
                                    fs=fs,
                                    boxcar=True)
rec['ff_residuals'] = rec['resp']._modified_copy(ff_residuals)
time_window = 0.2   # n secs of evoked response to collapse over for calculating dprime
bins = int(fs * time_window)

options = {'batch': batch,
           'cellid': site,
           'rasterfs': fs,
           'pupil': True,
           'resp': True,
           'stim':False}

manager = BAPHYExperiment(batch=batch, siteid=site[:7])
rec = manager.get_recording(**options)
rec['resp'] = rec['resp'].rasterize()

# extract appropriate shank
cells, _ = nb.parse_cellid(options)
rec['resp'] = rec['resp'].extract_channels(cells)
ncells = rec['resp'].shape[0]
rec = rec.and_mask(['FALSE_ALARM_TRIAL', 'EARLY_TRIAL'], invert=True)

# extract target responses
targets = [e for e in rec.epochs.name.unique() if 'TAR_' in e]
rew_tar = bh.get_rewarded_targets(rec, manager)
nr_tar = bh.get_nonrewarded_targets(rec, manager)
R_center = []
rt = rec.copy()
rt.and_mask(['PreStimSilence'], invert=True)
for t in targets:
    _r = rec['resp'].extract_epoch(t, mask=rt['mask'])[:, :, :bins].mean(axis=-1, keepdims=True)
    _r -= _r.mean(axis=0, keepdims=True)
    R_center.append(_r)