Skip to content

Commit

Permalink
Merge pull request #225 from AllenInstitute/axon_parent_validation_fix
Browse files Browse the repository at this point in the history
Axon parent validation fix
  • Loading branch information
gouwens authored Apr 29, 2024
2 parents 67e436a + adfa09c commit c884d0d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion neuron_morphology/validation/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def add_swc_stats(self, swc_file, stats):
self.file_record[swc_file] = record

def to_json(self):
return json.dumps(self.file_record.values(), indent=4, separators=(',', ': '))
record_list = list(self.file_record.values())
return json.dumps(record_list, indent=4, separators=(',', ': '))

def has_results(self):

Expand Down
2 changes: 1 addition & 1 deletion neuron_morphology/validation/type_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def validate_node_parent(morphology):

for node in axon_nodes_with_invalid_parents:
result.append(ve("Type 2 can only have a parent of the following types: %s" % valid_axon_parents, node['id'],
"Error"))
"Warning"))

basal_dendrite_nodes = morphology.get_node_by_types([BASAL_DENDRITE])

Expand Down
8 changes: 7 additions & 1 deletion neuron_morphology/validation/validate_reconstruction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import json
import logging
import neuron_morphology.swc_io as swc
import neuron_morphology.validation as validation
Expand All @@ -21,6 +22,7 @@ def parse_arguments(args):
parser.add_argument('--dir', type=str, nargs='+', help="SWC and Marker files")
parser.add_argument('--swc', type=str, help="SWC file")
parser.add_argument('--marker', type=str, help="Marker file")
parser.add_argument('--report_json', type=str, help="Report output json file")
return parser.parse_args(args)


Expand Down Expand Up @@ -89,8 +91,12 @@ def main():
except InvalidMarkerFile as imf:
report.add_marker_results(marker_file, imf.validation_errors)

print(report.to_json())
report_output = report.to_json()
print(report_output)
if report.has_results():
if args['report_json']:
with open(args['report_json'],'w') as f:
json.dump(report_output, f)
sys.exit(1)


Expand Down

0 comments on commit c884d0d

Please sign in to comment.