ptycho / ptypy

Ptypy - main repository
Other
36 stars 16 forks source link

Border artefacts in the retrieved phases images with CUDA version and different phase air offsets. #283

Closed jcesardasilva closed 3 years ago

jcesardasilva commented 3 years ago

Dear colleagues, I am having a very weird behavior in the calculations from Near-Field ptycho datasets, because, as you see below, the phases in the air region are not consistent with each other and take different offsets, which is a struggle to remove the phase ramps. The ML is not doing much work since the metrics oscillate a lot.

Capture d’écran 2021-01-21 à 09 45 08

I know it is a complicated version and I have to remove the vortices in the way we always did since I was at cSAXS in 2013. Here I have only 3-4 phase wrap jumps, but at cSAXS I used to have 10-12 phase wrap jumps. But for this sample, I get this weird behavior.
I tried with the CPU version to see whether there was a difference, but the overall image behavior is similar, which may lead us to think the problem might be in the experiments, right? But I did see some differences in the border of the images between the CPU and GPU versions, which are clearer when we have many phase wraps as for this sample. Then, most of the new vortices will appear again there and I suspect this may have implications in the convergence of the phase retrieval. I suppose this is related to the different ways padding or the Fourier shifts are implemented in CPU and GPU, right? See below, please:

This is the version from CPU:

Capture d’écran 2021-01-21 à 09 46 47

This is the version from GPU:

Capture d’écran 2021-01-21 à 09 45 46

It there any way to attenuate these problem with Ptypy? Or there is a way to have the border behavior of the CPU version into the GPU version?

bjoernenders commented 3 years ago

Hi Julio, sorry for replying late. CPU and GPU do not operate at the same level of precision in their calculations (double vs single), so they will diverge in areas of instability like the edges of a the object frame. I don't think there is a remedy at this point besides forcing air on both sides to take on the same value and ignoring the edge effects. I wouldn't trust the values there anyway since there is less overlap. I apologize that I can't give better advice, I remember these kind of measurements being particularly difficult for ptychography. Best, Bjoern