-
Notifications
You must be signed in to change notification settings - Fork 24
Structure validation #110
Structure validation #110
Conversation
for more information, see https://pre-commit.ci
fixing atlas path
Clearer output printing
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…erance argument to _assert_close function
for more information, see https://pre-commit.ci
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #110 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 24 24
Lines 1927 1943 +16
=====================================
- Misses 1927 1943 +16 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start - I've made a suggestion about how to make this new validation function could be made more consistent with the other validation functions, so it integrates smoothly into the script.
bg_atlasgen/validate_atlases.py
Outdated
matching_files = [ | ||
f"{num}.obj" for num in id_numbers if f"{num}.obj" in obj_file_list | ||
] | ||
missing_files = [ | ||
num for num in id_numbers if f"{num}.obj" not in obj_file_list | ||
] | ||
|
||
print(f"IDs without corresponding obj files: {missing_files}") | ||
print(f"IDs with corresponding obj files: {matching_files}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the other validation functions, we should raise an AssertionError
with the appropriate error message here, I think?
bg_atlasgen/validate_atlases.py
Outdated
id_numbers = [item[target_key] for item in json_file if target_key in item] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need the if
part here? Should not all items in the json_file have an id
key?
I wonder whether we should check the id via the bg_atlasapi via something like
atlas = BrainGlobeAtlas(atlas_name)
bg_atlas_api_ids = list(atlas.structures.keys())
# a fancy, one-line way to get the ids from the meshes - see https://docs.python.org/3/library/pathlib.html?highlight=stem#pathlib.PurePath.stem
ids_from_mesh_files = [
int(Path(file).stem) for file in os.listdir(obj_path) if file.endswith(".obj")
]
in_mesh_not_bg = []
for id in ids_from_mesh_files:
if id not in bg_atlas_api_ids:
in_mesh_not_bg.append(id)
in_bg_not_mesh = []
for id in bg_atlas_api_ids:
if id not in ids_from_mesh_files:
in_bg_not_mesh.append(id)
if len(in_mesh_not_bg) or len(in_bg_not_mesh):
raise AssertionError(f"Structures with ID {in_bg_not_mesh} are in the atlas, but don't have a corresponding mesh file; Structures with IDs {in_mesh_not_bg} have a mesh file, but are not accessible through the atlas.")
This is designed to throw at most one assertion error, so successful and failed validation results get logged in the same way as other validation functions (see next comment).
bg_atlasgen/validate_atlases.py
Outdated
return successful_validations, failed_validations | ||
|
||
|
||
def validate_mesh_structure_pairs(atlas_path: Path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should at least make an issue to write tests for this function if we don't add them in this PR.
I meant to request changes - sorry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start - I've made a suggestion about how to make this new validation function could be made more consistent with the other validation functions, so it integrates smoothly into the script.
Co-authored-by: Alessandro Felder <[email protected]>
…esible through the atlas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
What is this PR
Why is this PR needed?
We want to test if all the atlases fit the brainglobe framework
What does this PR do?
Adds a new validation function called
validate_mesh_structure_pairs
to the existingvalidate_atlases.py
scriptReferences
See PR #90
How has this PR been tested?
It was run locally to test if the new function works on existing data
Is this a breaking change?
No
Does this PR require an update to the documentation?
Not for now
Checklist: