示例#1
0
    def test_existence_of_constriction_for_dendrite_multiple_children(self):
        for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]:
            try:
                nodes = [
                    test_node(id=1, type=SOMA, radius=35.1, parent_node_id=-1),
                    test_node(id=2,
                              type=dendrite_type,
                              radius=2.0,
                              parent_node_id=1),
                    test_node(id=3,
                              type=dendrite_type,
                              radius=2.0,
                              parent_node_id=2),
                    test_node(id=4,
                              type=dendrite_type,
                              radius=1.5,
                              parent_node_id=3),
                    test_node(id=5,
                              type=dendrite_type,
                              radius=1.5,
                              parent_node_id=3)
                ]

                test_tree(nodes, strict_validation=True)

                self.fail("Morphology should have been rejected.")
            except InvalidMorphology as e:
                self.assertNodeErrors(
                    e.validation_errors,
                    "Constriction: The radius of types 3 and 4 should not be "
                    "less than 2.0px", [[5], [4]])
示例#2
0
    def test_multiple_axon_initiation_points_valid(self):
        nodes = [
            test_node(id=1, type=SOMA, parent_node_id=-1),
            test_node(id=2, type=AXON, parent_node_id=1)
        ]

        test_tree(nodes, strict_validation=True)
示例#3
0
    def test_children_of(self):

        morphology = test_morphology_small()
        node = test_node(id=1,
                         type=SOMA,
                         x=800,
                         y=610,
                         z=30,
                         radius=35,
                         parent_node_id=-1)
        children = morphology.children_of(node)
        expected_children = [
            test_node(id=2,
                      type=BASAL_DENDRITE,
                      x=400,
                      y=600,
                      z=10,
                      radius=3,
                      parent_node_id=1),
            test_node(id=4,
                      type=APICAL_DENDRITE,
                      x=600,
                      y=300,
                      z=20,
                      radius=3,
                      parent_node_id=1),
            test_node(id=6,
                      type=AXON,
                      x=900,
                      y=600,
                      z=30,
                      radius=3,
                      parent_node_id=1)
        ]
        self.assertEqual(children, expected_children)
示例#4
0
    def test_coordinate_corresponding_to_dendrite_tips_multiple_cut_dendrite_invalid(
            self):
        for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]:
            nodes = [
                test_node(id=1, type=SOMA, parent_node_id=-1),
                test_node(id=2,
                          type=dendrite_type,
                          x=0,
                          y=0,
                          z=0,
                          parent_node_id=1),
                test_node(id=2,
                          type=dendrite_type,
                          x=0,
                          y=0,
                          z=0,
                          parent_node_id=1)
            ]
            errors = mv.validate([
                test_marker(x=1, y=0, z=0, name=CUT_DENDRITE),
                test_marker(x=1, y=0, z=0, name=TYPE_30)
            ], test_tree(nodes))

            self.assertMarkerErrors(
                errors,
                "Coordinates for each dendrite (type 10) needs to correspond to "
                "a tip of a dendrite type (type 3 or 4) in the related morphology",
                [[{
                    'x': 1,
                    'y': 0,
                    'z': 0,
                    'name': CUT_DENDRITE
                }]])
示例#5
0
 def test_apical_dendrite_traceable_back_to_soma_valid(self):
     nodes = [
         test_node(id=1, type=SOMA, parent_node_id=-1),
         test_node(id=2, type=AXON, parent_node_id=1),
         test_node(id=3, type=APICAL_DENDRITE, parent_node_id=1)
     ]
     test_tree(nodes, strict_validation=True)
示例#6
0
 def test_axon_node_with_valid_parent_type(self):
     for node_type in [SOMA, AXON]:
         nodes = [
             test_node(id=1, type=node_type, parent_node_id=-1),
             test_node(id=2, type=AXON, parent_node_id=1)
         ]
         test_tree(nodes, strict_validation=True)
示例#7
0
 def test_basal_dendrite_node_with_valid_parent_type(self):
     for node_type in [SOMA]:
         nodes = [
             test_node(id=1, type=node_type, parent_node_id=-1),
             test_node(id=2, type=BASAL_DENDRITE, parent_node_id=1)
         ]
         test_tree(nodes, strict_validation=True)
示例#8
0
 def test_validate_expected_type_valid(self):
     for node_type in [AXON, BASAL_DENDRITE, APICAL_DENDRITE]:
         nodes = [
             test_node(id=1, type=SOMA),
             test_node(id=2, type=node_type, parent_node_id=1)
         ]
         errors = tv.validate_expected_types(test_tree(nodes))
         self.assertEqual(len(errors), 0)
示例#9
0
 def test_independent_axon_with_more_than_four_nodes_child_branch(self):
     nodes = [
         test_node(id=1, type=SOMA, parent_node_id=-1),
         test_node(id=2, type=AXON, parent_node_id=-1),
         test_node(id=3, type=AXON, parent_node_id=2),
         test_node(id=4, type=AXON, parent_node_id=3),
         test_node(id=5, type=AXON, parent_node_id=3)
     ]
     test_tree(nodes, strict_validation=True)
示例#10
0
 def test_immediate_child_of_soma_doesnt_more_than_one_child(self):
     nodes = [
         test_node(id=1, type=SOMA, parent_node_id=-1),
         test_node(id=2, type=APICAL_DENDRITE, parent_node_id=1),
         test_node(id=3, type=APICAL_DENDRITE, parent_node_id=2),
         test_node(id=4, type=APICAL_DENDRITE, parent_node_id=3),
         test_node(id=5, type=APICAL_DENDRITE, parent_node_id=3)
     ]
     test_tree(nodes, strict_validation=True)
 def test_children_nodes_appear_before_parent_nodes_not_valid(self):
     try:
         nodes = [test_node(id=1, type=AXON, parent_node_id=2),
                  test_node(id=2, type=SOMA, parent_node_id=-1)]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(e.validation_errors, "Child node needs to come before parent node",
                               [[1]])
示例#12
0
    def test_extreme_taper_less_than_eight_nodes_in_segment(self):
        nodes = [
            test_node(id=1, type=SOMA, radius=36.0, parent_node_id=-1),
            test_node(id=2, type=BASAL_DENDRITE, radius=2.0, parent_node_id=1),
            test_node(id=3, type=BASAL_DENDRITE, radius=2.0, parent_node_id=2),
            test_node(id=4, type=BASAL_DENDRITE, radius=2.0, parent_node_id=3)
        ]

        test_tree(nodes, strict_validation=True)
示例#13
0
    def test_decreasing_radius_when_going_away_from_soma_axon_valid(self):
        nodes = [
            test_node(id=1, type=SOMA, radius=36.0, parent_node_id=-1),
            test_node(id=2, type=AXON, radius=4.0, parent_node_id=1),
            test_node(id=3, type=AXON, radius=4.0, parent_node_id=2),
            test_node(id=4, type=AXON, radius=4.0, parent_node_id=1),
            test_node(id=5, type=AXON, radius=4.0, parent_node_id=4)
        ]

        test_tree(nodes, strict_validation=True)
示例#14
0
    def test_decreasing_radius_when_going_away_from_soma_dendrite_valid(self):
        nodes = [
            test_node(id=1, type=SOMA, radius=36.0, parent_node_id=-1),
            test_node(id=2, type=BASAL_DENDRITE, radius=4.0, parent_node_id=1),
            test_node(id=3, type=BASAL_DENDRITE, radius=2.0, parent_node_id=2),
            test_node(id=4, type=APICAL_DENDRITE, radius=4.0,
                      parent_node_id=1),
            test_node(id=5, type=APICAL_DENDRITE, radius=2.0, parent_node_id=4)
        ]

        test_tree(nodes, strict_validation=True)
示例#15
0
 def test_number_of_soma_nodes_invalid(self):
     try:
         nodes = [
             test_node(id=1, type=SOMA, parent_node_id=-1),
             test_node(id=2, type=SOMA, parent_node_id=-1)
         ]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(
             e.validation_errors,
             "The morphology needs to have one soma node", [[1], [2]])
示例#16
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)
示例#17
0
 def test_independent_axon_with_less_than_four_nodes_no_children(self):
     try:
         nodes = [
             test_node(id=1, type=SOMA, parent_node_id=-1),
             test_node(id=2, type=AXON, parent_node_id=-1)
         ]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(
             e.validation_errors,
             "There is an independent axon with less than 4 nodes", [[2]])
示例#18
0
 def test_soma_node_with_invalid_parent(self):
     try:
         nodes = [
             test_node(id=1, type=SOMA, parent_node_id=-1),
             test_node(id=2, type=SOMA, parent_node_id=1)
         ]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(
             e.validation_errors,
             "Type 1 can only have a parent of the following types:", [[2]])
示例#19
0
 def test_basal_dendrite_traceable_back_to_soma_invalid(self):
     try:
         nodes = [
             test_node(id=1, type=SOMA, parent_node_id=-1),
             test_node(id=2, type=AXON, parent_node_id=1),
             test_node(id=3, type=BASAL_DENDRITE, parent_node_id=-1)
         ]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(e.validation_errors,
                               "must be traceable back to the soma", [[3]])
示例#20
0
 def test_any_radius_valid_for_axon(self):
     for valid_radius in [-10, 0, 3, float('inf')]:
         nodes = [
             test_node(id=1, type=SOMA, radius=36, parent_node_id=-1),
             test_node(id=2,
                       type=AXON,
                       radius=valid_radius,
                       parent_node_id=1)
         ]
         errors = rv.validate_radius_threshold(
             test_tree(nodes, strict_validation=False))
         self.assertEqual(len(errors), 0)
示例#21
0
 def test_number_of_apical_dendrite_with_parent_of_soma_invalid(self):
     try:
         nodes = [
             test_node(id=1, type=SOMA, parent_node_id=-1),
             test_node(id=2, type=APICAL_DENDRITE, parent_node_id=1),
             test_node(id=3, type=APICAL_DENDRITE, parent_node_id=1)
         ]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(
             e.validation_errors,
             "Nodes of type 4 can only have 1 parent of type 1", [[2], [3]])
示例#22
0
 def test_invalid_radius_for_dendrite(self):
     for valid_radius in [20.002, 35, 40, 100, 1000]:
         for dendrite in [BASAL_DENDRITE, APICAL_DENDRITE]:
             nodes = [
                 test_node(id=1, type=SOMA, radius=36, parent_node_id=-1),
                 test_node(id=2,
                           type=dendrite,
                           radius=valid_radius,
                           parent_node_id=1)
             ]
             errors = rv.validate_radius_threshold(
                 test_tree(nodes, strict_validation=False))
             self.assertNodeErrors(errors, "The radius must be", [[2]])
示例#23
0
 def test_valid_radius_for_dendrite(self):
     for valid_radius in [-1, 0, 10, 16, 19.999]:
         for dendrite in [BASAL_DENDRITE, APICAL_DENDRITE]:
             nodes = [
                 test_node(id=1, type=SOMA, radius=36, parent_node_id=-1),
                 test_node(id=2,
                           type=dendrite,
                           radius=valid_radius,
                           parent_node_id=1)
             ]
             errors = rv.validate_radius_threshold(
                 test_tree(nodes, strict_validation=False))
             self.assertEqual(len(errors), 0)
示例#24
0
 def test_basal_dendrite_node_with_invalid_parent_type_independent(self):
     try:
         nodes = [
             test_node(id=1, type=SOMA, parent_node_id=-1),
             test_node(id=2, type=AXON, parent_node_id=1),
             test_node(id=3, type=BASAL_DENDRITE, parent_node_id=-1)
         ]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(
             e.validation_errors,
             "Type 3 can only have a parent of the following types:", [[3]])
示例#25
0
 def test_coordinate_corresponding_to_dendrite_tips_type_20_valid(self):
     for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]:
         nodes = [
             test_node(id=1, type=SOMA, parent_node_id=-1),
             test_node(id=2,
                       type=dendrite_type,
                       x=0,
                       y=0,
                       z=0,
                       parent_node_id=1)
         ]
         mv.validate([test_marker(x=1, y=0, z=0, name=AXON)],
                     test_tree(nodes))
示例#26
0
 def test_immediate_child_of_soma_has_more_than_one_child(self):
     try:
         nodes = [
             test_node(id=1, type=SOMA, parent_node_id=-1),
             test_node(id=2, type=APICAL_DENDRITE, parent_node_id=1),
             test_node(id=3, type=APICAL_DENDRITE, parent_node_id=2),
             test_node(id=4, type=APICAL_DENDRITE, parent_node_id=2)
         ]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(e.validation_errors,
                               "Immediate children of soma cannot branch",
                               [[2]])
示例#27
0
 def test_multiple_axon_initiation_points_not_valid(self):
     try:
         nodes = [
             test_node(id=1, type=SOMA, parent_node_id=-1),
             test_node(id=2, type=AXON, parent_node_id=1),
             test_node(id=3, type=AXON, parent_node_id=1)
         ]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(
             e.validation_errors,
             "Axon can only have one parent of type basal dendrite or soma",
             [[2], [3]])
示例#28
0
    def test_decreasing_radius_when_going_away_from_soma_dendrite_one_branch_valid(
            self):
        for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]:
            nodes = [
                test_node(id=1, type=SOMA, radius=36.0, parent_node_id=-1),
                test_node(id=2,
                          type=dendrite_type,
                          radius=2.0,
                          parent_node_id=1),
                test_node(id=3,
                          type=dendrite_type,
                          radius=4.0,
                          parent_node_id=2)
            ]

            test_tree(nodes, strict_validation=True)
示例#29
0
    def test_distance_between_connected_nodes_valid(self):

        nodes = [
            test_node(id=1, type=SOMA, parent_node_id=-1),
            test_node(id=2,
                      type=AXON,
                      x=3188.34,
                      y=2891.57,
                      z=88.9906,
                      parent_node_id=1),
            test_node(id=3,
                      type=AXON,
                      x=3198.34,
                      y=2888.57,
                      z=89.9906,
                      parent_node_id=2)
        ]
        test_tree(nodes, strict_validation=True)
示例#30
0
 def test_invalid_radius_multiple_types(self):
     try:
         nodes = [
             test_node(id=1, type=SOMA, radius=2.0, parent_node_id=-1),
             test_node(id=2, type=AXON, radius=2.0, parent_node_id=-1),
             test_node(id=3,
                       type=BASAL_DENDRITE,
                       radius=32.0,
                       parent_node_id=1),
             test_node(id=4,
                       type=APICAL_DENDRITE,
                       radius=32.0,
                       parent_node_id=1)
         ]
         test_tree(nodes, strict_validation=True)
         self.fail("Morphology should have been rejected.")
     except InvalidMorphology as e:
         self.assertNodeErrors(e.validation_errors, "The radius must be",
                               [[1], [3], [4]])