prestim = 0 poststim = 0 duration = .75 #soundpath = '/auto/users/hellerc/code/baphy/Config/lbhb/SoundObjects/@NaturalSounds/sounds_set4/' soundpath = '/auto/users/hellerc/code/baphy/Config/lbhb/SoundObjects/@NaturalSounds/sounds_set4/' manager = BAPHYExperiment(cellid=siteid, batch=batch) rec = manager.get_recording(**{ 'rasterfs': rasterfs, 'stim': False, 'pupil': True, 'resp': True }) rec['resp'] = rec['resp'].extract_channels(rec.meta['cells_to_extract']) rec['resp'] = rec['resp'].rasterize() rec = fix_cpn_epochs(rec) epochs = rec['resp'].epochs[rec['resp'].epochs.name.str.contains('STIM_')] epochs = epochs[(epochs.end <= (twin[1] / rasterfs)) & \ (epochs.end >= (twin[0] / rasterfs))] stims = epochs.name t = epochs[['start', 'end']].values.tolist() stimulus = [] spk_times = [] # for saving the highlighted data stim1 = [] stim2 = [] stim3 = [] r1 = [] r2 = []
df = ld.load_noise_correlation('rsc_ev') win = 15 # total window size (non overlapping across data) subwin = 0.25 # sub window size (mean rate across all / sd across all) # CV = sd of spike counts across all subwindows divided by the mean across all sub windows # If all neurons are Poisson and statistically independent, then the CV of the population rate will approach zero site = 'TAR010c' batch = 289 manager = BAPHYExperiment(cellid=site, batch=batch) options = {'rasterfs': 4, 'resp': True, 'stim': False, 'pupil': True} rec = manager.get_recording(**options) rec['resp'] = rec['resp'].rasterize() if batch == 331: rec = nems_preproc.fix_cpn_epochs(rec) else: rec = nems_preproc.mask_high_repetion_stims(rec) rec = generate_psth_from_resp(rec) # extract continuous data (subtract psth?) data = rec.apply_mask()['resp']._data #- rec.apply_mask()['psth_sp']._data pupil = rec.apply_mask()['pupil']._data # divide into bins win_bin = int(rec['resp'].fs * win) subwin_bin = int(rec['resp'].fs * subwin) CV = [] bpupil = [] i = 0 while ((i * win_bin) <= data.shape[-1]):
manager = BAPHYExperiment(cellid='ARM029a', batch=331) #manager = BAPHYExperiment(cellid='ARM033a', batch=331) #manager = BAPHYExperiment(cellid='AMT026a', batch=331) #manager = BAPHYExperiment(cellid='CRD018d', batch=331) #manager = BAPHYExperiment(cellid='AMT020a', batch=331) #manager = BAPHYExperiment(cellid='ARM031a', batch=331) r = manager.get_recording(recache=True, **{ 'rasterfs': 4, 'resp': True, 'pupil': True, 'stim': False, 'pupil_variable_name': 'area' }) r['resp'] = r['resp'].rasterize() r = fix_cpn_epochs(r) r = generate_psth_from_resp(r) epochs = [e for e in r['resp'].epochs.name.unique() if e.startswith('STIM')] r = r.and_mask(epochs) binsizes = [0.5, 1, 2] #, 3, 4] thresh = 1 significant_pairs = False for binsize in binsizes: rec = r.copy() # before masking, take raw signals and compute variance of an eyelid over a sliding window binsize = int(binsize * rec['resp'].fs) signal = rec['pupil_extras'].extract_channels(['eyelid_top_y'])._data signal2 = rec['pupil_extras'].extract_channels(['eyelid_bottom_y'])._data varsig = np.zeros(signal.shape)