Skip to content

Conversation

@jfowkes
Copy link
Collaborator

@jfowkes jfowkes commented Mar 11, 2025

Refractive Index Maximum Likelihood (i.e. the object is the refractive index). Just the CPU version for now.

@kahntm hopefully of interest to you. I don't have a good example to test this out on.

Will need to add support for the wavefield preconditioner once that goes in (but this is trivial).

@jfowkes jfowkes added the enhancement enhances package beyond current capability label Mar 11, 2025
@jfowkes jfowkes self-assigned this Mar 11, 2025
@kahntm
Copy link
Contributor

kahntm commented Mar 22, 2025

Hi. Thanks for implementing this. I will have a look at it soon.
As for "good" data to test it with: Any dataset should do. But some where the phase wraps at least once or twice would be the best.

@jfowkes
Copy link
Collaborator Author

jfowkes commented May 1, 2025

I have now added the wavefield preconditioner to refractive index ML (option wavefield_precond = True).

@jfowkes jfowkes added Hackathon2025 and removed enhancement enhances package beyond current capability labels Sep 18, 2025
@jfowkes
Copy link
Collaborator Author

jfowkes commented Sep 18, 2025

Here is a comparison of ML with the smoothing preconditioner:
ML
and refractive-ML with the smoothing preconditioner:
ML_ref
Seems to work okay on this easy dataset.

@jcesardasilva
Copy link
Contributor

jcesardasilva commented Sep 18, 2025

Thank you for sharing this with us. It seems to work, but I am a bit concerned about the gray values of the amplitude. I assume that both calculations were done on the same dataset, am I right? However, in the results obtained with "ML with the smoothing preconditioner," the range of gray values for the amplitude goes from 0.5e-10 up to 0.79e-10 (a delta of 2.9e-11). In contrast, the results from "refractive-ML with the smoothing preconditioner" show a range from 0 to 2.8 (a delta of 2.8). Additionally, the contrast seems inverted for the amplitude images: what is darker in one appears lighter in the other, and vice versa.

Could a minus sign be floating somewhere where it's not supposed to be?

Additionally, the probes have completely different power values, with one P = 8.5e8 and the other having P =4.8e8, which is almost a factor of 2 different. This obviously also affects the range of the color scale. This may indicate that something not so correct occurred, as even if one is now retrieving the refractive index for the object rather than the exponential of the phase, the probe should have remained very similar.

Could one force the amplitude to be between 0 and 1 (or even 1.2 to allow some flexibility) to check if there are improvements?

@jcesardasilva
Copy link
Contributor

Is this also implemented for the near-field ptycho? If so, is it possible to try it in the dataset I send you @jfowkes? The probe retrieval may complicate things a bit, though.

@jfowkes
Copy link
Collaborator Author

jfowkes commented Sep 19, 2025

@jcesardasilva yeah sorry I’m being lazy with the plotting (as ptypy isn’t setup for plotting refractive indexes) so for the refractive ML it’s actually plotting the amplitude and phase of the refractive index rather than the real and imaginary part, I’ll see if I can hack the plot script to fix this. It should work with nearfield data out of the box so I will try with your dataset today.

@daurer
Copy link
Contributor

daurer commented Oct 17, 2025

As discussed at the developer meeting, we should do a proper comparison of the results (not using ptypy.utils) so that we can discuss whether the refractive ML code makes sense. @jfowkes do you still have the scripts and could do this?

@jfowkes
Copy link
Collaborator Author

jfowkes commented Oct 18, 2025

Yes I still have the runscripts, happy to do the comparison properly. I should add that it does not work for the second example as the gradients explode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants