def setUp(self):
     # 180 deg at soma
     # axon - 90 deg local, 60 deg remote
     # basal - 90 deg local, 90 deg remote
     self.morphology = (
         MorphologyBuilder()
             .root(0, 0, 0)
                 .axon(0, 0, 1)
                     .axon(0, 1, 2)
                         .axon(0, 1, 1 + np.sqrt(3)).up(2)
                     .axon(0, -1, 2)
                         .axon(0, -1, 1 + np.sqrt(3)).up(3)
                 .basal_dendrite(0, 0, -1)
                     .basal_dendrite(0, 1, -2).up()
                     .basal_dendrite(0, -1, -2)
             .build()
     )
     nodes = self.morphology.nodes()
     for node in nodes:
         print(node)
     self.data = Data(self.morphology)
     self.local_specialized = specialize(
         bf.mean_bifurcation_angle_local,
         {AxonSpec, ApicalDendriteSpec, BasalDendriteSpec}
     )
     self.remote_specialized = specialize(
         bf.mean_bifurcation_angle_remote,
         {AxonSpec, ApicalDendriteSpec, BasalDendriteSpec}
     )
    def setUp(self):

        # Create an axon that branches once,
        # and a basal dendrite that has a bifurcation and a trifurcation
        self.morphology = (MorphologyBuilder(
        ).root().axon().axon().axon().axon().up().axon().up(4).basal_dendrite(
        ).basal_dendrite().basal_dendrite().up().basal_dendrite(
        ).basal_dendrite().up().basal_dendrite().up().basal_dendrite().build())

        self.data = Data(self.morphology)

        self.num_nodes = specialize(ic.num_nodes, NEURITE_SPECIALIZATIONS)
        self.num_tips = specialize(ic.num_tips, NEURITE_SPECIALIZATIONS)
        self.num_branches = specialize(ic.num_branches,
                                       NEURITE_SPECIALIZATIONS)
        self.mean_fragmentation = specialize(ic.mean_fragmentation,
                                             NEURITE_SPECIALIZATIONS)
        self.max_branch_order = specialize(ic.max_branch_order,
                                           NEURITE_SPECIALIZATIONS)
示例#3
0
    num_outer_bifurcations, mean_bifurcation_angle_local,
    mean_bifurcation_angle_remote)
from neuron_morphology.features.size import (total_length, total_surface_area,
                                             total_volume, mean_diameter,
                                             mean_parent_daughter_ratio,
                                             max_euclidean_distance)
from neuron_morphology.features.path import (max_path_distance,
                                             early_branch_path,
                                             mean_contraction)
from neuron_morphology.features.statistics.overlap import overlap
from neuron_morphology.features.statistics.moments import moments

default_features = [
    nested_specialize(dimension,
                      [COORD_TYPE_SPECIALIZATIONS, NEURITE_SPECIALIZATIONS]),
    specialize(num_nodes, NEURITE_SPECIALIZATIONS),
    specialize(num_branches, NEURITE_SPECIALIZATIONS),
    specialize(num_tips, NEURITE_SPECIALIZATIONS),
    specialize(mean_fragmentation, NEURITE_SPECIALIZATIONS),
    specialize(max_branch_order, NEURITE_SPECIALIZATIONS),
    specialize(num_outer_bifurcations, NEURITE_SPECIALIZATIONS),
    specialize(mean_bifurcation_angle_local, NEURITE_SPECIALIZATIONS),
    specialize(mean_bifurcation_angle_remote, NEURITE_SPECIALIZATIONS),
    specialize(total_length, NEURITE_SPECIALIZATIONS),
    specialize(total_surface_area, NEURITE_SPECIALIZATIONS),
    specialize(total_volume, NEURITE_SPECIALIZATIONS),
    specialize(mean_diameter, NEURITE_SPECIALIZATIONS),
    specialize(mean_parent_daughter_ratio, NEURITE_SPECIALIZATIONS),
    specialize(max_euclidean_distance, NEURITE_SPECIALIZATIONS),
    max_path_distance, early_branch_path, mean_contraction,
    nested_specialize(
示例#4
0
    def test_specialize_marked(self):
        multiply = MarkedFeature({self.does_math}, self.multiply)
        multiply_by_4 = specialize(multiply, {self.by4})["By4.multiply"]

        self.assertEqual(multiply_by_4(2), 8)
        self.assertEqual(multiply_by_4.marks, {self.uses_four, self.does_math})
示例#5
0
    def test_specialize_fn(self):
        multipliers = specialize(self.multiply, {self.by4})
        multiply_by_4 = multipliers["By4.multiply"]

        self.assertEqual(multiply_by_4(2), 8)
        self.assertEqual(multiply_by_4.marks, {self.uses_four})
    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}
        )