Exemplo n.º 1
0
def test_calc_efpl_outside_roi():
    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),
                    wknml.Node(id=6, position=(20, 1, 1), radius=1)
                ],
                edges=[
                    wknml.Edge(source=4, target=5),
                    wknml.Edge(source=5, target=6),
                ],
            ),
        ],
        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)
Exemplo n.º 2
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
Exemplo n.º 3
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)
Exemplo n.º 4
0
    def _edges_to_nml_edges(edges):
        """ Converts skeleton edges (numpy array) to wknml edges (list of named tuples)."""

        nml_edges = []
        for idx in range(edges.shape[0]):
            nml_edge = wknml.Edge(
                source=int(edges[idx, 0]),
                target=int(edges[idx, 1]),
            )
            nml_edges.append(nml_edge)

        return nml_edges