Beispiel #1
0
    def testComparisonFailureTransplantingALeafNode(self):
        """Remap each leaf node in a complex swc file, onto
        different internal nodes of the morphology,
        and check that the morphology is considered different
        """

        testSrcsPath = LocMgr().get_test_srcs_path()
        srcSWCFile = Join(testSrcsPath, "swc_srcs/28o_spindle20aFI.CNG.swc")

        m = MorphologyArray.fromSWC(srcSWCFile)

        # Find the leaf nodes:
        leaf_nodes = m.get_leaf_vertices_indices()

        for new_parent in [0, 10, 20, leaf_nodes[-1]]:

            for l in leaf_nodes[:-1]:
                v = m._vertices.copy()
                c = m._connectivity.copy()

                # Rewrite the connectivity matrix, mapping the
                # leaf to a new_parent:
                c[c == l] = new_parent

                mNew = MorphologyArray(vertices=v, connectivity=c)
                assert not MorphArrayComparison.are_same(
                    m, mNew, max_node_distance=0.00001)
Beispiel #2
0
    def testComparisonFailureAddingEpsilon2(self):
        """Load and complex .swc file, and
        change each [x, y, z, r] value in the vertices matrix
        individually, to check that it is not the same.
        """
        testSrcsPath = LocMgr().get_test_srcs_path()
        srcSWCFile = Join(testSrcsPath, "swc_srcs/28o_spindle20aFI.CNG.swc")

        m = MorphologyArray.fromSWC(srcSWCFile)
        MFRandom.seed(0)
        for i in range(len(m)):
            print i, len(m)
            for j in range(4):

                # Only test 2% of cases:
                if not np.random.rand() < 0.02:
                    continue

                m1 = MorphologyArray.fromSWC(srcSWCFile)
                m1._vertices[i, j] = m1._vertices[i, j] + 0.01
                assert MorphArrayComparison.are_same(m,
                                                     m1,
                                                     max_node_distance=0.02)
                assert not MorphArrayComparison.are_same(
                    m, m1, max_node_distance=0.005)