109 feature integrating mni template#126
Conversation
use constants and download data or custom path
| return | ||
|
|
There was a problem hiding this comment.
The _download_atlases function returns no value when the download fails (status code != 200), despite its signature requiring a Path. Consider raising an exception or returning a default Path to maintain consistency.
| return | |
| raise RuntimeError(f"Failed to download atlases from {archive_url}. Status code: {response.status_code}") |
| """ | ||
| try: | ||
| response = requests.get(f"{ZENODO_RECORD_URL}") | ||
| if response.status_code != 200: |
There was a problem hiding this comment.
After logging the error for a non-200 response in _get_zenodo_metadata_and_archive_url, the function should return None to avoid attempting to parse an invalid JSON response.
There was a problem hiding this comment.
@MarcelRosier does the 👍 mean you will change it like this? :)
There was a problem hiding this comment.
should already be done in afbc8a8
@neuronflow
|
also resolves #116 |
raise runtime error add return None
neuronflow
left a comment
There was a problem hiding this comment.
Looks good to me.
Probably we should document this atlas situation somewhere and we also need some documentation in the future.
We will probably not remember the difference between these atlases in the more distant future.
Agreed, created an issue #127; maybe a task for @evamariie ? |
Move atlases to zenodo and add constants to use them, currently supporting:
BRATS_SRI24, BRATS_SRI24_SKULLSTRIPPED, SRI24, SRI24_SKULLSTRIPPED, BRATS_MNI152
AI summary:
This pull request introduces significant updates to the
brainles_preprocessingmodule, focusing on atlas management, preprocessing enhancements, and improved error handling. The most notable changes include the addition of anAtlasenum, integration of a newverify_or_download_atlasesutility for managing atlases, updates to the preprocessor to support the new atlas functionality, and improved handling of optional dependencies. Below is a breakdown of the changes:Atlas Management Enhancements:
Atlasenum inbrainles_preprocessing/constants.pyto standardize atlas file references. ([brainles_preprocessing/constants.pyR11-R18](https://github.com/BrainLesion/preprocessing/pull/126/files#diff-475820ca3f02cf696a2d05f9ea7b8180d6b46638e918959f8931a8a60d1d4ebbR11-R18))verify_or_download_atlasesutility inbrainles_preprocessing/utils/zenodo.pyto manage atlas downloads from Zenodo, ensuring the latest version is always available. ([brainles_preprocessing/utils/zenodo.pyR1-R187](https://github.com/BrainLesion/preprocessing/pull/126/files#diff-4fb0edacbf74a6a17344f426fbd0c13af3255d5754b47a38a4837f7179117205R1-R187))Preprocessorclass to acceptAtlasenum values foratlas_image_path, defaulting toAtlas.BRATS_SRI24. This integrates seamlessly with the new atlas management utility. ([[1]](https://github.com/BrainLesion/preprocessing/pull/126/files#diff-2bff270dd9133b62ffd46d580258f85a16c6cfa94dfbbd75adac5799ec1b5109L53-R54),[[2]](https://github.com/BrainLesion/preprocessing/pull/126/files#diff-2bff270dd9133b62ffd46d580258f85a16c6cfa94dfbbd75adac5799ec1b5109L70-R73))Preprocessor Improvements:
Preprocessorclass to dynamically resolve atlas paths usingverify_or_download_atlaseswhen anAtlasenum value is provided. ([brainles_preprocessing/preprocessor.pyL70-R73](https://github.com/BrainLesion/preprocessing/pull/126/files#diff-2bff270dd9133b62ffd46d580258f85a16c6cfa94dfbbd75adac5799ec1b5109L70-R73))Optional Dependency Handling:
try-exceptblocks inbrainles_preprocessing/registration/__init__.pyto gracefully handle missing optional dependencies (itk-elastixandpicsl_greedy), with user-friendly warnings. ([brainles_preprocessing/registration/__init__.pyR21-R34](https://github.com/BrainLesion/preprocessing/pull/126/files#diff-692e53e54cb8ce147cf01644690d67acc119d312a8380bfa11c08994fbd65af5R21-R34))Testing and Validation:
tests/test_zenodo.pyto validate the functionality of theverify_or_download_atlasesutility, including scenarios for missing local atlases, outdated versions, and Zenodo connectivity issues. ([tests/test_zenodo.pyR1-R162](https://github.com/BrainLesion/preprocessing/pull/126/files#diff-556e52b52cee06ab58536bb1f4907d9b4ed44c5613de72b6a8085b65dc5e8358R1-R162))