コード例 #1
0
def run():
    logging.basicConfig(level=logging.INFO)
    
    good_trials = try_cache('Good trials')
    animal_sess_combs = [(animal,session) for animal in [66,70] 
                         for session in good_trials[animal]]
    
    _, good_clusters = get_good_clusters(0)
    
    for animal, session in animal_sess_combs:
        fn, trigger_tm = load_mux(animal, session)
        vl = load_vl(animal,fn)
        cls = {tetrode:load_cl(animal,fn,tetrode) for tetrode in range(1,17)}
        
        
        for tetrode,cl in cls.items():
            if tetrode not in good_clusters: 
                import pdb; pdb.set_trace()
                continue
            for cell in good_clusters[tetrode]:
                logging.info('Finding spike locations for animal %i, session %i, tetrode %i, cell %i',animal, session, tetrode,cell)
                cache_key = (cl['Label'][::10],vl['xs'][::10],trigger_tm,cell)
                spk_i = spike_loc(cl, vl, trigger_tm, cell, key=None)
                if spk_i is np.NAN: break
                store_in_cache(cache_key,spk_i)
コード例 #2
0
def run():
    logging.basicConfig(level=logging.INFO)

    good_trials = try_cache("Good trials")
    animal_sess_combs = [(animal, session) for animal in [66, 70] for session in good_trials[animal]]

    _, good_clusters = get_good_clusters(0)

    for animal, session in animal_sess_combs:
        fn, trigger_tm = load_mux(animal, session)
        vl = load_vl(animal, fn)
        cls = {tetrode: load_cl(animal, fn, tetrode) for tetrode in range(1, 17)}

        for tetrode, cl in cls.items():
            if tetrode not in good_clusters:
                import pdb

                pdb.set_trace()
                continue
            for cell in good_clusters[tetrode]:
                logging.info(
                    "Finding spike locations for animal %i, session %i, tetrode %i, cell %i",
                    animal,
                    session,
                    tetrode,
                    cell,
                )
                cache_key = (cl["Label"][::10], vl["xs"][::10], trigger_tm, cell)
                spk_i = spike_loc(cl, vl, trigger_tm, cell, key=None)
                if spk_i is np.NAN:
                    break
                store_in_cache(cache_key, spk_i)
コード例 #3
0
def cluster_graphs():
    animal = 70
    session = 8

    # Filenames (fn) are named descriptively:
    # session 18:14:04 on day 10/25/2013
    # load virmenLog75\20131025T181404.cmb.mat

    #for tetrode in range(1,17):
    for tetrode in [13]:
        for context in [1, -1]:
            global clrs
            clrs = ['b', 'g', 'r', 'c', 'm', 'k', 'b', 'g', 'r', 'c', 'm', 'k']

            fn, trigger_tm = load_mux(animal, session)
            cl = load_cl(animal, fn, tetrode)
            vl = load_vl(animal, fn)

            spk_is = []
            #for cell in range(2,100):
            for cell in [3]:
                cache_key = (cl['Label'][::10], vl['xs'][::10], trigger_tm,
                             cell)
                spk_i = spike_loc(cl, vl, trigger_tm, cell, cache_key)
                if spk_i is np.NAN: break
                cntx_is = np.nonzero(vl['Task'] == context)[0]
                spk_i = np.intersect1d(cntx_is, spk_i)
                spk_is.append(spk_i)

            tot_spks = len(spk_is)
            if tot_spks == 0: continue
            subp_x, subp_y = get_subplot_size(tot_spks)
            #plt.figure()
            for spk_i, i in zip(spk_is, range(tot_spks)):
                plt.subplot(subp_x, subp_y, i + 1)
                if context == 1:
                    plt.plot(vl['xs'], vl['ys'], zorder=1, color='k')
                    plt.scatter(vl['xs'][spk_i],
                                vl['ys'][spk_i],
                                zorder=2,
                                color='b',
                                label='Clockwise')
                else:
                    plt.scatter(vl['xs'][spk_i],
                                vl['ys'][spk_i],
                                zorder=2,
                                color='r',
                                label='Counterclockwise')

                #plot_spks(vl, spk_i, i+2)
            #plt.suptitle('Animal %i, Tetrode %i, Session %i, Context:%i'%(animal,tetrode,session,context))

            plt.xlim([-60, 60])
            plt.ylim([-60, 60])
            plt.xlabel('Position (in)')
            plt.ylabel('Position (in)')
        plt.show()
コード例 #4
0
def count_cells(vl,cls,trigger_tm,good_clusters):
    t_cells = {}
    for tetrode,cl in cls.items():
        if tetrode not in good_clusters: continue
        for cell in good_clusters[tetrode]:
            logging.info('Finding spike locations for tetrode %i, cell %i',tetrode,cell)
            cache_key = (cl['Label'][::10],vl['xs'][::10],trigger_tm,cell)
            spk_i = spike_loc(cl, vl, trigger_tm, cell, cache_key)
            if spk_i is np.NAN: break
            t_cells[(tetrode,cell)] = spk_i
    return t_cells
コード例 #5
0
def count_cells(vl, cls, trigger_tm, good_clusters):
    t_cells = {}
    for tetrode, cl in cls.items():
        if tetrode not in good_clusters: continue
        for cell in good_clusters[tetrode]:
            logging.info('Finding spike locations for tetrode %i, cell %i',
                         tetrode, cell)
            cache_key = (cl['Label'][::10], vl['xs'][::10], trigger_tm, cell)
            spk_i = spike_loc(cl, vl, trigger_tm, cell, cache_key)
            if spk_i is np.NAN: break
            t_cells[(tetrode, cell)] = spk_i
    return t_cells
コード例 #6
0
def cluster_graphs():
    animal = 70
    session = 8
    
    # Filenames (fn) are named descriptively:
    # session 18:14:04 on day 10/25/2013
    # load virmenLog75\20131025T181404.cmb.mat
    
    #for tetrode in range(1,17):  
    for tetrode in [13]:  
        for context in [1,-1]:
            global clrs
            clrs = ['b','g','r','c','m','k','b','g','r','c','m','k']
            
            fn, trigger_tm = load_mux(animal, session)
            cl = load_cl(animal,fn,tetrode)
            vl = load_vl(animal,fn)
        
            spk_is = []
            #for cell in range(2,100):
            for cell in [3]:
                cache_key = (cl['Label'][::10],vl['xs'][::10],trigger_tm,cell)
                spk_i = spike_loc(cl, vl, trigger_tm, cell,cache_key)
                if spk_i is np.NAN: break
                cntx_is = np.nonzero(vl['Task']==context)[0]
                spk_i = np.intersect1d(cntx_is, spk_i)
                spk_is.append(spk_i)
    
            tot_spks = len(spk_is)
            if tot_spks == 0: continue
            subp_x, subp_y = get_subplot_size(tot_spks)
            #plt.figure()
            for spk_i, i in zip(spk_is, range(tot_spks)):
                plt.subplot(subp_x,subp_y, i+1)
                if context==1: 
                    plt.plot(vl['xs'],vl['ys'],zorder=1,color='k')
                    plt.scatter(vl['xs'][spk_i],vl['ys'][spk_i],zorder=2,color='b',
                                label='Clockwise')
                else:
                    plt.scatter(vl['xs'][spk_i],vl['ys'][spk_i],zorder=2,color='r',
                                label='Counterclockwise')
    
                #plot_spks(vl, spk_i, i+2)
            #plt.suptitle('Animal %i, Tetrode %i, Session %i, Context:%i'%(animal,tetrode,session,context))
            
            plt.xlim([-60,60])
            plt.ylim([-60,60])
            plt.xlabel('Position (in)')
            plt.ylabel('Position (in)')
        plt.show()
コード例 #7
0
def count_cells(vl,cls,trigger_tm,good_clusters):
    ''' Returns a dictionary of tracked cells of the form
    t_cells[(tetrode,cell)] = indices of spikes of this cell '''
    
    t_cells = {}
    for tetrode,cl in cls.items():
        if tetrode not in good_clusters: continue
        for cell in good_clusters[tetrode]:
            logging.info('Finding spike locations for tetrode %i, cell %i',tetrode,cell)
            cache_key = (cl['Label'][::10],vl['xs'][::10],trigger_tm,cell)
            spk_i = spike_loc(cl, vl, trigger_tm, cell, cache_key)
            if spk_i is np.NAN: break
            t_cells[(tetrode,cell)] = spk_i
    if len(t_cells) == 0: raise Exception('No cells found')
    return t_cells
コード例 #8
0
def count_cells(vl, cls, trigger_tm, good_clusters):
    ''' Returns a dictionary of tracked cells of the form
    t_cells[(tetrode,cell)] = indices of spikes of this cell '''

    t_cells = {}
    for tetrode, cl in cls.items():
        if tetrode not in good_clusters: continue
        for cell in good_clusters[tetrode]:
            logging.info('Finding spike locations for tetrode %i, cell %i',
                         tetrode, cell)
            cache_key = (cl['Label'][::10], vl['xs'][::10], trigger_tm, cell)
            spk_i = spike_loc(cl, vl, trigger_tm, cell, cache_key)
            if spk_i is np.NAN: break
            t_cells[(tetrode, cell)] = spk_i
    if len(t_cells) == 0: raise Exception('No cells found')
    return t_cells