Ejemplo n.º 1
0
        return False
    
    return True

indices_in_bound, = np.where(np.apply_along_axis(check_in_bounds, 1, csv,
                                                 x_bounds, y_bounds))
data_thresholded = csv[indices_in_bound]
n = data_thresholded.shape[0]


def synapses_over_unmasked(row):
    s = (row[4]/row[3])*(64**3)
    return [row[0], row[1], row[2], s]
syn_unmasked = np.apply_along_axis(synapses_over_unmasked, 1, data_thresholded)
syn_normalized = syn_unmasked

a = np.apply_along_axis(lambda x:x[4]/x[3], 1, data_thresholded)
spike = a[np.logical_and(a <= 0.0015, a >= 0.0012)]
n, bins, _ = plt.hist(spike, 2000)
bin_max = np.where(n == n.max())
bin_width = bins[1]-bins[0]
syn_normalized[:,3] = syn_normalized[:,3]/(64**3)
spike = syn_normalized[np.logical_and(syn_normalized[:,3] <= 0.00131489435301+bin_width, syn_normalized[:,3] >= 0.00131489435301-bin_width)]
spike_thres = data_thresholded[np.logical_and(syn_normalized[:,3] <= 0.00131489435301+bin_width, syn_normalized[:,3] >= 0.00131489435301-bin_width)]
len_spike = len(spike_thres)

# Compare some of the bins represented the spike
xs = np.unique(spike_thres[:,0])
ys = np.unique(spike_thres[:,1])
get_image((0,10),(0,10),xs,ys,'spike'+str(0)+"_"+str(0))
def synapses_over_unmasked(row):
    s = (row[4] / row[3]) * (64 ** 3)
    return [row[0], row[1], row[2], s]


syn_unmasked = np.apply_along_axis(synapses_over_unmasked, 1, data_thresholded)
syn_normalized = syn_unmasked


# Looking at images across y, and of the layers in the y-direction
#########################################################################################
from image_builder import get_image

xs = np.unique(data_thresholded[:, 0])
ys = np.unique(data_thresholded[:, 1])

# Layer across y
get_image((0, 1), (0, len(ys) - 1), xs, ys, "across_y")
print len(ys) - 1

# Each y-layer defined by bounds of local minima in total syn density at each y
y_bounds = [(1564, 1837), (1837, 2071), (2071, 2305), (2305, 2539), (2539, 3124)]

for _, bounds in enumerate(y_bounds):
    print "for\n"
    y_lower = np.where(ys == bounds[0])[0][0]
    y_upper = np.where(ys == bounds[1])[0][0]
    print y_lower, y_upper, "hi\n"
    i = get_image((0, 1), (y_lower, y_upper), xs, ys, str(bounds[0]) + "_" + str(bounds[1]))