Exemplo n.º 1
0
    def testCreateTreeGF(self):
        self.loadBall()
        cm = CompartmentFitter(self.tree)

        # create tree with only 'L'
        tree_pas = cm.createTreeGF()
        self._checkChannels(tree_pas, [])
        # create tree with only 'Na_Ta'
        tree_na = cm.createTreeGF(['Na_Ta'])
        self._checkChannels(tree_na, ['Na_Ta'])
        # create tree with only 'Kv3_1'
        tree_k = cm.createTreeGF(['Kv3_1'])
        self._checkChannels(tree_k, ['Kv3_1'])
        # create tree with all channels
        tree_all = cm.createTreeGF(['Na_Ta', 'Kv3_1'])
        self._checkChannels(tree_all, ['Na_Ta', 'Kv3_1'])
Exemplo n.º 2
0
    def testRecalcImpedanceMatrix(self, g_inp=np.linspace(0., 0.01, 20)):
        self.loadBall()
        fit_locs = [(1, .5)]
        cm = CompartmentFitter(self.tree)
        cm.setCTree(fit_locs)

        # test only leak
        # compute impedances explicitly
        greens_tree = cm.createTreeGF(channel_names=[])
        greens_tree.setEEq(-75.)
        greens_tree.setImpedancesInTree()
        z_mat = greens_tree.calcImpedanceMatrix(fit_locs,
                                                explicit_method=False)[0]
        z_test = z_mat[:, :,
                       None] / (1. + z_mat[:, :, None] * g_inp[None, None, :])
        # compute impedances with compartmentfitter function
        z_calc = np.array([ \
                           cm.recalcImpedanceMatrix('fit locs', [g_i], \
                               channel_names=[]
                           ) \
                           for g_i in g_inp \
                          ])
        z_calc = np.swapaxes(z_calc, 0, 2)
        assert np.allclose(z_calc, z_test)

        # test with z based on all channels (passive)
        # compute impedances explicitly
        greens_tree = cm.createTreeGF(
            channel_names=list(cm.tree.channel_storage.keys()))
        greens_tree.setEEq(-75.)
        greens_tree.setImpedancesInTree()
        z_mat = greens_tree.calcImpedanceMatrix(fit_locs,
                                                explicit_method=False)[0]
        z_test = z_mat[:, :,
                       None] / (1. + z_mat[:, :, None] * g_inp[None, None, :])
        # compute impedances with compartmentfitter function
        z_calc = np.array([ \
                           cm.recalcImpedanceMatrix('fit locs', [g_i], \
                               channel_names=list(cm.tree.channel_storage.keys())) \
                           for g_i in g_inp \
                          ])
        z_calc = np.swapaxes(z_calc, 0, 2)
        assert np.allclose(z_calc, z_test)
Exemplo n.º 3
0
 def testSynRescale(self, g_inp=np.linspace(0., 0.01, 20)):
     e_rev, v_eq = 0., -75.
     self.loadBallAndStick()
     fit_locs = [(4, .7)]
     syn_locs = [(4, 1.)]
     cm = CompartmentFitter(self.tree)
     cm.setCTree(fit_locs)
     # compute impedance matrix
     greens_tree = cm.createTreeGF(channel_names=[])
     greens_tree.setEEq(-75.)
     greens_tree.setImpedancesInTree()
     z_mat = greens_tree.calcImpedanceMatrix(fit_locs + syn_locs)[0]
     # analytical synapse scale factors
     beta_calc = 1. / (1. + (z_mat[1, 1] - z_mat[0, 0]) * g_inp)
     beta_full = z_mat[0,1] / z_mat[0,0] * (e_rev - v_eq) / \
                 ((1. + (z_mat[1,1] - z_mat[0,0]) * g_inp ) * (e_rev - v_eq))
     # synapse scale factors from compartment fitter
     beta_cm = np.array([cm.fitSynRescale(fit_locs, syn_locs, [0], [g_i], e_revs=[0.])[0] \
                         for g_i in g_inp])
     assert np.allclose(beta_calc, beta_cm, atol=.020)
     assert np.allclose(beta_full, beta_cm, atol=.015)