elastix icon indicating copy to clipboard operation
elastix copied to clipboard

OpenCLResampler gives wrong result

Open mfroeling opened this issue 5 years ago • 3 comments

I have compiled elastix 5.0 with OpenCL (win64, OpenCL 2.0, VS 2017, ITK 5.0.1) and everything seems to work fine.

However when I was testing GPU vs CPU I noticed that the GPU result was wrong but the CPU were not. I have checked all the logging and elastix seems to do exactly the same for the CPU and GPU and the transform parameters and all other outputs are identical. However, the results were definitely not.

ex1 ex2

log

elastix-OpenCL.log elastix.log

EDIT:

while using the OpenCLResampler but setting (OpenCLResamplerUseOpenCL "false") the result is correct again.

openCL

EDIT 2:

After some further testing the error is only happening when using the "AffineDTITransform" for all other transforms the result is as expected

mfroeling avatar Jan 10 '20 14:01 mfroeling

Hi @mfroeling, thanks for taking the time to investigate this issue! We applied some recent changes that fix bugs related to the OpenCL resampler, please see #741. I know that it has been a while since you raised the issue, however, can you test if the error persists using the latest main branch?

ntatsisk avatar Oct 12 '22 11:10 ntatsisk

@ntatsisk i will compile and test as soon i have some time and let you know the outcome. Thanks for the update!

mfroeling avatar Oct 13 '22 07:10 mfroeling

@ntatsisk i managed to reproduce the test. (win64, OpenCL 3.0.1, VS 2019, ITK 5.3) your fix did not solve my problem.

CPU AffineTransform vs AffineDTITransform CPU aff vs affDTI

GPU AffineTransform vs AffineDTITransform GPU aff vs affDTI

CPU vs GPU AffineDTITransform CPU vs GPU

What i did notice now looking at the outputs is that every method gives the same result. However the AffineDTITransform the MatrixTranslation is the matrix needed for the correct translation which for the AffineTransform is stored in the TransformParameters.

So my guess now is that the OpenCLResampler uses the TransformParameters always but for the AffineDTITransform it should rather use the MatrixTranslation.

Best Martijn

mfroeling avatar Oct 13 '22 09:10 mfroeling