Пример #1
0
def find_silent_neurons(neurons, num_trials, dataDir):
    """
    Finds neurons that did not fire in any of the training trials
    """
    num_successful_trials = [
    ]  # number of trials in which dendritic bursts were produced

    for neuron_id in neurons:
        counter = 0  # counter to count successful trials
        for n in range(num_trials):
            filename = dataDir + "RA" + str(neuron_id) + "_trial" + str(
                n + 1) + ".bin"
            (t, Vs, _, _, _, Vd, _, _, _, _, _, _, _, _, _, _, _,
             _) = reading.read_hh2(filename)

            burst_times, burst_indices = get_burst_times(
                t, Vd)  # obtain dendritic burst times

            if len(burst_times) > 0:
                counter += 1
        num_successful_trials.append(counter)

    not_fired = [
        n for i, n in enumerate(neurons) if num_successful_trials[i] == 0
    ]

    return not_fired, num_successful_trials
Пример #2
0
def get_burst_times(filename):
    """
    Extracts dendritic burst indices from file with HVC(RA) data
    """
    (t, _, _, _, _, Vd, _, _, _, _, _, _, _, _, _, _, _, _) = reading.read_hh2(filename)
    
    burst_indices = []
    burst_times = []
    flag = False
        
    for i, v in enumerate(Vd):
        if flag == False and v >= DENDRITIC_THRESHOLD:
            flag = True
        elif flag == True and v < DENDRITIC_THRESHOLD:
            burst_indices.append(i)
            burst_times.append(t[i])
            flag = False
        
    return burst_times, burst_indices
Пример #3
0
def average_inh_input_burst_difference_one_neuron(neuron_id, num_trials):
    """
    Computes average time difference between inhibitory inputs and dendritic bursts 
    for the same neuron over num_trials trials
    """
    dt_all_trials = []

    num_successful_trials = 0  # number of trials when neuron fired
    # store time differences for all trials in one array
    for i in range(1, num_trials + 1):
        filename = dataDir + "RA" + str(neuron_id) + "_trial" + str(i) + ".bin"
        (t, Vs, _, _, _, Vd, _, _, _, _, Gexc_d, Ginh_d, _, _, _, _, _,
         _) = reading.read_hh2(filename)

        dt = inh_input_burst_difference(t, Vd, Ginh_d)

        if len(dt) > 0:
            dt_all_trials.extend(dt)
            num_successful_trials += 1

    dt_all_trials = sorted(dt_all_trials)

    #print dt_all_trials

    if len(dt_all_trials) == 0:
        print("dt_all_trials is empty for neuron {0}".format(neuron_id))

    else:
        min_dt = np.floor(min(dt_all_trials))

        if min_dt % 2 == 0:
            min_dt -= 1

        bins = np.arange(
            min_dt,
            np.ceil(max(dt_all_trials)) + INHIBITORY_SPIKE_RESOLUTION,
            INHIBITORY_SPIKE_RESOLUTION)

        hist, bins = np.histogram(dt_all_trials, bins=bins)
        hist = hist / float(num_successful_trials)

        return hist, bins
Пример #4
0
"""
Created on Wed Feb  8 17:43:01 2017

@author: jingroup

Script plots membrane traces for same HVC(RA) neuron
"""
import reading
import matplotlib.pyplot as plt

file1 = "/home/eugene/Output/networks/RandomChainTest240217/RA/RA256_trial1.bin"
file2 = "/home/eugene/Output/networks/RandomChainTest240217/RA/RA256_trial2.bin"
file3 = "/home/eugene/Output/networks/RandomChainTest240217/RA/RA256_trial3.bin"

(t_1, Vs_1, _, _, _, Vd_1, _, _, _, _, Gexc_d_1, Ginh_d_1, _, _, _, _, _,
 _) = reading.read_hh2(file1)
(t_2, Vs_2, _, _, _, Vd_2, _, _, _, _, Gexc_d_2, Ginh_d_2, _, _, _, _, _,
 _) = reading.read_hh2(file2)
(t_3, Vs_3, _, _, _, Vd_3, _, _, _, _, Gexc_d_3, Ginh_d_3, _, _, _, _, _,
 _) = reading.read_hh2(file3)

f = plt.figure()
ax1 = f.add_subplot(311)

ax1.plot(t_1, Vs_1, 'r')
ax1.plot(t_2, Vs_2, 'b')
ax1.plot(t_3, Vs_3, 'm')
ax1.set_ylabel("Vs (mV)")

ax2 = f.add_subplot(312)
Пример #5
0
#simFileAbs = os.path.join(script_dir, simFileRel)
#testFileAbs = os.path.join(script_dir, testFileRel)
#print repr(fileContent)


#print dataPointsNumber[0]
#print len(fileContent[8:])


#print voltage
#print time

#print len(voltage)
#print len(time)

(t, Vs, Is, n, h, Vd, Id, r, c, Ca, Gexc_d, Ginh_d, Gexc_s, Ginh_s, Ei, flag, Nsoma, Ndend) = reading.read_hh2(simFileAbs)

print Nsoma
#print "Vs", Vs

#print "s_soma", s_s
#print "s_dend", s_d

print "Ei = ", Ei[100]
print_time_state(0)

print Vs
print t
#print(len(Vd))
#print(n[0])
#print(n[11999])
Пример #6
0
def calculate_average_input_conductance_for_neuron(neuron_id, num_trials,
                                                   dataDir):
    """
    Calculates average input conductance for neuron neuron_id. Average is taken
    for num_trials and is aligned to neuron's dendritic burst
    """
    num_points_in_window = int(WINDOW_SIZE /
                               TIMESTEP)  # number of datapoints inside window

    # if even, add one more datapoint
    if num_points_in_window % 2 == 0:
        num_points_in_window += 1

    half_window = num_points_in_window / 2
    #print half_window
    #print num_points_in_window

    exc_input = np.zeros((num_trials, num_points_in_window), np.float32)
    inh_input = np.zeros((num_trials, num_points_in_window), np.float32)

    successful_trials = np.zeros(
        num_trials,
        np.bool)  # array with bools indicating trials with dendritic bursts

    for n in range(num_trials):
        filename = dataDir + "RA" + str(neuron_id) + "_trial" + str(n +
                                                                    1) + ".bin"
        (t, Vs, _, _, _, Vd, _, _, _, _, Gexc_d, Ginh_d, _, _, _, _, _,
         _) = reading.read_hh2(filename)

        burst_times, burst_indices = get_burst_times(
            t, Vd)  # obtain dendritic burst times

        if len(burst_times) > 0:
            successful_trials[n] = True
            # loop through all dendritic burst times
            for burst_index in burst_indices:
                #for i in range(num_points_in_window):
                #exc_input[n][i] += Gexc_d[burst_index - half_window + i]
                #inh_input[n][i] += Ginh_d[burst_index - half_window + i]
                exc_input[n] += Gexc_d[(burst_index -
                                        half_window):(burst_index +
                                                      half_window + 1)]
                inh_input[n] += Ginh_d[(burst_index -
                                        half_window):(burst_index +
                                                      half_window + 1)]

            # average over number of dendritic bursts:
            exc_input[n] = exc_input[n] / float(len(burst_indices))
            inh_input[n] = inh_input[n] / float(len(burst_indices))

    #print exc_input.shape

    t_input = np.linspace(-half_window * TIMESTEP, half_window * TIMESTEP,
                          num_points_in_window)

    # if no dendritic bursts was produced
    if np.sum(successful_trials) == 0:
        average_exc_input = np.zeros(num_points_in_window, np.float32)
        average_inh_input = np.zeros(num_points_in_window, np.float32)
        return t_input, average_exc_input, average_inh_input

    else:
        average_exc_input = np.sum(exc_input[successful_trials],
                                   axis=0) / np.sum(successful_trials)
        average_inh_input = np.sum(inh_input[successful_trials],
                                   axis=0) / np.sum(successful_trials)

        return t_input, average_exc_input, average_inh_input