示例#1
0
def test_calc_efpl_simple():
    import wknml
    nml = wknml.NML(
        parameters=wknml.NMLParameters(
            name='',
            scale=(1, 1, 1),
        ),
        trees=[
            wknml.Tree(
                id=0,
                color=(255, 255, 0, 1),
                name='',
                nodes=[
                    wknml.Node(id=4, position=(2, 1, 1), radius=1),
                    wknml.Node(id=5, position=(3, 1, 1), radius=1)
                ],
                edges=[
                    wknml.Edge(source=4, target=5),
                ],
            ),
        ],
        branchpoints=[],
        comments=[],
        groups=[],
    )

    Vlbls = np.ones((5, 5, 5), dtype=np.uint32)
    dataset_start = np.zeros((1, 3), dtype=int)

    calc_eftpl(nml, Vlbls, dataset_start)
示例#2
0
def test__calc_efpl__use_correct_edge_lengths():
    """ Github issue: https://github.com/elhuhdron/emdrp/issues/4
    
    Check that the norm between edge node positions is calculated along the
    correct axis.
    """
    import wknml

    trees = [
        wknml.Tree(
            id=0,
            color=(255, 255, 0, 1),
            name="neuron1",
            nodes=[
                wknml.Node(id=0, position=(1, 1, 1), radius=1),
                wknml.Node(id=1, position=(1, 1, 3), radius=1),
                wknml.Node(id=2, position=(1, 2, 1), radius=1)
            ],
            edges=[
                wknml.Edge(source=0, target=1),
                wknml.Edge(source=0, target=2)
            ],
            groupId=1,
        )
    ]

    nml = wknml.NML(
        parameters=wknml.NMLParameters(
            name="Test",
            scale=(1, 1, 1),
        ),
        trees=trees,
        branchpoints=[],
        comments=[],
        groups=[],
    )

    Vlbls = np.ones((5, 5, 5), dtype=np.uint32)
    dataset_start = np.zeros((1, 3), dtype=int)

    Vlbls[:, 1:, :] = 2

    efpl = calc_eftpl(nml, Vlbls, dataset_start)

    assert (efpl == 2 / 3)
示例#3
0
def util_get_nml():
    import wknml
    trees = [
        wknml.Tree(
            id=0,
            color=(255, 255, 0, 1),
            name="Synapse 1",
            nodes=[
                wknml.Node(id=0, position=(1, 1, 1), radius=1),
                wknml.Node(id=1, position=(1, 1, 2), radius=1),
                wknml.Node(id=2, position=(1, 1, 3), radius=1),
                wknml.Node(id=3, position=(1, 2, 2), radius=1)
            ],
            edges=[
                wknml.Edge(source=0, target=1),
                wknml.Edge(source=1, target=2),
                wknml.Edge(source=1, target=3)
            ],
            groupId=1,
        ),
        wknml.Tree(
            id=1,
            color=(255, 0, 255, 1),
            name="Synapse 2",
            nodes=[
                wknml.Node(id=0, position=(2, 1, 1), radius=1),
                wknml.Node(id=1, position=(3, 1, 1), radius=1),
                wknml.Node(id=2, position=(4, 1, 1), radius=1)
            ],
            edges=[
                wknml.Edge(source=0, target=1),
                wknml.Edge(source=1, target=2)
            ],
            groupId=1,
        ),
    ]

    nml = wknml.NML(
        parameters=wknml.NMLParameters(
            name="Test",
            scale=(1, 1, 1),
        ),
        trees=trees,
        branchpoints=[],
        comments=[],
        groups=[],
    )

    return nml
示例#4
0
    def _nodes_to_nml_nodes(nodes):
        """ Converts skeleton nodes (DataFrame subclass) to wknml nodes (list of named tuples)."""

        nml_nodes = []
        for idx, row in nodes.iterrows():
            nml_node = wknml.Node(id=int(row.id),
                                  position=tuple(row.position.values),
                                  radius=float(row.radius),
                                  rotation=tuple(row.rotation.values),
                                  inVp=int(row.inVp),
                                  inMag=int(row.inMag),
                                  bitDepth=int(row.bitDepth),
                                  interpolation=bool(row.interpolation.values),
                                  time=int(row.time))
            nml_nodes.append(nml_node)

        return nml_nodes