-
Notifications
You must be signed in to change notification settings - Fork 12
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
Attempt at Uniformity task optimization. #464
Comments
New ChangesRemoved the two stages performing the ROI look up using nested loops (O[n2]). In exchange, we now have a large ROI and a small ROI pair of steps. My code now looks for the min and max pixels within the large ROI using masked arrays. Then, generate a pair of small ROIs centered around these pixels using masked arrays. It then computes the mean value in those small ROIs. The original approach spent too much time scanning the region of interest trying to determine where to place the small ROIs. Something that I hope to bring in my changes is a better approximation of what is expected out of users per the guideline, which should make results easier to validate and reason about. New ProfileValidating ResultsReference (ACR Large Phantom)ReportPerformance ImprovementMy code takes this task from 12.5 seconds to 1.70 seconds of execution. This is 7 times faster and makes this task match the performance of the other tasks. This combined with parallelization should guarantee that all ACR tasks can be achieved within a couple of seconds, thus making it possible to minimize the time spent by technologists getting these results ready. |
Now, I can start yielding some of the performance back in exchange for correctness. Per ACR guidelines, we really want the mean intensity value. My next step is to generate a 2D kernel that is as close to circular as possible (covers as much of the area an ROI made by a human would) and compute a mean large roi from which we can identify a min and max point using np.argmin and np.argmax. Those points should be reflecting accurate 1cm2 means and thus be true local minima/maxima in the pixel space. A convolution here might be optimal and maintain performance around < 3 s of execution time. |
Ok, so I implemented the smoothing step and recalculation based on it. Reference ACR ExampleReference DatasetFor this report, I focused on the GE Medium phantom dataset available in the project since it adds a notch at the top of the large ROI and thus impose extra challenges in image processing (can become a local minima region that can bias results towards a smaller uniformity). BeforeMain Logic for Small ROIsReportBelow is the results from running the original implementation of the hazen's uniformity task. BenchmarkAfterApproachThe new approach is to take the original image and convolve it with a circular kernel with the exact dimensions as the small ROI. Main Logic for Small ROIsKernelThe kernel is generated based on the in-plane voxel/pixel resolution and the small ROI radius Intermediate VisualizationReportBenchmarkItems Addressed
SummaryI have a solution to the Uniformity task performance issues. It revealed more critical issues that put into question the validity of results. I took a convolution approach to identify the mean min and max intensity regions for the calculation of PIU. My current solution appears to lower the execution time from 122s to 2.53s for the GE medium phantom. That is a 48x improvement in this case. Mileage may vary since I have seen the original implementation run 10x faster against acquisitions with half the matrix size. My approach seems to keep execution under the target 3s. More importantly, I believe that the new results are much closer to the true homogeneity of the acquisition, which is very homogeneous in this case. A validation report vs 500 phantom acquisitions is in my todo. |
There was a mistake in my logic. Addressing the mistake in mean() calculation yielded results that were comparable to the original implementation (although there was still some differences in results). It looks more stable now after running some tests. We still keep our speed and other bug fixes wins, but now it puts into question the homogeneity of my in-house data. More validation needs to happen. |
I am ready to push changes to this project. |
I did further cleaning of my code and this is the final write up on my changes. Reference ACR ExampleReference DatasetFor this report, I focused on the GE Medium phantom dataset available in the project since it adds a notch at the top of the large ROI and thus impose extra challenges in image processing (can become a local minima region that can bias results towards a smaller uniformity). BeforeMain Logic for Small ROIsReportBelow is the results from running the original implementation of the hazen's uniformity task. BenchmarkAfterApproachThe new approach is to take the original image and convolve it with a circular kernel with the exact dimensions as the small ROI. Main Logic for Small ROIsKernelThe kernel is generated based on the in-plane voxel/pixel resolution and the small ROI radius. Intermediate VisualizationReportBenchmarkItems Addressed
SummaryI have a solution to the Uniformity task performance issues. It revealed more critical issues that put into question the validity of results. I took a convolution approach to identify the mean min and max intensity regions for the calculation of PIU. My current solution appears to lower the execution time from 122s to 2.53s for the GE medium phantom. That is a 48x improvement in this case. Mileage may vary since I have seen the original implementation run 10x faster against acquisitions with half the matrix size. My approach seems to keep execution under the target 3s. More importantly, the main adjustment to the accuracy of the uniformity calculation comes from better center detection of the large ROI (See #452 ) A validation report vs 500 phantom acquisitions is in my todo. |
Is your feature request related to a problem? Please describe.
Out of all of the tasks, the Uniformity task appears to run the slowest. It feels significant as an observer.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect each task to take no longer than the average time of the other tasks. 2-3 seconds are passable. I have done complex image processing (registration, gaussian filtering, subtractions, etc...) on much bigger data than the single phantom slices these tasks typically require, so I have a feeling there might be areas for improvement here.
Screenshots
For comparison, here is the profile for the acr_geometric_accuracy task, which seems to consume about 3 seconds with a third of the time spent on saving the images.
Desktop (please complete the following information):
Additional context
I am going to profile and attempt to optimize the code if possible.
My idea is to make sure these tasks perform in relatively comparable ways.
The text was updated successfully, but these errors were encountered: