def test_lfpcalc_calc_lfp_pointsource_moi_infinite_slice(self): """ Test that infinitely thick slice does not affect potential. """ sigma_T = 0.3 sigma_G = 0.0 sigma_S = 1.5 h = 1e10 steps = 20 cell = DummyCell(z=np.array([[100, 100]])) with_saline = lfpcalc.calc_lfp_pointsource_moi(cell, x=0, y=0, z=50, sigma_T=sigma_T, sigma_G=sigma_G, sigma_S=sigma_S, r_limit=cell.d / 2, h=h, steps=steps) without_saline = lfpcalc.calc_lfp_pointsource_moi(cell, x=0, y=0, z=50, sigma_T=sigma_T, sigma_G=sigma_G, sigma_S=sigma_T, r_limit=cell.d / 2, h=h, steps=steps) np.testing.assert_almost_equal(with_saline, without_saline)
def test_lfpcalc_calc_lfp_pointsource_moi_saline_effect(self): """ Test that the saline bath decreases signal as expected """ sigma_T = 0.3 sigma_G = 0.0 sigma_S = 1.5 h = 200 steps = 20 cell = DummyCell(z=np.array([[100, 100]])) with_saline = lfpcalc.calc_lfp_pointsource_moi(cell, x=0, y=0, z=0, sigma_T=sigma_T, sigma_G=sigma_G, sigma_S=sigma_S, r_limit=cell.d / 2, h=h, steps=steps) without_saline = lfpcalc.calc_lfp_pointsource_moi(cell, x=0, y=0, z=0, sigma_T=sigma_T, sigma_G=sigma_G, sigma_S=sigma_T, r_limit=cell.d / 2, h=h, steps=steps) np.testing.assert_array_less(with_saline, without_saline)
def test_lfpcalc_calc_lfp_pointsource_moi_01(self): """ Test that ECoG scenario gives expected analytical result """ sigma_T = 0.3 sigma_G = 0.3 sigma_S = 1.5 h = 5000 steps = 20 cell = DummyCell(x=np.array([[0, 0]]), z=np.array([[h - 50, h - 50]])) source_scaling = (sigma_T - sigma_S) / (sigma_S + sigma_T) z = h - 20 # Recording position z <= h, z != cell.z.mean(axis=-1)[0] analytic = cell.imem[0] / (4 * np.pi * sigma_T) * ( 1 / np.abs(z - cell.z.mean(axis=-1)[0]) + # real source # image source source_scaling / np.abs(z - (2 * h - cell.z.mean(axis=-1)[0]))) moi_method_lfpy = lfpcalc.calc_lfp_pointsource_moi(cell.x, cell.y, cell.z, x=0., y=0, z=z, sigma_T=sigma_T, sigma_G=sigma_G, sigma_S=sigma_S, r_limit=cell.d / 2, h=h, steps=steps) np.testing.assert_equal(analytic, moi_method_lfpy)
def test_lfpcalc_calc_lfp_pointsource_moi_00(self): """ Test slice where all layers have same conductivity reproduces isotropic case. """ sigma_T = 0.3 sigma_G = 0.3 sigma_S = 0.3 h = 300 steps = 20 cell = DummyCell(np.array([[h / 2, h / 2]])) in_vivo = lfpcalc.calc_lfp_pointsource(cell.x, cell.y, cell.z, x=0.5, y=0, z=1, sigma=sigma_T, r_limit=cell.d / 2) in_vitro = lfpcalc.calc_lfp_pointsource_moi(cell.x, cell.y, cell.z, x=0.5, y=0, z=1, sigma_T=sigma_T, sigma_G=sigma_G, sigma_S=sigma_S, r_limit=cell.d / 2, h=h, steps=steps) np.testing.assert_equal(in_vivo, in_vitro)
def test_lfpcalc_calc_lfp_pointsource_moi_20steps(self): """ Test that the calc_lfp_pointsource_moi reproduces previously known nummerical value """ sigma_T = 0.3 sigma_G = 0.0 sigma_S = 1.5 h = 200 steps = 20 correct = 0.00108189 cell = DummyCell(x=np.array([[0., -200.]]), z=np.array(([[0., 220.]]))) calculated = lfpcalc.calc_lfp_pointsource_moi(cell.x, cell.y, cell.z, x=100, y=0, z=0, sigma_T=sigma_T, sigma_G=sigma_G, sigma_S=sigma_S, r_limit=cell.d / 2, h=h, steps=steps) np.testing.assert_almost_equal(correct, calculated, 5)
def test_lfpcalc_calc_lfp_pointsource_moi_04(self): """ Test that slice with zero-conductivity MEA region (z<0) has twice the potential as in vivo case at MEA electrode plane """ sigma_T = 0.3 sigma_G = 0.0 sigma_S = 0.3 h = 200 steps = 3 cell = DummyCell(z=np.array([[50, 50]])) in_vivo = lfpcalc.calc_lfp_pointsource(cell.x, cell.y, cell.z, x=50., y=0, z=0, sigma=sigma_T, r_limit=cell.d / 2) in_vitro = lfpcalc.calc_lfp_pointsource_moi(cell.x, cell.y, cell.z, x=50, y=0, z=0, sigma_T=sigma_T, sigma_G=sigma_G, sigma_S=sigma_S, r_limit=cell.d / 2, h=h, steps=steps) np.testing.assert_almost_equal(2 * in_vivo, in_vitro, decimal=9)
def test_lfpcalc_calc_lfp_pointsource_moi_02(self): """ Very close to point source, in vivo and in vitro have similar results, e.g., the positions should be adjusted similarly. """ sigma_T = 0.3 sigma_G = 0.0 sigma_S = 1.5 h = 2000 steps = 20 cell = DummyCell(z=np.array([[h / 2, h / 2]])) in_vivo = lfpcalc.calc_lfp_pointsource(cell.x, cell.y, cell.z, x=0.5, y=0, z=h / 2, sigma=sigma_T, r_limit=cell.d / 2) in_vitro = lfpcalc.calc_lfp_pointsource_moi(cell.x, cell.y, cell.z, x=0.5, y=0, z=h / 2, sigma_T=sigma_T, sigma_G=sigma_G, sigma_S=sigma_S, r_limit=cell.d / 2, h=h, steps=steps) np.testing.assert_almost_equal(in_vivo, in_vitro, 4)