class TestGpuGridGaussianCompute_64x64(TestCase): def setUp(self): self.grid_size = getDimensions(self) a = np.array([[3, 3], [5, 5], [3, 5], [5, 3], [4, 4]]).astype(np.float32).reshape(5, 2) self.sigma = .1 test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) # These are the individual tiles that will have information about the dataset test_tile = ViewTile((test_set,), (3, 5, 3, 5)) self.new = GpuGridGaussian(test_tile, self.grid_size, self.sigma) self.new.compute_grid() def doCleanups(self): self.new.clean_cuda() def test_shape(self): print self.new.get_grid_data() new_data = self.new.get_grid_data() new_data.shape == self.grid_size def test_max_point_value(self): g = gaussian_normal_sigma(self.sigma) new_data = self.new.get_grid_data() diff = math.fabs(new_data.max() - g) assert diff < .00001 def test_min_point_value(self): new_data = self.new.get_grid_data() assert new_data.min() < .001
class TestGpuGridGaussianStudyWindowSize(TestCase): def setUp(self): a = np.array([[750, 5], [0, 0], [1500, 0], [1500, 10], [0, 10], [237, 2], [237, 2], [1234, 7], [400, 3]]).astype(np.float32).reshape(9, 2) self.grid_size = (1024, 1024) self.sigma = .1 test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) # These are the individual tiles that will have information about the dataset test_tile = ViewTile((test_set,), (0, 1500, 0, 10)) self.new = GpuGridGaussian(test_tile, self.grid_size, self.sigma) self.new.compute_grid() def doCleanups(self): self.new.clean_cuda() def test_shape(self): new_data = self.new.get_grid_data() assert new_data.shape == self.grid_size def test_max_point_value(self): g = gaussian_normal_sigma(self.sigma) * 2.425 new_data = self.new.get_grid_data() diff = math.fabs(new_data.max() - g) print diff assert diff < .1 def test_min_point_value(self): new_data = self.new.get_grid_data() assert new_data.min() < .001
class TestRandomGpuGridGaussianComputeComplex_1024x1024(TestCase): def setUp(self): self.grid_size = getDimensions(self) a = np.array(np.random.random(400)).astype(np.float32).reshape(200, 2) self.sigma = .1 test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) # These are the individual tiles that will have information about the dataset test_tile = ViewTile((test_set,), (0, 1, 0, 1)) self.new = GpuGridGaussian(test_tile, self.grid_size, self.sigma) self.new.compute_grid() def doCleanups(self): self.new.clean_cuda() def test_shape(self): new_data = self.new.get_grid_data() assert new_data.shape == self.grid_size def test_max_greater_than(self): new_data = self.new.get_grid_data() assert new_data.max() > gaussian_normal_sigma(self.sigma) def test_min_greater_than(self): new_data = self.new.get_grid_data() assert new_data.min() > gaussian_normal_sigma(self.sigma)
class TestGpuGridGaussianCompute_32x32(TestCase): def setUp(self): self.size = getDimensions(self) a = np.array([[0, 0], [1, 1], [0, 1], [1, 0], [.5, .5]]).astype(np.float32).reshape(5, 2) sigma = .1 test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) test_tile = ViewTile((test_set,), (0, 1, 0, 1)) self.new = GpuGridGaussian(test_tile, self.size, sigma) self.new.compute_grid() self.old = GpuGaussianOld(a, (0, 1, 0, 1), self.size, sigma) self.old.compute_grid() def doCleanups(self): self.new.clean_cuda() self.old.clean_cuda() def test_equiv_arrays(self): new_data = self.new.get_grid_data() old_data = self.old.get_grid_data() assert np.array_equiv(new_data, old_data) def test_equal_arrays(self): new_data = self.new.get_grid_data() old_data = self.old.get_grid_data() assert np.array_equal(new_data, old_data) def test_size(self): new_data = self.new.get_grid_data() assert new_data.shape == self.size
class TestGpuGridGaussianCompute_2x2(TestCase): def setUp(self): self.size = getDimensions(self) a = np.array([[0, 0], [1, 1], [0, 1], [1, 0], [.5, .5]]).astype(np.float32).reshape(5, 2) sigma = .1 test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) # These are the individual tiles that will have information about the dataset test_tile = ViewTile((test_set,), (0, 1, 0, 1)) self.new = GpuGridGaussian(test_tile, self.size, sigma) self.new.compute_grid() self.old = GpuGaussianOld(test_tile.get_Data()[0].getDataSet(), test_tile.get_View().view(), self.size, sigma) self.old.compute_grid() def doCleanups(self): self.new.clean_cuda() self.old.clean_cuda() def test_equiv_arrays(self): new_data = self.new.get_grid_data() old_data = self.old.get_grid_data() assert np.array_equiv(new_data, old_data) def test_equal_arrays(self): new_data = self.new.get_grid_data() old_data = self.old.get_grid_data() assert np.array_equal(new_data, old_data) def test_size(self): new_data = self.new.get_grid_data() assert new_data.shape == self.size old_data = self.old.get_grid_data() assert old_data.shape == self.size
def setUp(self): a = np.array([[0, 0], [1, 1], [0, 1], [1, 0], [.5, .5]]).astype(np.float32).reshape(5, 2) test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) # These are the individual tiles that will have information about the dataset test_tile = ViewTile((test_set,), (0, 1, 0, 1)) self.g = GpuGridGaussian(test_tile, (32, 32), .1)
def setUp(self): self.size = getDimensions(self) a = np.array([[0, 0], [1, 1], [0, 1], [1, 0], [.5, .5]]).astype(np.float32).reshape(5, 2) sigma = .1 test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) test_tile = ViewTile((test_set,), (0, 1, 0, 1)) self.new = GpuGridGaussian(test_tile, self.size, sigma) self.new.compute_grid() self.old = GpuGaussianOld(a, (0, 1, 0, 1), self.size, sigma) self.old.compute_grid()
def setUp(self): self.size = getDimensions(self) a = np.array([[0, 0], [1, 1], [0, 1], [1, 0], [.5, .5]]).astype(np.float32).reshape(5, 2) self.sigma = .1 test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) # These are the individual tiles that will have information about the dataset test_tile = ViewTile((test_set,), (0, 1, 0, 1)) self.new = GpuGridGaussian(test_tile, self.size, self.sigma) self.new.compute_grid()
def setUp(self): a = np.array([[750, 5], [0, 0], [1500, 0], [1500, 10], [0, 10], [237, 2], [237, 2], [1234, 7], [400, 3]]).astype(np.float32).reshape(9, 2) self.grid_size = (1024, 1024) self.sigma = .1 test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) # These are the individual tiles that will have information about the dataset test_tile = ViewTile((test_set,), (0, 1500, 0, 10)) self.new = GpuGridGaussian(test_tile, self.grid_size, self.sigma) self.new.compute_grid()
def setUp(self): self.grid_size = getDimensions(self) a = np.array([[3, 3], [5, 5], [3, 5], [5, 3], [4, 4]]).astype(np.float32).reshape(5, 2) sigma = .07 test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) # These are the individual tiles that will have information about the dataset test_tile = ViewTile((test_set,), (3, 5, 3, 5)) self.new = GpuGridGaussian(test_tile, self.grid_size, sigma) self.new.compute_grid() self.old = GpuGaussianOld(test_tile.get_Data()[0].getDataSet(), test_tile.get_View().view(), self.grid_size, sigma) self.old.compute_grid()
class TestGpuGridGaussianNoCompute(TestCase): def setUp(self): a = np.array([[0, 0], [1, 1], [0, 1], [1, 0], [.5, .5]]).astype(np.float32).reshape(5, 2) test_set = CellTypeDataSet("", a, rgb=(0, .5, .5)) # These are the individual tiles that will have information about the dataset test_tile = ViewTile((test_set,), (0, 1, 0, 1)) self.g = GpuGridGaussian(test_tile, (32, 32), .1) def doCleanups(self): self.g.clean_cuda() def test_array_equiv(self): image = self.g.get_grid_data() compare = np.zeros_like(image) assert np.array_equiv(image, compare) def test_array_equal(self): image = self.g.get_grid_data() compare = np.zeros_like(image) assert np.array_equal(image, compare)
print str(gc_data.shape[0]) + " Granule cell spikes, and" print str(bc_data.shape[0]) + " Basket cell spikes." mea_set = CellTypeDataSet("Cell # \n(MEA 0 - 6599, ", mea_data, rgb=(0, 0, 0.5)) lea_set = CellTypeDataSet("\nLEA 660 - 11199)", lea_data, rgb=(0.5, 0, 0)) gc_set = CellTypeDataSet("GC Cell Septotemporal Position (mm)", gc_data, rgb=(0, 0.5, 0.5)) bc_set = CellTypeDataSet("Basket Cells", bc_data, rgb=(0.5, 0, 0.5)) mea_lea_tile = ViewTile((mea_set, lea_set), (tstart, tstop, 0, sum(numCells[0:2]))) gc_tile = ViewTile((gc_set,), (tstart, tstop, 0, 10)) bc_tile = ViewTile((bc_set,), (tstart, tstop, 0, 10)) # Values are normalized from [0-1500, 0-n] to grid of [0-1, 0-1]. Sigma choice should be between 0-1 sigma = 0.001 gc = GpuGridGaussian(gc_tile, (1024, 1024), sigma) gc.compute_grid() gc.save_image("tmp/gc_data_gaussian_sigma=" + str(sigma) + ".bin") gc.show_image() gc.clean_cuda() bc = GpuGridGaussian(bc_tile, (1024, 1024), sigma) bc.compute_grid() bc.save_image("tmp/bc_data_gaussian_sigma=" + str(sigma) + ".bin") bc.show_image() bc.clean_cuda() mea_lea = GpuGridGaussian(mea_lea_tile, (1024, 1024), sigma) mea_lea.compute_grid() mea_lea.save_image("tmp/mea_lea_data_gaussian_sigma=" + str(sigma) + ".bin") mea_lea.show_image()