ANTsX / ANTsPy

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.
https://antspyx.readthedocs.io
Apache License 2.0
586 stars 161 forks source link

File errors in `ants` folder under home directory crashes ANTsPyx #671

Open dipterix opened 3 weeks ago

dipterix commented 3 weeks ago

I copied some home-brewed scripts using ants into my home directory, under folder name ants.

It seems that whenever I load ants, the package will run whatever is in the ~/ants folder, and errors out when the folder script contains bugs.

I wonder if it's possible to

  1. add try-catch to wrap loading ~/ants so ants loads even there is an error in the script
  2. add a special file (e.g. .ANTSIGNORE), which list files that should be excluded from startup.
ncullen93 commented 3 weeks ago

I sort of get what you mean but would need a bit more explanation. Would just renaming your folder to something else fix it? It is never really advisable to have a folder with the same name as a package... but I'm assuming you actually have the repo cloned? If you're willing to submit a PR the it sounds like something we can definitely use.

dipterix commented 3 weeks ago

I was able to fix it by myself. I understand the solution is easy once found out. However, that requires me to read into the python error trace back messages. I was helping a physician with his computer but they don't know too much about programming. What's even worse is that they have pipeline SOP that includes creating this folder.

Though I told them not to do this. It's pretty straightforward and common for lots of people to create folders with the same name under home directory, just to store their daily functions. For programs, I believe there are better places to store the package add-ons. For example $XDG_DATA_HOME, $XDG_CONFIG_HOME, and $XDG_CACHE_HOME.

However, I guess changing to $XDG_CONFIG_HOME or $XDG_DATA_HOME may be hard for ANTs as you probably created this "add-on" loader because someone wants to use this feature. That's why files like .ANTS_IGNORE or .ANTS_ADD_ON could help resolving the current issues without putting too much efforts: it simply allows ANTs to either ignore or include some starting up files. Or even simpler, putting try-catch with warnings.

If you could point me to where the loading is happening, I'm happy to write a PR.

gdevenyi commented 3 weeks ago

It seems that whenever I load ants, the package will run whatever is in the ~/ants folder, and errors out when the folder script contains bugs.

Can you show an exact set of commands you're doing, and the output you're getting?