Esempio n. 1
0
    def test_KCSD_1D_zero_csd(self):
        """if measured potential is 0, the calculated CSD should be 0"""

        params = {'n_sources': 20, 'dist_density': 20,
                  'source_type': 'gauss_lim'}
        k_zero = KCSD(elec_pos=np.array([[1.0], [2.0], [3.0], [4.0], [5.0]]),
                      sampled_pots=np.array([[0.0], [0.0], [0.0], [0.0], [0.0]]),
                      params=params)
        k_zero.estimate_csd()
        self.assertAlmostEqual(norm(k_zero.solver.estimated_csd), 0.0, places=10)
def csd_est_using_kCSD(probe_loc, lfp_bar, lambd=0.0, sigma = sigma):
    elec_pos = np.expand_dims(probe_loc, axis=1)
    pots = np.expand_dims(lfp_bar, axis=1)
    params = {'gdX': np.diff(probe_loc)[0], 'gdY': np.diff(probe_loc)[0], sigma:sigma, lambd:lambd }

    k = KCSD(elec_pos, pots, params)
    k.solver.lambd = lambd
    k.estimate_pots()
    k.estimate_csd()
    return k.solver.space_X.ravel(), k.solver.estimated_csd.ravel()*sigma
Esempio n. 3
0
 def test_KCSD_3D_zero_pot(self):
     """if the input pots are zero, estimated pots and csd should be zero"""
     elec_pos = np.array([(0, 0, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0),
                          (0, 1, 1), (1, 1, 0), (1, 0, 1), (1, 1, 1)])
     pots = np.array([[0], [0], [0], [0], [0], [0], [0], [0]])
     params = {'gdX': 0.2, 'gdY': 0.2, 'gdZ': 0.2, 'n_src': 10}
     k = KCSD(elec_pos, pots, params)
     k.estimate_pots()
     k.estimate_csd()
     for pot in k.solver.estimated_pots.flatten():
         self.assertAlmostEqual(pot, 0.0, places=5)
     for csd in k.solver.estimated_csd.flatten():
         self.assertAlmostEqual(csd, 0.0, places=5)
Esempio n. 4
0
    def test_KCSD_1D_csd_reconstruction(self):
        """reconstructed csd should be similar to model csd"""

        params = {'sigma': self.sigma, 'source_type': 'gauss_lim',
                  'x_min': self.xmin, 'x_max': self.xmax, 'h': self.h}
        k = KCSD(self.elec_pos, self.meas_pot, params)
        k.estimate_csd()
        """print np.max(k.estimated_csd)
        plot(k.estimated_csd)
        plot(self.true_csd)
        show()
        print k.X_src"""
        for estimated_csd, true_csd in zip(k.solver.estimated_csd, self.true_csd):
            self.assertAlmostEqual(estimated_csd, true_csd, places=1)
Esempio n. 5
0
    def test_KCSD_1D_zero_csd(self):
        """if measured potential is 0, the calculated CSD should be 0"""

        params = {
            'n_sources': 20,
            'dist_density': 20,
            'source_type': 'gauss_lim'
        }
        k_zero = KCSD(elec_pos=np.array([[1.0], [2.0], [3.0], [4.0], [5.0]]),
                      sampled_pots=np.array([[0.0], [0.0], [0.0], [0.0],
                                             [0.0]]),
                      params=params)
        k_zero.estimate_csd()
        self.assertAlmostEqual(norm(k_zero.solver.estimated_csd),
                               0.0,
                               places=10)
Esempio n. 6
0
 def test_KCSD_3D_zero_pot(self):
     """if the input pots are zero, estimated pots and csd should be zero"""
     elec_pos = np.array([(0, 0, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0),
                         (0, 1, 1), (1, 1, 0), (1, 0, 1), (1, 1, 1)])
     pots = np.array([[0], [0], [0], [0], [0], [0], [0], [0]])
     params = {
         'gdX': 0.2,
         'gdY': 0.2,
         'gdZ': 0.2,
         'n_src': 10
     }
     k = KCSD(elec_pos, pots, params)
     k.estimate_pots()
     k.estimate_csd()
     for pot in k.solver.estimated_pots.flatten():
         self.assertAlmostEqual(pot, 0.0, places=5)
     for csd in k.solver.estimated_csd.flatten():
         self.assertAlmostEqual(csd, 0.0, places=5)
Esempio n. 7
0
    def test_KCSD_1D_csd_reconstruction(self):
        """reconstructed csd should be similar to model csd"""

        params = {
            'sigma': self.sigma,
            'source_type': 'gauss_lim',
            'x_min': self.xmin,
            'x_max': self.xmax,
            'h': self.h
        }
        k = KCSD(self.elec_pos, self.meas_pot, params)
        k.estimate_csd()
        """print np.max(k.estimated_csd)
        plot(k.estimated_csd)
        plot(self.true_csd)
        show()
        print k.X_src"""
        for estimated_csd, true_csd in zip(k.solver.estimated_csd,
                                           self.true_csd):
            self.assertAlmostEqual(estimated_csd, true_csd, places=1)