Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
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]])
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
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)
 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]])
Beispiel #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)
Beispiel #10
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)
Beispiel #11
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)
Beispiel #12
0
 def test_valid_radius_multiple_types(self):
     nodes = [
         test_node(id=1, type=SOMA, radius=36.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=3.0, parent_node_id=1),
         test_node(id=4, type=BASAL_DENDRITE, radius=2.0, parent_node_id=3),
         test_node(id=5, type=APICAL_DENDRITE, radius=3.0,
                   parent_node_id=1),
         test_node(id=6, type=APICAL_DENDRITE, radius=2.0, parent_node_id=5)
     ]
     test_tree(nodes)
Beispiel #13
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]])
Beispiel #14
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]])
Beispiel #15
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]])
Beispiel #16
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]])
Beispiel #17
0
    def test_absence_of_constriction_for_dendrite_after_node_ten_from_soma(
            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=10.0,
                          parent_node_id=1),
                test_node(id=3,
                          type=dendrite_type,
                          radius=11.0,
                          parent_node_id=2),
                test_node(id=4,
                          type=dendrite_type,
                          radius=12.0,
                          parent_node_id=3),
                test_node(id=5,
                          type=dendrite_type,
                          radius=12.0,
                          parent_node_id=4),
                test_node(id=6,
                          type=dendrite_type,
                          radius=12.0,
                          parent_node_id=5),
                test_node(id=7,
                          type=dendrite_type,
                          radius=12.0,
                          parent_node_id=6),
                test_node(id=8,
                          type=dendrite_type,
                          radius=12.0,
                          parent_node_id=7),
                test_node(id=9,
                          type=dendrite_type,
                          radius=12.0,
                          parent_node_id=8),
                test_node(id=10,
                          type=dendrite_type,
                          radius=12.0,
                          parent_node_id=9),
                test_node(id=11,
                          type=dendrite_type,
                          radius=12.0,
                          parent_node_id=10),
                test_node(id=12,
                          type=dendrite_type,
                          radius=1.5,
                          parent_node_id=11)
            ]

            test_tree(nodes, strict_validation=True)
Beispiel #18
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]])
Beispiel #19
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]])
Beispiel #20
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]])
Beispiel #21
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]])
Beispiel #22
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
                }]])
Beispiel #23
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)
Beispiel #24
0
    def test_existence_of_extreme_taper_for_dendrite_more_than_eight_nodes_in_one_segment(
            self):
        for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]:
            try:
                nodes = [
                    test_node(id=1, type=SOMA, radius=36.0, parent_node_id=-1),
                    test_node(id=2,
                              type=dendrite_type,
                              radius=12.0,
                              parent_node_id=1),
                    test_node(id=3,
                              type=dendrite_type,
                              radius=12.0,
                              parent_node_id=2),
                    test_node(id=4,
                              type=dendrite_type,
                              radius=12.0,
                              parent_node_id=3),
                    test_node(id=5,
                              type=dendrite_type,
                              radius=12.0,
                              parent_node_id=4),
                    test_node(id=6,
                              type=dendrite_type,
                              radius=12.0,
                              parent_node_id=5),
                    test_node(id=7,
                              type=dendrite_type,
                              radius=12.0,
                              parent_node_id=6),
                    test_node(id=8,
                              type=dendrite_type,
                              radius=2.0,
                              parent_node_id=7),
                    test_node(id=9,
                              type=dendrite_type,
                              radius=2.0,
                              parent_node_id=8)
                ]

                test_tree(nodes, strict_validation=True)
                self.fail("Morphology should have been rejected.")
            except InvalidMorphology as e:
                self.assertNodeErrors(e.validation_errors,
                                      "Extreme Taper: For types 3 and 4",
                                      [[2, 8]])
Beispiel #25
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)
Beispiel #26
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)
Beispiel #27
0
    def test_absence_of_constriction_for_dendrite(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=12.0,
                          parent_node_id=1),
                test_node(id=3,
                          type=dendrite_type,
                          radius=11.0,
                          parent_node_id=2),
                test_node(id=4,
                          type=dendrite_type,
                          radius=10.0,
                          parent_node_id=3)
            ]

            test_tree(nodes, strict_validation=True)
Beispiel #28
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]])
Beispiel #29
0
    def test_existence_of_constriction_for_dendrite_one_child_less_than_limit(
            self):
        try:
            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=1.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,
                "Constriction: The radius of types 3 and 4 should not be less "
                "than 2.0px", [[2]])
Beispiel #30
0
    def test_distance_between_connected_nodes_invalid(self):
        try:

            nodes = [
                test_node(id=1, type=SOMA, parent_node_id=-1),
                test_node(id=2,
                          type=AXON,
                          x=6725.2098,
                          y=5890.6503,
                          z=76.0,
                          parent_node_id=1),
                test_node(id=3, type=AXON, x=0, y=0, z=0, 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,
                "The distance between two nodes should be less than 50px",
                [[2, 3]])