-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
PERF: accelerating antsAtroposSegmentationImageFilter.hxx function GetPosteriorProbabilityImage using ITK ParallelizeImageRegion #1462
Conversation
…riorProbabilityImage using ITK ParallelizeImageRegion
This is great. However, I would prefer to see a few more subjects processed where the output doesn't change before merging. |
@ntustison Sure, good idea. I have tested 5 more images with the following:
Output:
To me the changes seems quite solid, maybe someone else should rerun my experiments or do further tests to if they get similar results. |
Can we check it remains consistent with prior probability images? That's probably the most common use case. |
Yeah, that's a good idea. I'll try running a few subjects through the antsAtroposN4.sh pipeline. |
I've been trying to run this in the background but am having difficulty getting identical results. I think I traced it to |
@ntustison are you running single threaded? |
Yep, single-threaded. |
OK, then maybe we need additional changes, I'll take look. Meanwhile, I'll build this PR and run some tests using AAN4 directly |
That would be great. I started out with antsAtroposN4 which is what led me to looking internally at the components. |
Okay, @cookpa , thanks for the reminder about setting the ANTS_RANDOM_SEED. It appears that I'm now getting the identical results I was expecting. I'll check after a couple more subjects and then we can merge this. Thanks again @br-cpvc . Regarding the randomization in antsBrainExtraction---do you want me to work on that or were you planning on addressing it? |
I also get reproducible results, and with two threads, the execution time is reduced by about 20%. |
I replied in the issue, I'll make the change to make antsBrainExtraction.sh use a consistent random seed throughout if "-u 0" is passed. I think that's pretty backwards compatible because most users wouldn't call "-u 0" unless they want reproducible results |
Great. I'm happy to see that the changes has been merged :) Thank you all for the collaboration, it has been a pleasure working together on this change, and I'm happy to be able to contribute a little bit back to the project. Thank you all for the excellent work you do, and thank you very much for continuously putting your effort into this great project through out all these years. |
This is a reimplementation of the optimizations initially proposed in PR #1452
With the help of the ITK discourse forum in post https://discourse.itk.org/t/how-to-use-itk-multi-threading-primitives-to-do-parallel-execution-of-loop-iteration/5531/ I have managed to rework my previous proof of concept implementation into a generic solution that uses the ITK multi-threading primitive ParallelizeImageRegion.
During my limited testing (using only two image inputs) I have seen the execution time being reduced to around 60-70% of the original implementations execution time. The execution times for the two tested image inputs: image 1 was reduced from 96 seconds to 60 seconds (see below) and image 2 from 272 seconds to 168 seconds.
I have validated the implementation using the following:
Tests where done on the cpu:
Preparations:
using a compiled version of ANTs before the code changes:
using a compiled version of ANTs after the code changes:
The md5sums confirms that the new implementation produces the exact same output as the before the changes.