def testFilterSpeedBandwidth(n_iterations=5): speeds = np.arange(1, 9.5, 0.5) inputs = [] for speed in speeds: for j in xrange(n_iterations): seed = [np.random.randint(999), np.random.randint(999)] inputs.append( gd.generateDots(seed, 0, 0, 5, 60, 0, 1, speed)) pool = multiprocessing.Pool() out = pool.map(filterDots, inputs) pool.close() data = np.array(out) summed_me = np.sum(data, axis=1) mean_me = np.mean(summed_me.reshape(-1, n_iterations), axis=1) fig = plt.figure() ax = fig.add_subplot(111) colors = b2mpl.get_map('Set1', 'Qualitative', 3).mpl_colors ax.add_line(plt.Line2D(speeds, mean_me, color=colors[0])) ax.set_xlabel('Motion speed (degrees per s))') ax.set_ylabel('Total motion energy') majorLocator = MultipleLocator(1) ax.xaxis.set_major_locator(majorLocator) majorLocator = MultipleLocator(50) ax.yaxis.set_major_locator(majorLocator) ax.set_xlim(1, 9) ax.set_ylim(np.min(mean_me) - 10, np.max(mean_me) + 10) sns.despine(offset=5, trim=True) plt.tight_layout() return speeds, mean_me
def testFilterLinearCoh(n_iterations=5): cohs = np.array([-0.512, -0.256, -0.128, -0.064, -0.032, 0, 0.032, 0.064, 0.128, 0.256, 0.512]) inputs = [] for coh in cohs: for j in xrange(n_iterations): seed = [np.random.randint(999), np.random.randint(999)] if np.sign(coh) == 1: direction = 0 else: direction = 180 inputs.append( gd.generateDots(seed, 0, 0, 5, 60, direction, np.abs(coh), 5)) pool = multiprocessing.Pool() out = pool.map(filterDots, inputs) pool.close() data = np.array(out) summed_me = np.sum(data, axis=1) mean_me = np.mean(summed_me.reshape(-1, n_iterations), axis=1) fig = plt.figure() ax = fig.add_subplot(111) colors = b2mpl.get_map('Set1', 'Qualitative', 3).mpl_colors ax.add_line(plt.Line2D(cohs, mean_me, color=colors[0])) ax.set_xlabel('Motion strength (proportion coh)') ax.set_ylabel('Total motion energy') ax.set_xlim(-.61, .61) ax.set_ylim(np.min(mean_me) * 1.2, np.max(mean_me) * 1.2) sns.despine(offset=5, trim=True) plt.tight_layout() return cohs, mean_me