Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

printing data frames with validation function information #115

Merged
merged 23 commits into from
Feb 12, 2024
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d6d481b
first test functions for validate_mesh_structure_pairs
viktorpm Jan 29, 2024
512cd63
storing atlases and successful/failed validation functions in a data …
viktorpm Jan 31, 2024
3aaf90a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 31, 2024
4e29467
restoring test_validation.py to the original merged version. Chages a…
viktorpm Jan 31, 2024
84de0d1
restoring test_validation.py to the original merged version. Chages a…
viktorpm Jan 31, 2024
f6b0dc0
validate_atlases.py: going back to the version on main, appending onl…
viktorpm Feb 1, 2024
fd8a6a8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 1, 2024
a0ba87b
populating dictionaries in for loop, writing JSON files
viktorpm Feb 1, 2024
6d9707b
Merge branch 'cosmetics' of github.com:brainglobe/bg-atlasgen into co…
viktorpm Feb 1, 2024
0bd3163
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 1, 2024
a980f67
saving JSON files to ~/.brainglobe/atlases/validation
viktorpm Feb 2, 2024
eec486a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 2, 2024
398dccc
printing where to find the result files
viktorpm Feb 2, 2024
56686e1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 2, 2024
576d8d2
Update bg_atlasgen/validate_atlases.py
viktorpm Feb 5, 2024
d7a7d3b
Update bg_atlasgen/validate_atlases.py
viktorpm Feb 5, 2024
defaa29
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 5, 2024
16dee78
Merge branch 'main' into cosmetics
viktorpm Feb 6, 2024
8773286
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 6, 2024
da4cc8f
saving only one JSON file with all the information
viktorpm Feb 9, 2024
6c00f6d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 9, 2024
58722fd
uncommenting test functions
viktorpm Feb 9, 2024
dea87e4
Merge branch 'cosmetics' of github.com:brainglobe/bg-atlasgen into co…
viktorpm Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions bg_atlasgen/validate_atlases.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Script to validate atlases"""

import json
import os
from pathlib import Path

Expand Down Expand Up @@ -151,18 +152,20 @@ def validate_atlas(atlas_name, version, validation_functions):
if not updated:
update_atlas(atlas_name)

# list to store the errors of the failed validations
failed_validations = {atlas_name: []}
successful_validations = {atlas_name: []}
validation_results = {atlas_name: []}

for i, validation_function in enumerate(validation_functions):
for i, validation_function in enumerate(all_validation_functions):
try:
validation_function(BrainGlobeAtlas(atlas_name))
successful_validations[atlas_name].append(validation_function)
validation_results[atlas_name].append(
(validation_function.__name__, None, str("Pass"))
)
except AssertionError as error:
failed_validations[atlas_name].append((validation_function, error))
validation_results[atlas_name].append(
(validation_function.__name__, str(error), str("Fail"))
)

return successful_validations, failed_validations
return validation_results


if __name__ == "__main__":
Expand All @@ -178,17 +181,29 @@ def validate_atlas(atlas_name, version, validation_functions):

valid_atlases = []
invalid_atlases = []
validation_results = {}

for atlas_name, version in get_all_atlases_lastversions().items():
successful_validations, failed_validations = validate_atlas(
temp_validation_results = validate_atlas(
atlas_name, version, all_validation_functions
)
for item in successful_validations:
valid_atlases.append(item)
for item in failed_validations:
invalid_atlases.append(item)

print("Summary")
print("### Valid atlases ###")
print(valid_atlases)
print("### Invalid atlases ###")
print(invalid_atlases)
validation_results.update(temp_validation_results)

print("Validation has been completed")
print("Find validation_results.json in ~/.brainglobe/atlases/validation/")

# Get the directory path
output_dir_path = str(get_brainglobe_dir() / "atlases/validation")

# Create the directory if it doesn't exist
if not os.path.exists(output_dir_path):
os.makedirs(output_dir_path)

# Open a file for writing (will overwrite any files from previous runs!)
with open(
str(
get_brainglobe_dir() / "atlases/validation/validation_results.json"
),
"w",
) as file:
json.dump(validation_results, file)
Loading