コード例 #1
0
 def loadThreeCompartmentModel(self):
     # simple 3 compartment model
     pnode = CompartmentNode(0, ca=1.9e-6, g_l=1.8e-3)
     self.ctree = CompartmentTree(root=pnode)
     cnode = CompartmentNode(1, ca=2.4e-6, g_l=0.3e-4, g_c=3.9)
     self.ctree.addNodeWithParent(cnode, pnode)
     lnode0 = CompartmentNode(2, ca=1.9e-6, g_l=0.3e-4, g_c=3.8e-3)
     self.ctree.addNodeWithParent(lnode0, cnode)
コード例 #2
0
ファイル: test_neurontree.py プロジェクト: unibe-cns/NEAT
    def loadTwoCompartmentModel(self, w_locinds=True):
        # simple two compartment model
        pnode = CompartmentNode(0, ca=1.5e-5, g_l=2e-3)
        self.ctree = CompartmentTree(root=pnode)
        cnode = CompartmentNode(1, ca=2e-6, g_l=3e-4, g_c=4e-3)
        self.ctree.addNodeWithParent(cnode, pnode)

        if w_locinds:
            self.addLocinds()
コード例 #3
0
 def loadMultiDendModel(self):
     # simple 3 compartment model
     pnode = CompartmentNode(0, ca=1.9e-6, g_l=1.8e-3)
     self.ctree = CompartmentTree(root=pnode)
     cnode0 = CompartmentNode(1, ca=2.4e-6, g_l=0.3e-4, g_c=3.9)
     self.ctree.addNodeWithParent(cnode0, pnode)
     cnode1 = CompartmentNode(2, ca=1.9e-6, g_l=0.4e-4, g_c=3.8e-3)
     self.ctree.addNodeWithParent(cnode1, pnode)
     cnode2 = CompartmentNode(3, ca=1.3e-6, g_l=0.5e-4, g_c=2.7e-2)
     self.ctree.addNodeWithParent(cnode2, pnode)
コード例 #4
0
    def _initTree1(self):
        # 1   2
        #  \ /
        #   0
        croot = CompartmentNode(0, loc_ind=0)
        cnode1 = CompartmentNode(1, loc_ind=1)
        cnode2 = CompartmentNode(2, loc_ind=2)

        ctree = CompartmentTree(root=croot)
        ctree.addNodeWithParent(cnode1, croot)
        ctree.addNodeWithParent(cnode2, croot)

        self.ctree = ctree
コード例 #5
0
 def loadTModel(self):
     # simple T compartment model
     # pnode = CompartmentNode(0, ca=1.5e-5, g_l=2e-3)
     # self.ctree = CompartmentTree(root=pnode)
     # cnode = CompartmentNode(1, ca=1.5e-6, g_l=2.5e-4, g_c=2e-3)
     # self.ctree.addNodeWithParent(cnode, pnode)
     # lnode0 = CompartmentNode(2, ca=1.5e-6, g_l=2.5e-4, g_c=2e-3)
     # self.ctree.addNodeWithParent(lnode0, cnode)
     # lnode1 = CompartmentNode(3, ca=1.5e-6, g_l=2.5e-4, g_c=2e-3)
     # self.ctree.addNodeWithParent(lnode1, cnode)
     pnode = CompartmentNode(0, ca=1.5e-5, g_l=2e-3)
     self.ctree = CompartmentTree(root=pnode)
     cnode = CompartmentNode(1, ca=2e-6, g_l=3e-4, g_c=4e-3)
     self.ctree.addNodeWithParent(cnode, pnode)
     lnode0 = CompartmentNode(2, ca=1.5e-6, g_l=2.5e-4, g_c=3e-3)
     self.ctree.addNodeWithParent(lnode0, cnode)
     lnode1 = CompartmentNode(3, ca=1.5e-6, g_l=2.5e-4, g_c=5e-3)
     self.ctree.addNodeWithParent(lnode1, cnode)
コード例 #6
0
    def _initTree2(self):
        # 3
        # |
        # 2
        # |
        # 1
        # |
        # 0
        croot = CompartmentNode(0, loc_ind=0)
        cnode1 = CompartmentNode(1, loc_ind=1)
        cnode2 = CompartmentNode(2, loc_ind=2)
        cnode3 = CompartmentNode(3, loc_ind=3)

        ctree = CompartmentTree(root=croot)
        ctree.addNodeWithParent(cnode1, croot)
        ctree.addNodeWithParent(cnode2, cnode1)
        ctree.addNodeWithParent(cnode3, cnode2)

        self.ctree = ctree
コード例 #7
0
    def _initTree3(self):
        # 4 5 6 7   8
        #  \|/   \ /
        #   1  2  3
        #    \ | /
        #     \|/
        #      0
        cns = [CompartmentNode(ii, loc_ind=ii) for ii in range(9)]

        ctree = CompartmentTree(root=cns[0])
        # first order children
        ctree.addNodeWithParent(cns[1], cns[0])
        ctree.addNodeWithParent(cns[2], cns[0])
        ctree.addNodeWithParent(cns[3], cns[0])
        # second order children
        ctree.addNodeWithParent(cns[4], cns[1])
        ctree.addNodeWithParent(cns[5], cns[1])
        ctree.addNodeWithParent(cns[6], cns[1])
        ctree.addNodeWithParent(cns[7], cns[3])
        ctree.addNodeWithParent(cns[8], cns[3])

        self.ctree = ctree
コード例 #8
0
ファイル: test_neurontree.py プロジェクト: unibe-cns/NEAT
class TestReducedNeuron():
    def addLocinds(self):
        for ii, cn in enumerate(self.ctree):
            cn.loc_ind = ii

    def loadTwoCompartmentModel(self, w_locinds=True):
        # simple two compartment model
        pnode = CompartmentNode(0, ca=1.5e-5, g_l=2e-3)
        self.ctree = CompartmentTree(root=pnode)
        cnode = CompartmentNode(1, ca=2e-6, g_l=3e-4, g_c=4e-3)
        self.ctree.addNodeWithParent(cnode, pnode)

        if w_locinds:
            self.addLocinds()

    def loadTModel(self, w_locinds=True):
        # simple T compartment model
        # pnode = CompartmentNode(0, ca=1.5e-5, g_l=2e-3)
        # self.ctree = CompartmentTree(root=pnode)
        # cnode = CompartmentNode(1, ca=1.5e-6, g_l=2.5e-4, g_c=2e-3)
        # self.ctree.addNodeWithParent(cnode, pnode)
        # lnode0 = CompartmentNode(2, ca=1.5e-6, g_l=2.5e-4, g_c=2e-3)
        # self.ctree.addNodeWithParent(lnode0, cnode)
        # lnode1 = CompartmentNode(3, ca=1.5e-6, g_l=2.5e-4, g_c=2e-3)
        # self.ctree.addNodeWithParent(lnode1, cnode)
        pnode = CompartmentNode(0, ca=1.5e-5, g_l=2e-3)
        self.ctree = CompartmentTree(root=pnode)
        cnode = CompartmentNode(1, ca=2e-6, g_l=3e-4, g_c=4e-3)
        self.ctree.addNodeWithParent(cnode, pnode)
        lnode0 = CompartmentNode(2, ca=1.5e-6, g_l=2.5e-4, g_c=3e-3)
        self.ctree.addNodeWithParent(lnode0, cnode)
        lnode1 = CompartmentNode(3, ca=1.5e-6, g_l=2.5e-4, g_c=5e-3)
        self.ctree.addNodeWithParent(lnode1, cnode)

        if w_locinds:
            self.addLocinds()

    def loadThreeCompartmentModel(self, w_locinds=True):
        # simple 3 compartment model
        pnode = CompartmentNode(0, ca=1.9e-6, g_l=1.8e-3)
        self.ctree = CompartmentTree(root=pnode)
        cnode = CompartmentNode(1, ca=2.4e-6, g_l=0.3e-4, g_c=3.9)
        self.ctree.addNodeWithParent(cnode, pnode)
        lnode0 = CompartmentNode(2, ca=1.9e-6, g_l=0.3e-4, g_c=3.8e-3)
        self.ctree.addNodeWithParent(lnode0, cnode)

        if w_locinds:
            self.addLocinds()

    def loadMultiDendModel(self, w_locinds=True):
        # simple 3 compartment model
        pnode = CompartmentNode(0, ca=1.9e-6, g_l=1.8e-3)
        self.ctree = CompartmentTree(root=pnode)
        cnode0 = CompartmentNode(1, ca=2.4e-6, g_l=0.3e-4, g_c=3.9)
        self.ctree.addNodeWithParent(cnode0, pnode)
        cnode1 = CompartmentNode(2, ca=1.9e-6, g_l=0.4e-4, g_c=3.8e-3)
        self.ctree.addNodeWithParent(cnode1, pnode)
        cnode2 = CompartmentNode(3, ca=1.3e-6, g_l=0.5e-4, g_c=2.7e-2)
        self.ctree.addNodeWithParent(cnode2, pnode)

        if w_locinds:
            self.addLocinds()

    def testGeometry1(self):
        fake_c_m = 1.
        fake_r_a = 100. * 1e-6
        factor_r_a = 1e-6

        ## test method 1
        # test with two compartments
        self.loadTwoCompartmentModel()
        ctree = self.ctree
        # check if fake geometry is correct
        points, _ = ctree.computeFakeGeometry(fake_c_m=fake_c_m,
                                              fake_r_a=fake_r_a,
                                              factor_r_a=1e-6,
                                              delta=1e-14,
                                              method=1)
        # create a neuron comparemtns
        comps = []
        for ii, node in enumerate(ctree):
            comps.append(h.Section())
            h.pt3dadd(*points[ii][0], sec=comps[-1])
            h.pt3dadd(*points[ii][1], sec=comps[-1])
            h.pt3dadd(*points[ii][2], sec=comps[-1])
            h.pt3dadd(*points[ii][3], sec=comps[-1])
            comps[-1].Ra = fake_r_a * 1e6
            comps[-1].cm = fake_c_m
            comps[-1].nseg = 1
        # check areas
        assert np.abs(comps[0](0.5).area() * 1e-8 * fake_c_m -
                      ctree[0].ca) < 1e-12
        assert np.abs(comps[1](0.5).area() * 1e-8 * fake_c_m -
                      ctree[1].ca) < 1e-12
        # check whether resistances are correct
        assert np.abs(comps[0](0.5).ri() - 1.) < 1e-6
        assert np.abs((comps[1](0.5).ri() - 1. / ctree[1].g_c) /
                      comps[1](0.5).ri()) < 1e-6
        assert np.abs((comps[1](0.5).ri() * factor_r_a - comps[1](1.).ri()) /
                      comps[1](1.).ri()) < 1e-6

        # test with three compartments
        self.loadThreeCompartmentModel()
        ctree = self.ctree
        # check if fake geometry is correct
        points, _ = ctree.computeFakeGeometry(fake_c_m=fake_c_m,
                                              fake_r_a=fake_r_a,
                                              factor_r_a=1e-6,
                                              delta=1e-14,
                                              method=1)
        # create a neuron comparemtns
        comps = []
        for ii, node in enumerate(ctree):
            comps.append(h.Section())
            h.pt3dadd(*points[ii][0], sec=comps[-1])
            h.pt3dadd(*points[ii][1], sec=comps[-1])
            h.pt3dadd(*points[ii][2], sec=comps[-1])
            h.pt3dadd(*points[ii][3], sec=comps[-1])
            comps[-1].Ra = fake_r_a * 1e6
            comps[-1].cm = fake_c_m
            comps[-1].nseg = 1
        # check areas
        assert np.abs(comps[0](0.5).area() * 1e-8 * fake_c_m -
                      ctree[0].ca) < 1e-12
        assert np.abs(comps[1](0.5).area() * 1e-8 * fake_c_m -
                      ctree[1].ca) < 1e-12
        assert np.abs(comps[2](0.5).area() * 1e-8 * fake_c_m -
                      ctree[2].ca) < 1e-12
        # check whether resistances are correct
        assert np.abs(comps[0](0.5).ri() - 1.) < 1e-6
        assert np.abs((comps[1](0.5).ri() - 1. / ctree[1].g_c) /
                      comps[1](0.5).ri()) < 1e-6
        assert np.abs((comps[2](0.5).ri() - 1. / ctree[2].g_c) /
                      comps[2](0.5).ri()) < 1e-6
        assert np.abs((comps[1](0.5).ri() * factor_r_a - comps[1](1.).ri()) /
                      comps[1](1.).ri()) < 1e-6
        assert np.abs((comps[2](0.5).ri() * factor_r_a - comps[2](1.).ri()) /
                      comps[2](1.).ri()) < 1e-6

        # test the T model
        self.loadTModel()
        ctree = self.ctree
        # check if fake geometry is correct
        points, _ = ctree.computeFakeGeometry(fake_c_m=fake_c_m,
                                              fake_r_a=fake_r_a,
                                              factor_r_a=1e-6,
                                              delta=1e-14,
                                              method=1)
        # create a neuron comparemtns
        comps = []
        for ii, node in enumerate(ctree):
            comps.append(h.Section())
            h.pt3dadd(*points[ii][0], sec=comps[-1])
            h.pt3dadd(*points[ii][1], sec=comps[-1])
            h.pt3dadd(*points[ii][2], sec=comps[-1])
            h.pt3dadd(*points[ii][3], sec=comps[-1])
            comps[-1].Ra = fake_r_a * 1e6
            comps[-1].cm = fake_c_m
            comps[-1].nseg = 1
        # check areas
        assert np.abs(comps[0](0.5).area() * 1e-8 * fake_c_m -
                      ctree[0].ca) < 1e-12
        assert np.abs(comps[1](0.5).area() * 1e-8 * fake_c_m -
                      ctree[1].ca) < 1e-12
        assert np.abs(comps[2](0.5).area() * 1e-8 * fake_c_m -
                      ctree[2].ca) < 1e-12
        assert np.abs(comps[3](0.5).area() * 1e-8 * fake_c_m -
                      ctree[3].ca) < 1e-12
        # check whether resistances are correct
        assert np.abs(comps[0](0.5).ri() - 1.) < 1e-6
        assert np.abs((comps[1](0.5).ri() - 1. / ctree[1].g_c) /
                      comps[1](0.5).ri()) < 1e-6
        assert np.abs((comps[2](0.5).ri() - 1. / ctree[2].g_c) /
                      comps[2](0.5).ri()) < 1e-6
        assert np.abs((comps[3](0.5).ri() - 1. / ctree[3].g_c) /
                      comps[3](0.5).ri()) < 1e-6
        assert np.abs((comps[1](0.5).ri() * factor_r_a - comps[1](1.).ri()) /
                      comps[1](1.).ri()) < 1e-6
        assert np.abs((comps[2](0.5).ri() * factor_r_a - comps[2](1.).ri()) /
                      comps[2](1.).ri()) < 1e-6
        assert np.abs((comps[3](0.5).ri() * factor_r_a - comps[3](1.).ri()) /
                      comps[3](1.).ri()) < 1e-6

    def testImpedanceProperties1(self):
        fake_c_m = 1.
        fake_r_a = 100. * 1e-6
        # create the two compartment model without locinds
        self.loadTwoCompartmentModel(w_locinds=False)
        ctree = self.ctree
        # check if error is raised if loc_inds have not been set
        with pytest.raises(AttributeError):
            ctree.calcImpedanceMatrix()

        # create the two compartment model with locinds
        self.loadTwoCompartmentModel()
        ctree = self.ctree
        # compute the impedance matrix exactly
        z_mat_comp = ctree.calcImpedanceMatrix()
        # create a neuron model
        sim_tree = createReducedNeuronModel(ctree,
                                            fake_c_m=fake_c_m,
                                            fake_r_a=fake_r_a,
                                            method=1)
        z_mat_sim = sim_tree.calcImpedanceMatrix([(0, 0.5), (1, 0.5)])

        # create the three compartmental model
        self.loadThreeCompartmentModel()
        ctree = self.ctree
        # compute the impedance matrix exactly
        z_mat_comp = ctree.calcImpedanceMatrix()
        # create a neuron model
        sim_tree = createReducedNeuronModel(ctree,
                                            fake_c_m=fake_c_m,
                                            fake_r_a=fake_r_a,
                                            method=1)
        z_mat_sim = sim_tree.calcImpedanceMatrix([(0, 0.5), (1, 0.5),
                                                  (2, 0.5)])

        # create the T compartmental model
        self.loadTModel()
        ctree = self.ctree
        # compute the impedance matrix exactly
        z_mat_comp = ctree.calcImpedanceMatrix()
        # create a neuron model
        sim_tree = createReducedNeuronModel(ctree,
                                            fake_c_m=fake_c_m,
                                            fake_r_a=fake_r_a,
                                            method=1)
        z_mat_sim = sim_tree.calcImpedanceMatrix([(0, 0.5), (1, 0.5), (2, 0.5),
                                                  (3, 0.5)])
        assert np.allclose(z_mat_sim, z_mat_comp)

        # create the multidend model
        self.loadMultiDendModel()
        ctree = self.ctree
        # compute the impedance matrix exactly
        z_mat_comp = ctree.calcImpedanceMatrix()
        # create a neuron model
        sim_tree = createReducedNeuronModel(ctree,
                                            fake_c_m=fake_c_m,
                                            fake_r_a=fake_r_a,
                                            method=1)
        z_mat_sim = sim_tree.calcImpedanceMatrix([(0, 0.5), (1, 0.5), (2, 0.5),
                                                  (3, 0.5)])
        assert np.allclose(z_mat_sim, z_mat_comp)

    def testGeometry2(self):
        fake_c_m = 1.
        fake_r_a = 100. * 1e-6
        factor_r_a = 1e-6

        ## test method 2
        # test with two compartments
        self.loadTwoCompartmentModel()
        ctree = self.ctree
        # check if fake geometry is correct
        lengths, radii = ctree.computeFakeGeometry(fake_c_m=fake_c_m,
                                                   fake_r_a=fake_r_a,
                                                   factor_r_a=1e-6,
                                                   delta=1e-14,
                                                   method=2)
        # create a neuron comparemtns
        comps = []
        for ii, node in enumerate(ctree):
            comps.append(h.Section())
            comps[-1].diam = 2. * radii[ii] * 1e4
            comps[-1].L = lengths[ii] * 1e4
            comps[-1].Ra = fake_r_a * 1e6
            comps[-1].cm = fake_c_m
            comps[-1].nseg = 1

        # check areas
        assert np.abs(comps[0](0.5).area() * 1e-8 * fake_c_m -
                      ctree[0].ca) < 1e-12
        assert np.abs(comps[1](0.5).area() * 1e-8 * fake_c_m -
                      ctree[1].ca) < 1e-12
        # check whether resistances are correct
        assert np.abs((comps[1](0.5).ri() - 1. / ctree[1].g_c) /
                      comps[1](0.5).ri()) < 1e-12
        assert np.abs((comps[1](0.5).ri() - comps[1](1.).ri()) /
                      comps[1](1.).ri()) < 1e-12

        # test with three compartments
        self.loadThreeCompartmentModel()
        ctree = self.ctree
        # check if fake geometry is correct
        lengths, radii = ctree.computeFakeGeometry(fake_c_m=fake_c_m,
                                                   fake_r_a=fake_r_a,
                                                   factor_r_a=1e-6,
                                                   delta=1e-14,
                                                   method=2)
        # create a neuron comparemtns
        comps = []
        for ii, node in enumerate(ctree):
            comps.append(h.Section())
            comps[-1].diam = 2. * radii[ii] * 1e4
            comps[-1].L = lengths[ii] * 1e4
            comps[-1].Ra = fake_r_a * 1e6
            comps[-1].cm = fake_c_m
            comps[-1].nseg = 1

        # check areas
        assert np.abs(comps[0](0.5).area() * 1e-8 * fake_c_m -
                      ctree[0].ca) < 1e-12
        assert np.abs(comps[1](0.5).area() * 1e-8 * fake_c_m -
                      ctree[1].ca) < 1e-12
        assert np.abs(comps[2](0.5).area() * 1e-8 * fake_c_m -
                      ctree[2].ca) < 1e-12
        # check whether resistances are correct
        assert np.abs((comps[1](0.5).ri() - 1. / ctree[1].g_c) /
                      comps[1](0.5).ri()) < 1e-12
        assert np.abs((comps[1](0.5).ri() - comps[1](1.).ri()) /
                      comps[1](1.).ri()) < 1e-12
        assert np.abs((comps[2](0.5).ri() - 1. / ctree[2].g_c) /
                      comps[2](0.5).ri()) < 1e-12
        assert np.abs((comps[2](0.5).ri() - comps[2](1.).ri()) /
                      comps[2](1.).ri()) < 1e-12

        # test the T model
        self.loadTModel()
        ctree = self.ctree
        # check if fake geometry is correct
        lengths, radii = ctree.computeFakeGeometry(fake_c_m=fake_c_m,
                                                   fake_r_a=fake_r_a,
                                                   factor_r_a=1e-6,
                                                   delta=1e-14,
                                                   method=2)
        # create a neuron comparemtns
        comps = []
        for ii, node in enumerate(ctree):
            comps.append(h.Section())
            comps[-1].diam = 2. * radii[ii] * 1e4
            comps[-1].L = lengths[ii] * 1e4
            comps[-1].Ra = fake_r_a * 1e6
            comps[-1].cm = fake_c_m
            comps[-1].nseg = 1

        # check areas
        assert np.abs(comps[0](0.5).area() * 1e-8 * fake_c_m -
                      ctree[0].ca) < 1e-12
        assert np.abs(comps[1](0.5).area() * 1e-8 * fake_c_m -
                      ctree[1].ca) < 1e-12
        assert np.abs(comps[2](0.5).area() * 1e-8 * fake_c_m -
                      ctree[2].ca) < 1e-12
        assert np.abs(comps[3](0.5).area() * 1e-8 * fake_c_m -
                      ctree[3].ca) < 1e-12
        # check whether resistances are correct
        assert np.abs((comps[1](0.5).ri() - 1. / ctree[1].g_c) /
                      comps[1](0.5).ri()) < 1e-12
        assert np.abs((comps[1](0.5).ri() - comps[1](1.).ri()) /
                      comps[1](1.).ri()) < 1e-12
        assert np.abs((comps[2](0.5).ri() - 1. / ctree[2].g_c) /
                      comps[2](0.5).ri()) < 1e-12
        assert np.abs((comps[2](0.5).ri() - comps[2](1.).ri()) /
                      comps[2](1.).ri()) < 1e-12
        assert np.abs((comps[3](0.5).ri() - 1. / ctree[3].g_c) /
                      comps[3](0.5).ri()) < 1e-12
        assert np.abs((comps[3](0.5).ri() - comps[3](1.).ri()) /
                      comps[3](1.).ri()) < 1e-12

    def testImpedanceProperties2(self):
        fake_c_m = 1.
        fake_r_a = 100. * 1e-6
        # create the two compartment model
        self.loadTwoCompartmentModel()
        ctree = self.ctree
        # compute the impedance matrix exactly
        z_mat_comp = ctree.calcImpedanceMatrix()
        # create a neuron model
        sim_tree = createReducedNeuronModel(ctree,
                                            fake_c_m=fake_c_m,
                                            fake_r_a=fake_r_a,
                                            method=2)
        z_mat_sim = sim_tree.calcImpedanceMatrix([(0, 0.5), (1, 0.5)])
        assert np.allclose(z_mat_sim, z_mat_comp, atol=1e-2)

        # create the three compartmental model
        self.loadThreeCompartmentModel()
        ctree = self.ctree
        # compute the impedance matrix exactly
        z_mat_comp = ctree.calcImpedanceMatrix()
        # create a neuron model
        sim_tree = createReducedNeuronModel(ctree,
                                            fake_c_m=fake_c_m,
                                            fake_r_a=fake_r_a,
                                            method=2)
        z_mat_sim = sim_tree.calcImpedanceMatrix([(0, 0.5), (1, 0.5),
                                                  (2, 0.5)])
        assert np.allclose(z_mat_sim, z_mat_comp)

        # create the T compartmental model
        self.loadTModel()
        ctree = self.ctree
        # compute the impedance matrix exactly
        z_mat_comp = ctree.calcImpedanceMatrix()
        # create a neuron model
        sim_tree = createReducedNeuronModel(ctree,
                                            fake_c_m=fake_c_m,
                                            fake_r_a=fake_r_a,
                                            method=2)
        z_mat_sim = sim_tree.calcImpedanceMatrix([(0, 0.5), (1, 0.5), (2, 0.5),
                                                  (3, 0.5)])
        assert np.allclose(z_mat_sim, z_mat_comp)

        # create the multidend model
        self.loadMultiDendModel()
        ctree = self.ctree
        # compute the impedance matrix exactly
        z_mat_comp = ctree.calcImpedanceMatrix()
        # create a neuron model
        sim_tree = createReducedNeuronModel(ctree,
                                            fake_c_m=fake_c_m,
                                            fake_r_a=fake_r_a,
                                            method=2)
        z_mat_sim = sim_tree.calcImpedanceMatrix([(0, 0.5), (1, 0.5), (2, 0.5),
                                                  (3, 0.5)])
        assert np.allclose(z_mat_sim, z_mat_comp)