ANTsX / ANTsPyNet

Pre-trained models and utilities for deep learning on medical images in Python
https://antspynet.readthedocs.io
Apache License 2.0
200 stars 29 forks source link

Question about antsxnet_cache_directory (string) in antspynet.utilities.brain_extraction. #128

Open Lucifer201210 opened 2 months ago

Lucifer201210 commented 2 months ago

Hi, When I exacted brain using antspynet.utilities.brain_extraction according to AntsPyNet document (https://antsx.github.io/ANTsPyNet/docs/build/html/utilities.html#applications), an error happened.

截图 2024-08-22 00-41-48

According this document, the antsxnet_cache_directorywas used to store the downloaded template and model weights. I haved download brainExtractionRobustT1.h5 and S_template3_resampled.nii.gz in a folder. Then I set antsxnet_cache_directory to this folder path. the code was as following:

截图 2024-08-22 00-50-33

截图 2024-08-22 00-50-59

brainExtractionRobustT1.h5 and S_template3_resampled.nii.gz were in /home/wei/DeepLearning/Model_pth/, Since I haved downloaded template and model weights to the folder path which antsxnet_cache_directory was pointed to,why antspynet.utilities.brain_extraction still need to download data from https://ndownloader.figshare.com/files/22597175

Then I copy brainExtractionRobustT1.h5 and S_template3_resampled.nii.gz to ~/.keras/ANTsXNet, and run antspynet.utilities.brain_extraction twice, the same error happed.

截图 2024-08-22 01-04-35

When I copy https://ndownloader.figshare.com/files/22597175 to my google chrome, It automatically download S_template3_resampled.nii.gz . I don't know the reason why error happend.

cookpa commented 2 months ago

Code looks correct, always good to verify that the file is accessible before calling brain_extraction

import os
mycachedir = '/home/wei/DeepLearning/Model_pth/'
os.listdir(mycachedir)
os.access(os.path.join(mycachedir, 'brainExtractionRobustT1.h5'), os.R_OK)
ntustison commented 2 months ago

And, fyi, I would always check with the self-contained, minimal tutorials for antsxnet available here.

Lucifer201210 commented 2 months ago

Code looks correct, always good to verify that the file is accessible before calling brain_extraction

import os
mycachedir = '/home/wei/DeepLearning/Model_pth/'
os.listdir(mycachedir)
os.access(os.path.join(mycachedir, 'brainExtractionRobustT1.h5'), os.R_OK)

Thanks! I tried the code above and the file is accessible.

截图 2024-08-23 14-52-02

The same error happened as before. Is it needed to install any other dependencies or Tensorflow/pytorch before using brain_exaction?

cookpa commented 2 months ago

I made #130 in an effort to simplify cache issues like this