-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed difference between binaries and python wrappers #703
Comments
For @ntustison @stnava shall we harmonize defaults, which one to adopt? I'll go with faster (2) unless you have a preference to make antspy the standard. |
Yeah, I'm all for harmonizing the defaults and I'd go with what's in the original ANTs DenoiseImage. |
For denoiseimage in particular, I would hope you could normalize with the OG implementation |
Is there a usage with defaults you could paste here? |
DenoiseImage was ported from Jose's original Matlab code. Minc code was not referenced at all. |
Well
|
I profiled n4_bias_correction with the line_profiler / kernprof, the library function execution accounts for 99.4% of the execution time. So there's not a lot of work happening at the wrapper level. |
Yes, I realize that. But you were referring to a specific implementation in the context of defaults and that's why I clarified that it was Jose's original Matlab code. |
Just a bit more historical context---I happened to be invited by an MNI-adjacent friend for a get-together during MICCAI 2013 in Nagoya, Japan. Fortunately, I sat right across the table from Jose and, after discussing common interests (such our enjoyment of Luis Miguel), he realized I was "one of the ANTs guys" and he asked me if I would like to put his denoising algorithm in ANTs. I said sure and he pointed me to his Matlab code which I eventually ported to ITK-style. After the FreeSurfer folk began using the implementation in their pipeline a couple years ago, I asked Jose about the possibility of making it an ITK module and he was all for it. |
I think there might also be optimization differences in the ITK / ANTs compilation. It seems Lines 4 to 10 in 8911caa
Also the ITK compilation has Lines 20 to 21 in 8911caa
|
Correct, I did not notice the difference with Here is what I have now :
|
Thanks for testing, @benoitberanger Would you mind trying out #705 ? If you have the Github CLI, you can do
It appears to close the gap on my Mac. |
Wow! Thanks for reporting this |
Describe the bug
There is a massive difference of computation time between Terminal CLI and the Python wrappers for
N4BiasFieldCorrection
andDenoiseImage
From the terminal :
N4BiasFieldCorrection : 22s
DenoiseImage : 76s
From Python:
N4BiasFieldCorrection : 33s
DenoiseImage : 602s
To reproduce
I use a classic 3DT2 in 0.8mm iso:
From the terminal :
cd /tmp/test_antspy N4BiasFieldCorrection -i in.nii -o n4_in.nii -v 1 DenoiseImage -i n4_in.nii -o dn_n4_in.nii -v 1 -n Rician
From Python :
Expected behavior
Since I built from source ANTs and ANTsPy, I would expect roughly the same computation.
x1.5
N4BiasFieldCorrection
is unexpected but ok, however x8 forDenoiseImage
is very weird.ANTsPy installation (please complete the following information):
python -m pip install .
]Additional context
When running both tests, I can see in
htop
that all 16 CPUs are running at 100%, with both Terminal CLI and Python wrappers. So it's not an obvious multi-threading problem.The text was updated successfully, but these errors were encountered: