brainglobe / brainglobe-atlasapi

A lightweight python module to interact with atlases for systems neuroscience
https://brainglobe.info/documentation/brainglobe-atlasapi/index.html
BSD 3-Clause "New" or "Revised" License
117 stars 24 forks source link

validate_atlases.py additional_references error #275

Closed viktorpm closed 1 month ago

viktorpm commented 1 month ago

Describe the bug

allen_human_500um 0.1
/nfs/nhome/live/vplattner/_projects/validation/brainglobe-atlasapi/brainglobe_atlasapi/core.py:65: UserWarning: This atlas seems to be outdated as no additional_references list is found in metadata!
  warnings.warn(
Traceback (most recent call last):
  File "/nfs/nhome/live/vplattner/_projects/validation/brainglobe-atlasapi/brainglobe_atlasapi/atlas_generation/validate_atlases.py", line 252, in <module>
    temp_validation_results = validate_atlas(
                              ^^^^^^^^^^^^^^^
  File "/nfs/nhome/live/vplattner/_projects/validation/brainglobe-atlasapi/brainglobe_atlasapi/atlas_generation/validate_atlases.py", line 222, in validate_atlas
    validation_function(BrainGlobeAtlas(atlas_name))
  File "/nfs/nhome/live/vplattner/_projects/validation/brainglobe-atlasapi/brainglobe_atlasapi/atlas_generation/validate_atlases.py", line 132, in validate_additional_references
    ) in atlas.additional_references.references_list:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'BrainGlobeAtlas' object has no attribute 'additional_references'

To Reproduce

module load mamba
mamba init
mamba activate bg-atlasapi
git clone https://github.com/brainglobe/brainglobe-atlasapi.git
cd brainglobe-atlasapi/
git checkout main

pip install -e ".[allenmouse, dev]"
pip install scikit-image
pip install imio
pip install brainio

python brainglobe_atlasapi/atlas_generation/validate_atlases.py

Computer used (please complete the following information):

adamltyson commented 1 month ago

I think this should be added to the validation scripts, to check that the atlases have additional_references set correctly (or at all).

alessandrofelder commented 1 month ago

The warning is useful in this case, I think, @viktorpm

UserWarning: This atlas seems to be outdated as no additional_references list is found in metadata!

This suggests that there is an atlas (is it the human atlas or the one after in the validation list?) that hasn't been updated since we introduced the additional references concept in the code.

How I think it is intended to work (for atlases with no additional references):

viktorpm commented 1 month ago

@alessandrofelder, looks like the human atlas doesn't return what the validate_additional_references function expects. The warning has always been there, so that shouldn't be a problem. I tried to print the reference list allenhu.additional_references.references_list but got an error. Should we try to catch the error and continue the validation or fix the atlas (it is likely a bigger job)?

allen mouse 100um atlas

allen100 = BrainGlobeAtlas("allen_mouse_100um") 

allen100.additional_references.references_list

[]

allen human 500um atlas

allenhu = BrainGlobeAtlas("allen_human_500um")
/home/plattnerv/miniforge3/envs/bg-atlasapi/lib/python3.11/site-packages/brainglobe_atlasapi/core.py:65: UserWarning: This atlas seems to be outdated as no additional_references list is found in metadata!
  warnings.warn(

allenhu.additional_references.references_list

Traceback (most recent call last):
  File "/home/plattnerv/.pycharm_helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
           ^^^^^^
  File "<input>", line 1, in <module>
AttributeError: 'BrainGlobeAtlas' object has no attribute 'additional_references'
adamltyson commented 1 month ago

To fix the issue, I think (famous last words) that the human atlas just needs to be regenerated. It should then have the correct metadata. I think the issue stems from the fact that it hasn't been regenerated since the concept of additional references was added to the atlas API.

viktorpm commented 1 month ago

I agree, but I couldn't find an easy fix for the script. I'll make it my priority to work on that (in a new PR).