def test_multiple_axon_initiation_points_valid_with_independent_axon(self): morphology.Morphology([ 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) ], strict_validation=True)
def test_decreasing_radius_when_going_away_from_soma_axon_valid(self): morphology.Morphology([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)] , strict_validation=True)
def test_decreasing_radius_when_going_away_from_soma_dendrite_valid(self): morphology.Morphology([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)] , strict_validation=True)
def test_coordinate_corresponding_to_dendrite_tips_multiple_cut_dendrite_invalid( self): for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]: test_morphology = morphology.Morphology([ 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) ], strict_validation=False) 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_morphology) 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 }]])
def test_basal_dendrite_node_with_valid_parent_type(self): for node_type in [SOMA]: morphology.Morphology([ test_node(id=1, type=node_type, parent_node_id=-1), test_node(id=2, type=BASAL_DENDRITE, parent_node_id=1) ], strict_validation=True)
def test_axon_node_with_valid_parent_type(self): for node_type in [SOMA, AXON]: morphology.Morphology([ test_node(id=1, type=node_type, parent_node_id=-1), test_node(id=2, type=AXON, parent_node_id=1) ], strict_validation=True)
def test_apical_dendrite_traceable_back_to_soma_valid(self): morphology.Morphology([ 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) ], strict_validation=True)
def test_absence_of_constriction_for_dendrite_multiple_children_less_than_limit(self): for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]: morphology.Morphology([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=2)] , strict_validation=True)
def test_coordinate_corresponding_to_axon_tips_type_20_valid(self): test_morphology = morphology.Morphology([ test_node(id=1, type=SOMA, parent_node_id=-1), test_node(id=2, type=AXON, x=0, y=0, z=0, parent_node_id=1) ], strict_validation=False) mv.validate([test_marker(x=0, y=0, z=0, name=AXON)], test_morphology)
def test_independent_axon_with_more_than_four_nodes_child_branch(self): morphology.Morphology([ 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) ], strict_validation=True)
def test_children_nodes_appear_before_parent_nodes_not_valid(self): try: morphology.Morphology([test_node(id=1, type=AXON, parent_node_id=2) , test_node(id=2, type=SOMA, parent_node_id=-1)] , strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors(e.validation_errors, "Child node needs to come before parent node", [[1]])
def test_immediate_child_of_soma_doesnt_more_than_one_child(self): morphology.Morphology([ 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) ], strict_validation=True)
def test_coordinate_corresponding_to_dendrite_tips_type_20_valid(self): for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]: test_morphology = morphology.Morphology([ 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) ], strict_validation=False) mv.validate([test_marker(x=1, y=0, z=0, name=AXON)], test_morphology)
def test_invalid_radius_multiple_types(self): try: morphology.Morphology([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)] , strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors(e.validation_errors, "The radius must be", [[1], [3], [4]])
def test_existence_of_constriction_for_dendrite_one_child_less_than_limit(self): try: for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]: morphology.Morphology([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)] , strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors(e.validation_errors, "Constriction: The radius of types 3 and 4 should not be less " "than 2.0px", [[2]])
def test_number_of_soma_nodes_invalid(self): try: morphology.Morphology([ test_node(id=1, type=SOMA, parent_node_id=-1), test_node(id=2, type=SOMA, parent_node_id=-1) ], strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors( e.validation_errors, "The morphology needs to have one soma node", [[1], [2]])
def test_independent_axon_with_less_than_four_nodes_no_children(self): try: morphology.Morphology([ test_node(id=1, type=SOMA, parent_node_id=-1), test_node(id=2, type=AXON, parent_node_id=-1) ], strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors( e.validation_errors, "There is an independent axon with less than 4 nodes", [[2]])
def test_apical_dendrite_traceable_back_to_soma_invalid(self): try: morphology.Morphology([ 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) ], strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors(e.validation_errors, "must be traceable back to the soma", [[3]])
def test_soma_node_with_invalid_parent(self): try: morphology.Morphology([ test_node(id=1, type=SOMA, parent_node_id=-1), test_node(id=2, type=SOMA, parent_node_id=1) ], strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors( e.validation_errors, "Type 1 can only have a parent of the following types:", [[2]])
def test_existence_of_constriction_for_dendrite_multiple_children(self): for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]: try: morphology.Morphology([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)] , strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors(e.validation_errors, "Constriction: The radius of types 3 and 4 should not be " "less than 2.0px", [[4], [5]])
def test_basal_dendrite_node_with_invalid_parent_type_independent(self): try: morphology.Morphology([ 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) ], strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors( e.validation_errors, "Type 3 can only have a parent of the following types:", [[3]])
def test_number_of_apical_dendrite_with_parent_of_soma_invalid(self): try: morphology.Morphology([ 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) ], strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors( e.validation_errors, "Nodes of type 4 can only have 1 parent of type 1", [[2], [3]])
def test_multiple_axon_initiation_points_not_valid(self): try: morphology.Morphology([ 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) ], strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors( e.validation_errors, "Axon can only have one parent of type basal dendrite or soma", [[2], [3]])
def test_immediate_child_of_soma_has_more_than_one_child(self): try: morphology.Morphology([ 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) ], strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors(e.validation_errors, "Immediate children of soma cannnot branch", [[2]])
def test_absence_of_extreme_taper_for_dendrite_more_than_eight_nodes_in_one_segment(self): for dendrite_type in [BASAL_DENDRITE, APICAL_DENDRITE]: morphology.Morphology([test_node(id=1, type=SOMA, radius=36.0, parent_node_id=-1) , test_node(id=2, type=dendrite_type, radius=4.0, parent_node_id=1) , test_node(id=3, type=dendrite_type, radius=4.0, parent_node_id=2) , test_node(id=4, type=dendrite_type, radius=4.0, parent_node_id=3) , test_node(id=5, type=dendrite_type, radius=4.0, parent_node_id=4) , test_node(id=6, type=dendrite_type, radius=4.0, parent_node_id=5) , test_node(id=7, type=dendrite_type, radius=4.0, parent_node_id=6) , test_node(id=8, type=dendrite_type, radius=3.0, parent_node_id=7) , test_node(id=9, type=dendrite_type, radius=3.0, parent_node_id=8)] , strict_validation=True)
def test_distance_between_connected_nodes_valid(self): morphology.Morphology([ 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) ], strict_validation=True)
def test_number_of_type_30_less_than_one(self): test_morphology = morphology.Morphology( [test_node(id=1, type=SOMA, parent_node_id=-1)], strict_validation=False) errors = mv.validate([test_marker(name=NO_RECONSTRUCTION)], test_morphology) self.assertMarkerErrors(errors, "Total number of type 30s is 0", [[{}]])
def test_distance_between_connected_nodes_invalid(self): try: morphology.Morphology([ 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) ], strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors( e.validation_errors, "The distance between two nodes should be less than 50px", [[2, 3]])
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: morphology.Morphology([test_node(id=1, type=SOMA, radius=36.0, parent_node_id=-1) , test_node(id=2, type=dendrite_type, radius=5.0, parent_node_id=1) , test_node(id=3, type=dendrite_type, radius=5.0, parent_node_id=2) , test_node(id=4, type=dendrite_type, radius=5.0, parent_node_id=3) , test_node(id=5, type=dendrite_type, radius=5.0, parent_node_id=4) , test_node(id=6, type=dendrite_type, radius=5.0, parent_node_id=5) , test_node(id=7, type=dendrite_type, radius=5.0, parent_node_id=6) , test_node(id=8, type=dendrite_type, radius=1.0, parent_node_id=7) , test_node(id=9, type=dendrite_type, radius=1.0, parent_node_id=8)] , strict_validation=True) self.fail("Morphology should have been rejected.") except InvalidMorphology, e: self.assertNodeErrors(e.validation_errors, "Extreme Taper: For types 3 and 4", [[2, 8]])
def test_coordinate_corresponding_to_axon_tips_no_reconstruction_invalid( self): test_morphology = morphology.Morphology([ test_node(id=1, type=SOMA, parent_node_id=-1), test_node(id=2, type=AXON, x=0, y=0, z=0, parent_node_id=1) ], strict_validation=False) errors = mv.validate([ test_marker(x=1, y=0, z=0, name=NO_RECONSTRUCTION), test_marker(x=1, y=0, z=0, name=TYPE_30) ], test_morphology) self.assertMarkerErrors( errors, "Coordinates for each axon (type 20) needs to correspond to " "a tip of an axon type (type 2) in the related morphology", [[{ 'x': 1, 'y': 0, 'z': 0, 'name': NO_RECONSTRUCTION }]])