def load_recording(batch=None, cellid=None, reformat=True, by_sequence=True, **context): from nems.recording import load_recording options = { 'cellid': cellid, 'batch': batch, 'rasterfs': 100, 'includeprestim': 1, 'stimfmt': 'ozgf', 'chancount': 18, 'pupil': 0, 'stim': 1, 'pertrial': 1, 'runclass': 'RDT', 'recache': False, } path = baphy_data_path(**options) rec = load_recording(path) if reformat: rec = reformat_RDT_recording(rec) if by_sequence: rec = average_away_epoch_occurrences(rec, '^SEQUENCE') return {'rec': rec}
'cellid': cellid, 'batch': batch, 'rasterfs': 100, 'includeprestim': 1, 'stimfmt': 'ozgf', 'chancount': 18, 'pupil': 0, 'stim': 1, 'pertrial': 1, 'runclass': 'RDT', 'recache': False, } recording_uri = baphy_data_path(**options) rec=load_recording(recording_uri) resp = rec['resp'] respfast = resp.copy() respfast.fs = 1000 respfast=respfast.rasterize() resp=resp.rasterize() ep = resp.epochs stim=rec['stim'].extract_epoch('Stim , '+targetid+' , Target')[0,:,:] firsttar = (ep['name'].str.startswith('Stim , '+targetid+'+') & ep['name'].str.endswith('Target')) trial_start = ep[ep['name']=='TRIAL']['start'].values s,e = ep['start'][firsttar].values, ep['end'][firsttar].values
rec = average_away_epoch_occurrences(rec, '^SEQUENCE') return {'rec': rec} def remove_nan(rec): i = np.isnan(rec['fg'].as_continuous()) new_signals = {} for name, signal in rec.items(): new_data = signal.as_continuous()[:, i] new_signals[name] = signal._modified_copy(new_data) return Recording(new_signals) if __name__ == '__main__': rec = load_recording('269', 'zee021e-c1') #import itertools #import pylab as pl #epochs = rec['fg'].extract_epoch('03') #f, axes = pl.subplots(4, 4) #for i, ax in zip(range(16), itertools.chain(*axes)): # ax.imshow(epochs[i]) #epochs = rec['bg'].extract_epoch('03') #f, axes = pl.subplots(4, 4) #for i, ax in zip(range(16), itertools.chain(*axes)): # ax.imshow(epochs[i]) #epochs = rec['resp'].extract_epoch('03')