예제 #1
0
import nems.db as nd
import pandas as pd
import pathlib as pl

all_rec_ids = set()
all_sites = list()
all_regions = list()
for batch, region in zip([318, 319], ['A1', 'PEG']):
    df = nd.get_batch_cell_data(batch=batch)
    files = df.parm.unique()
    rec_ids = [file.split('/')[-1].split('.')[0] for file in files]
    sites = [rec_id.split('_')[0][:7] for rec_id in rec_ids]

    all_rec_ids.update(rec_ids)
    all_sites.extend(sites)
    all_regions.extend([region] * len(rec_ids))

region_map = pd.DataFrame({'site_id': all_sites, 'region': all_regions})

empirical_bad = {'DRX008b14_p_NTI', 'CRD002a16_p_NTI'}
good_rec_ids = all_rec_ids.difference(empirical_bad)
all_animals = set([rec[:3] for rec in good_rec_ids])
print(good_rec_ids)
print(all_animals)

mapfile = pl.Path('/auto/users/mateo/integration_quilt/scrambling-ferrets/rasters/region_map.csv')
region_map.to_csv(mapfile)
예제 #2
0
import nems.utilities as nu
import nems.db as nd
#import nems.utilities.baphy

# find all cells in A1 / natural sound dataset
batch = 271

d = nd.get_batch_cells(batch=batch)
print(d['cellid'])

# figure out filepath for demo files
cellid = 'TAR010c-07-1'

# database can be used to locate files, but need to configure nems
d = nd.get_batch_cell_data(cellid=cellid, batch=batch, label='parm')
parmfilepath = d['parm'][0]

# less responsive site
#cellid='all'   # set cellid='all' to load all cells recorded at this site
#parmfilepath='/auto/data/daq/Tartufo/TAR010/TAR010c16_p_NAT.m'

options = {
    'rasterfs': 100,
    'includeprestim': True,
    'stimfmt': 'ozgf',
    'chancount': 18,
    'cellid': cellid,
    'pupil': True
}
event_times, spike_dict, stim_dict, state_dict = nu.baphy.baphy_load_dataset(
예제 #3
0
elif use_example == "RDT":
    # this is an RDT example:
    cellid = "chn029d-a1"
    batch = 269  # RDT in A1
    modelname = "wc02_fir_dexp"  # string identifier for this model architecture
    valeventcount = 20

elif use_example == "PTD":
    # this is an RDT example:
    cellid = "TAR010c-21-2"  # note same cellid as NAT data but different files
    batch = 301  # 301 is A1, pure tone detect with pupil recordings
    modelname = "wc02_fir_dexp"
    valeventcount = 3

# get file info from database
d = nd.get_batch_cell_data(batch, cellid)

# load the data. This is a little more complicated than simple_example now
# because there may be multiple files for a given (cellid,batch)
X_est_set = []
Y_est_set = []
X_val_set = []
Y_val_set = []
for ii in range(0, len(d)):

    # specify some pre-processing/formatt parameters for the stimulus. this
    # will point to a specific .mat file with the relevant spectrogram by
    # adding strings onto the end of the filename stub returned by
    # nd.get_batch_cell()
    stim_options = {
        'filtfmt': 'ozgf',
예제 #4
0
#Example of how to cache parameters for REM analysis.
#ZPS 2018-10-01

import pandas as pd
import nems.db as nd
from nems_lbhb.baphy_io import get_rem, cache_rem_options, load_rem_options
from os.path import basename

#Load the file paths for pupil data.
batch_cell_data = nd.get_batch_cell_data(batch=289)
parmfiles = batch_cell_data['parm'].unique().tolist()
parmfiles = [s.replace('.m', '') for s in parmfiles]
pupilfilepaths = [s + '.pup.mat' for s in parmfiles]

#Choose a recording.
recording_to_analyze = pupilfilepaths[0]
#Try analyzing using the default parameters.
_, options = get_rem(recording_to_analyze)
#Look at the results, adjust the parameters if necessary.
options["rem_max_pupil_sd"] = 0.03
#Check if the changes to the parameters gives better results.
_, options = get_rem(recording_to_analyze, **options)
#Once the results are acceptable, save them in the cache.
cache_rem_options(recording_to_analyze, **options)

#To review all analyzed recordings in the batch:
for recording in pupilfilepaths:
    try:
        get_rem(recording, **load_rem_options(recording))
    except ValueError:
        continue
예제 #5
0
#for PCA
from sklearn.decomposition import PCA
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler

from nems import db
from nems_lbhb.baphy_experiment import BAPHYExperiment
from nems_lbhb.motor import face_tools

import importlib
importlib.reload(face_tools)
plt.close('all')

batch = 324
siteid = "CLT021a"
df = db.get_batch_cell_data(batch=batch, cellid=siteid)
parmfiles = list(df.reset_index()['parm'].unique())
vid_paths = [f.replace('.m', '.lick.avi') for f in parmfiles]
f = face_tools.summary_plot(vid_paths[1:2])

f.savefig('/auto/users/svd/projects/free_moving/face_pca.pdf')
"""
#parmfile = '/auto/data/daq/Clathrus/training2022/Clathrus_2022_01_11_TBP_1.m'
#parmfile = '/auto/data/daq/Clathrus/CLT011/CLT011a05_a_TBP.m'

parmfile1 = '/auto/data/daq/Clathrus/CLT021/CLT021a04_a_TBP.m'
experiment = BAPHYExperiment(parmfile=parmfile1)
rec1 = experiment.get_recording(rasterfs=30, recache=False, dlc=True,
                               resp=True, stim=False, dlc_threshold=0.25)

#parmfile2 = '/auto/data/daq/Clathrus/CLT021/CLT021a05_p_TBP.m'