コード例 #1
0
 def setUp(self):
     self.morphology = Morphology(
         basic_nodes(),
         node_id_cb=lambda node: node["id"],
         parent_id_cb=lambda node: node["parent_id"],
     )
     self.data = Data(self.morphology, relative_soma_depth=0.25)
コード例 #2
0
    def build(self):
        """ Construct a Morphology object using this builder. This is a non-
        destructive operation. The Morphology will be validated at this stage.
        """

        return Morphology(self.nodes,
                          node_id_cb=lambda node: node["id"],
                          parent_id_cb=lambda node: node["parent"])
コード例 #3
0
    def setUp(self):
        # morphology with 3/4 axons below soma in z
        self.morphology = Morphology(
            [
                {
                    "id": 0,
                    "parent_id": -1,
                    "type": SOMA,
                    "x": 0,
                    "y": 0,
                    "z": 100,
                    "radius": 5
                },
                {
                    "id": 1,
                    "parent_id": 0,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 110,
                    "radius": 1
                },
                {
                    "id": 2,
                    "parent_id": 1,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 90,
                    "radius": 1
                },
                {
                    "id": 3,
                    "parent_id": 2,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 80,
                    "radius": 1
                },
                {
                    "id": 4,
                    "parent_id": 3,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 70,
                    "radius": 1
                },
            ],
            node_id_cb=lambda node: node["id"],
            parent_id_cb=lambda node: node["parent_id"],
        )

        self.data = Data(self.morphology)
コード例 #4
0
    def test_independent_axon_count_zero(self):
        nodes = [
            test_node(id=1, type=SOMA, parent_node_id=-1),
            test_node(id=2, type=AXON, parent_node_id=1)
        ]
        test_morphology = Morphology(nodes,
                                     node_id_cb=lambda node: node['id'],
                                     parent_id_cb=lambda node: node['parent'])
        test_morphology.validate(strict=False)

        stat = morphology_statistics(test_morphology)
        self.assertEqual(stat["Number of Independent Axons"], 0)
コード例 #5
0
 def setUp(self):
     self.morphology = Morphology(
         [
             {
                 "id": 0,
                 "parent_id": -1,
                 "type": SOMA,
                 "x": 0,
                 "y": 0,
                 "z": 100,
                 "radius": 1
             },
             {
                 "id": 1,
                 "parent_id": 0,
                 "type": AXON,
                 "x": 0,
                 "y": 0,
                 "z": 110,
                 "radius": 20
             },
             {
                 "id": 2,
                 "parent_id": 1,
                 "type": AXON,
                 "x": 0,
                 "y": 0,
                 "z": 120,
                 "radius": 1
             },
             {
                 "id": 3,
                 "parent_id": 0,
                 "type": APICAL_DENDRITE,
                 "x": 0,
                 "y": 3,
                 "z": 100,
                 "radius": 10
             },
             {
                 "id": 4,
                 "parent_id": 3,
                 "type": APICAL_DENDRITE,
                 "x": 0,
                 "y": 6,
                 "z": 100,
                 "radius": 1
             },
         ],
         node_id_cb=lambda node: node["id"],
         parent_id_cb=lambda node: node["parent_id"],
     )
コード例 #6
0
    def setUp(self):
        nodes = basic_nodes()
        self.sizes = np.random.rand(len(nodes))

        for sz, node in zip(self.sizes, nodes):
            node["radius"] = sz

        self.morphology = Morphology(
            nodes,
            node_id_cb=lambda node: node["id"],
            parent_id_cb=lambda node: node["parent_id"],
        )

        self.mean_diameter = np.mean(self.sizes) * 2
コード例 #7
0
def test_morphology_from_data_file_by_node_type(node_types=None):

    morphology = swc.morphology_from_swc(test_file)
    nodes = morphology.get_node_by_types(node_types)
    for node in nodes:
        # unfortunately, pandas automatically promotes numeric types to float in to_dict
        node['parent'] = int(node['parent'])
        node['id'] = int(node['id'])
        node['type'] = int(node['type'])

    node_id_cb = lambda node: node['id']
    parent_id_cb = lambda node: node['parent']

    axon_only_morphology = Morphology(nodes, node_id_cb, parent_id_cb)
    return axon_only_morphology
コード例 #8
0
def morphology_from_swc(swc_path):

    swc_data = read_swc(swc_path, sep=' ')

    nodes = swc_data.to_dict('record')
    for node in nodes:
        # unfortunately, pandas automatically promotes numeric types to float in to_dict
        node['parent'] = int(node['parent'])
        node['id'] = int(node['id'])
        node['type'] = int(node['type'])

    return Morphology(
        nodes,
        node_id_cb=lambda node: node['id'],
        parent_id_cb=lambda node: node['parent']
    )
コード例 #9
0
def test_tree(nodes=None, strict_validation=False):

    if not nodes:
        return None

    for node in nodes:
        # unfortunately, pandas automatically promotes numeric types to float in to_dict
        node['parent'] = int(node['parent'])
        node['id'] = int(node['id'])
        node['type'] = int(node['type'])

    node_id_cb = lambda node: node['id']
    parent_id_cb = lambda node: node['parent']

    morpho = Morphology(nodes, node_id_cb, parent_id_cb)
    morpho.validate(strict=strict_validation)
    return morpho
コード例 #10
0
def test_morphology_large():

    nodes = [
        test_node(id=1,
                  type=SOMA,
                  x=800,
                  y=610,
                  z=30,
                  radius=35,
                  parent_node_id=-1),
        test_node(id=2,
                  type=BASAL_DENDRITE,
                  x=400,
                  y=600,
                  z=10,
                  radius=3,
                  parent_node_id=1),
        test_node(id=3,
                  type=BASAL_DENDRITE,
                  x=430,
                  y=630,
                  z=20,
                  radius=3,
                  parent_node_id=2),
        test_node(id=4,
                  type=BASAL_DENDRITE,
                  x=460,
                  y=660,
                  z=30,
                  radius=3,
                  parent_node_id=3),
        test_node(id=5,
                  type=BASAL_DENDRITE,
                  x=490,
                  y=690,
                  z=40,
                  radius=3,
                  parent_node_id=4),
        test_node(id=6,
                  type=APICAL_DENDRITE,
                  x=600,
                  y=300,
                  z=20,
                  radius=3,
                  parent_node_id=1),
        test_node(id=7,
                  type=APICAL_DENDRITE,
                  x=630,
                  y=330,
                  z=30,
                  radius=3,
                  parent_node_id=6),
        test_node(id=8,
                  type=APICAL_DENDRITE,
                  x=660,
                  y=360,
                  z=40,
                  radius=3,
                  parent_node_id=7),
        test_node(id=9,
                  type=APICAL_DENDRITE,
                  x=690,
                  y=390,
                  z=50,
                  radius=3,
                  parent_node_id=8),
        test_node(id=10,
                  type=APICAL_DENDRITE,
                  x=710,
                  y=420,
                  z=60,
                  radius=3,
                  parent_node_id=9),
        test_node(id=11,
                  type=APICAL_DENDRITE,
                  x=740,
                  y=450,
                  z=70,
                  radius=3,
                  parent_node_id=10),
        test_node(id=12,
                  type=AXON,
                  x=900,
                  y=600,
                  z=30,
                  radius=3,
                  parent_node_id=1),
        test_node(id=13,
                  type=AXON,
                  x=930,
                  y=630,
                  z=40,
                  radius=3,
                  parent_node_id=12),
        test_node(id=14,
                  type=AXON,
                  x=960,
                  y=660,
                  z=50,
                  radius=3,
                  parent_node_id=13),
        test_node(id=15,
                  type=AXON,
                  x=990,
                  y=690,
                  z=60,
                  radius=3,
                  parent_node_id=14),
        test_node(id=16,
                  type=AXON,
                  x=1020,
                  y=720,
                  z=70,
                  radius=3,
                  parent_node_id=15),
        test_node(id=17,
                  type=AXON,
                  x=1050,
                  y=750,
                  z=80,
                  radius=3,
                  parent_node_id=16)
    ]

    for node in nodes:
        # unfortunately, pandas automatically promotes numeric types to float in to_dict
        node['parent'] = int(node['parent'])
        node['id'] = int(node['id'])
        node['type'] = int(node['type'])

    return Morphology(nodes,
                      node_id_cb=lambda node: node['id'],
                      parent_id_cb=lambda node: node['parent'])
コード例 #11
0
def test_morphology_small_multiple_trees():

    nodes = [
        test_node(id=1,
                  type=SOMA,
                  x=800,
                  y=610,
                  z=30,
                  radius=35,
                  parent_node_id=-1),
        test_node(id=2,
                  type=BASAL_DENDRITE,
                  x=400,
                  y=600,
                  z=10,
                  radius=3,
                  parent_node_id=1),
        test_node(id=3,
                  type=APICAL_DENDRITE,
                  x=600,
                  y=300,
                  z=20,
                  radius=3,
                  parent_node_id=1),
        test_node(id=4,
                  type=AXON,
                  x=900,
                  y=600,
                  z=30,
                  radius=3,
                  parent_node_id=1),
        test_node(id=5,
                  type=AXON,
                  x=900,
                  y=600,
                  z=30,
                  radius=3,
                  parent_node_id=-1),
        test_node(id=6,
                  type=AXON,
                  x=900,
                  y=600,
                  z=30,
                  radius=3,
                  parent_node_id=5),
        test_node(id=7,
                  type=AXON,
                  x=900,
                  y=600,
                  z=30,
                  radius=3,
                  parent_node_id=6),
        test_node(id=8,
                  type=AXON,
                  x=900,
                  y=600,
                  z=30,
                  radius=3,
                  parent_node_id=7),
        test_node(id=9,
                  type=AXON,
                  x=900,
                  y=600,
                  z=30,
                  radius=3,
                  parent_node_id=8)
    ]

    for node in nodes:
        # unfortunately, pandas automatically promotes numeric types to float in to_dict
        node['parent'] = int(node['parent'])
        node['id'] = int(node['id'])
        node['type'] = int(node['type'])

    return Morphology(nodes,
                      node_id_cb=lambda node: node['id'],
                      parent_id_cb=lambda node: node['parent'])
コード例 #12
0
    def setUp(self):

        # Create an axon that extends positively,
        # and a basal dendrite that extends negatively
        self.one_dim_neuron = Morphology(
            [
                {
                    "id": 0,
                    "parent_id": -1,
                    "type": SOMA,
                    "x": 0,
                    "y": 100,
                    "z": 0,
                    "radius": 10
                },
                # Axon node [100, 125, 150, 175, 200]
                {
                    "id": 1,
                    "parent_id": 0,
                    "type": AXON,
                    "x": 0,
                    "y": 100,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 2,
                    "parent_id": 1,
                    "type": AXON,
                    "x": 0,
                    "y": 125,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 3,
                    "parent_id": 2,
                    "type": AXON,
                    "x": 0,
                    "y": 150,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 4,
                    "parent_id": 3,
                    "type": AXON,
                    "x": 0,
                    "y": 175,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 5,
                    "parent_id": 4,
                    "type": AXON,
                    "x": 0,
                    "y": 200,
                    "z": 0,
                    "radius": 3
                },
                # Basal node [100, 75, 50]
                {
                    "id": 11,
                    "parent_id": 0,
                    "type": BASAL_DENDRITE,
                    "x": 0,
                    "y": 100,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 12,
                    "parent_id": 11,
                    "type": BASAL_DENDRITE,
                    "x": 0,
                    "y": 75,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 13,
                    "parent_id": 12,
                    "type": BASAL_DENDRITE,
                    "x": 0,
                    "y": 50,
                    "z": 0,
                    "radius": 3
                },
            ],
            node_id_cb=lambda node: node["id"],
            parent_id_cb=lambda node: node["parent_id"],
        )

        self.one_dim_neuron_data = Data(self.one_dim_neuron)

        self.dimension_features = nested_specialize(
            di.dimension,
            [COORD_TYPE_SPECIALIZATIONS, NEURITE_SPECIALIZATIONS])
コード例 #13
0
 def setUp(self):
     self.morphology = Morphology(
         basic_nodes(),
         node_id_cb=lambda node: node["id"],
         parent_id_cb=lambda node: node["parent_id"],
     )
コード例 #14
0
 def setUp(self):
     self.morphology = Morphology([
             {
                 "id": 0,
                 "parent_id": -1,
                 "type": SOMA,
                 "x": 0,
                 "y": 0,
                 "z": 100,
                 "radius": 1
             },
             {
                 "id": 1,
                 "parent_id": 0,
                 "type": AXON,
                 "x": 0,
                 "y": 0,
                 "z": 101,
                 "radius": 1
             },
             {
                 "id": 2,
                 "parent_id": 0,
                 "type": APICAL_DENDRITE,
                 "x": 0,
                 "y": 0,
                 "z": 102,
                 "radius": 1
             },
             { # bifurcates
                 "id": 3,
                 "parent_id": 1,
                 "type": AXON,
                 "x": 0,
                 "y": 0,
                 "z": 110,
                 "radius": 1
             },                
             {
                 "id": 4,
                 "parent_id": 3,
                 "type": AXON,
                 "x": 0,
                 "y": 0,
                 "z": 140,
                 "radius": 1 
             },     
             { # this node backtracks, causing the path distance to differ from the euclidean
                 "id": 11,
                 "parent_id": 4,
                 "type": AXON,
                 "x": 0,
                 "y": 0,
                 "z": 130,
                 "radius": 1 
             },       
             { # bifurcates
                 "id": 5,
                 "parent_id": 3,
                 "type": AXON,
                 "x": 0,
                 "y": 0,
                 "z": 130,
                 "radius": 1 
             },                
             {
                 "id": 6,
                 "parent_id": 5,
                 "type": AXON,
                 "x": 0,
                 "y": 0,
                 "z": 135,
                 "radius": 1 
             },       
             {
                 "id": 7,
                 "parent_id": 5,
                 "type": AXON,
                 "x": 30,
                 "y": 0,
                 "z": 103,
                 "radius": 1 
             },     
             { # bifurcates
                 "id": 8,
                 "parent_id": 2,
                 "type": APICAL_DENDRITE,
                 "x": 0,
                 "y": 0,
                 "z": 125,
                 "radius": 1 
             },
             {
                 "id": 9,
                 "parent_id": 8,
                 "type": APICAL_DENDRITE,
                 "x": 0,
                 "y": 0,
                 "z": 126,
                 "radius": 1 
             },
             {
                 "id": 10,
                 "parent_id": 8,
                 "type": APICAL_DENDRITE,
                 "x": 0,
                 "y": 0,
                 "z": 127,
                 "radius": 1 
             },
         ],
         node_id_cb=lambda node: node["id"],
         parent_id_cb=lambda node: node["parent_id"],
     )
コード例 #15
0
    def setUp(self):

        self.one_dim_neuron = Morphology([
                {
                    "id": 0,
                    "parent_id": -1,
                    "type": SOMA,
                    "x": 0,
                    "y": 0,
                    "z": 100,
                    "radius": 1
                },
                {
                    "id": 1,
                    "parent_id": 0,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 101,
                    "radius": 1
                },
                {
                    "id": 2,
                    "parent_id": 0,
                    "type": APICAL_DENDRITE,
                    "x": 0,
                    "y": 0,
                    "z": 102,
                    "radius": 1
                },
                { # bifurcates and is within 120
                    "id": 3,
                    "parent_id": 1,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 110,
                    "radius": 1
                },                
                { # This is the farthest node from the root
                    "id": 4,
                    "parent_id": 3,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 140,
                    "radius": 1 
                },                
                { # bifurcates, and is beyond 120
                    "id": 5,
                    "parent_id": 3,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 130,
                    "radius": 1 
                },                
                {
                    "id": 6,
                    "parent_id": 5,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 135,
                    "radius": 1 
                },       
                {
                    "id": 7,
                    "parent_id": 5,
                    "type": AXON,
                    "x": 0,
                    "y": 0,
                    "z": 136,
                    "radius": 1 
                },     
                { # bifurcates and is beyond 120
                    "id": 8,
                    "parent_id": 2,
                    "type": APICAL_DENDRITE,
                    "x": 0,
                    "y": 0,
                    "z": 125,
                    "radius": 1 
                },
                {
                    "id": 9,
                    "parent_id": 8,
                    "type": APICAL_DENDRITE,
                    "x": 0,
                    "y": 0,
                    "z": 126,
                    "radius": 1 
                },
                {
                    "id": 10,
                    "parent_id": 8,
                    "type": APICAL_DENDRITE,
                    "x": 0,
                    "y": 0,
                    "z": 127,
                    "radius": 1 
                },
            ],
            node_id_cb=lambda node: node["id"],
            parent_id_cb=lambda node: node["parent_id"],
        )

        self.one_dim_neuron_data = Data(self.one_dim_neuron)

        self.neurite_features = specialize(
            bf.num_outer_bifurcations,
            {AxonSpec, ApicalDendriteSpec, BasalDendriteSpec}
        )
コード例 #16
0
    def setUp(self):

        # Create an Axon that extends y 100 to 120
        # and Basal Dendrite that extends y 100 to 110 and 100 to 80
        # So that 3/4 axon nodes overlap, 1/4 are above basal
        # and that 3/6 basal are below, and 3/6 overlap
        self.one_dim_neuron = Morphology(
            [
                {
                    "id": 0,
                    "parent_id": -1,
                    "type": SOMA,
                    "x": 0,
                    "y": 100,
                    "z": 0,
                    "radius": 10
                },
                # Axon y 100 to 150
                {
                    "id": 1,
                    "parent_id": 0,
                    "type": AXON,
                    "x": 0,
                    "y": 101,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 2,
                    "parent_id": 1,
                    "type": AXON,
                    "x": 0,
                    "y": 102,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 3,
                    "parent_id": 2,
                    "type": AXON,
                    "x": 0,
                    "y": 110,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 4,
                    "parent_id": 3,
                    "type": AXON,
                    "x": 0,
                    "y": 120,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 11,
                    "parent_id": 0,
                    "type": BASAL_DENDRITE,
                    "x": 0,
                    "y": 101,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 12,
                    "parent_id": 11,
                    "type": BASAL_DENDRITE,
                    "x": 0,
                    "y": 102,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 13,
                    "parent_id": 12,
                    "type": BASAL_DENDRITE,
                    "x": 0,
                    "y": 110,
                    "z": 0,
                    "radius": 3
                },
                # Basal Dendrite y 100 to 80
                {
                    "id": 14,
                    "parent_id": 12,
                    "type": BASAL_DENDRITE,
                    "x": 0,
                    "y": 99,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 15,
                    "parent_id": 14,
                    "type": BASAL_DENDRITE,
                    "x": 0,
                    "y": 90,
                    "z": 0,
                    "radius": 3
                },
                {
                    "id": 16,
                    "parent_id": 15,
                    "type": BASAL_DENDRITE,
                    "x": 0,
                    "y": 80,
                    "z": 0,
                    "radius": 3
                },
            ],
            node_id_cb=lambda node: node["id"],
            parent_id_cb=lambda node: node["parent_id"],
        )

        self.one_dim_neuron_data = Data(self.one_dim_neuron)

        self.overlap_features = nested_specialize(
            ol.overlap,
            [
                NEURITE_SPECIALIZATIONS,  #.remove(AllNeuriteSpec),
                NEURITE_COMPARISON_SPECIALIZATIONS
            ]  #.remove(AllNeuriteCompareSpec)]
        )