Skip to content

ptycho: enhance show_scan_positions for probe overlap/size estimation and metadata#190

Merged
arthurmccray merged 3 commits intoelectronmicroscopy:devfrom
bobleesj:ptycho-scan-position-plot
Mar 11, 2026
Merged

ptycho: enhance show_scan_positions for probe overlap/size estimation and metadata#190
arthurmccray merged 3 commits intoelectronmicroscopy:devfrom
bobleesj:ptycho-scan-position-plot

Conversation

@bobleesj
Copy link
Collaborator

What this PR does

No physics is changed for probe size estimation.

User wants to get an approximation for probe overlap, size, etc. The existing implementation works but with a minor fix as mentioned in the in-line comment:

Here is the plot and output:

ptycho_pix.show_scan_positions(num_probes=20)
Screenshot 2026-03-09 at 6 25 08 PM

Yes, probes are tiny.

API renders:

Screenshot 2026-03-09 at 6 22 14 PM

What should the reviewer(s) do

This was brought up while going through the ptycho notebook w/ @arthurmccray. I will probably the only user for now but since no physics is modified, it can be merged but if you more ideas, please share.

Copy link
Collaborator Author

@bobleesj bobleesj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arthurmccray ready for review

diffraction_limit_A = 0.61 * wavelength / conv_angle_rad
defocus_blur_A = abs(defocus) * conv_angle_rad
probe_radius_A = diffraction_limit_A + defocus_blur_A
probe_radius_px = probe_radius_A / self.sampling[0]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the ptycho sampling is different from the original sampling.

For printing, I used the original sampling

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ptycho.sampling is the realspace sampling of the reconstructed object, i.e. it's dependent on the maximum scattering angle of the diffraction patterns. We generate this image with the scan positions using the _get_probe_overlap method, which uses the same patches backend as is in the forward model, so that is the correct sampling to use. Just wanted to clarify :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this clafirication! I will take a look!

Copy link
Collaborator Author

@bobleesj bobleesj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more comments on unit code convention and metadata

@bobleesj bobleesj requested a review from arthurmccray March 10, 2026 16:06
Copy link
Collaborator

@arthurmccray arthurmccray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I would make the super minor change of specifying the object FOV in the printed string, but otherwise ready to merge.

diffraction_limit_A = 0.61 * wavelength / conv_angle_rad
defocus_blur_A = abs(defocus) * conv_angle_rad
probe_radius_A = diffraction_limit_A + defocus_blur_A
probe_radius_px = probe_radius_A / self.sampling[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ptycho.sampling is the realspace sampling of the reconstructed object, i.e. it's dependent on the maximum scattering angle of the diffraction patterns. We generate this image with the scan positions using the _get_probe_overlap method, which uses the same patches backend as is in the forward model, so that is the correct sampling to use. Just wanted to clarify :)

Copy link
Collaborator Author

@bobleesj bobleesj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arthurmccray Thanks Arthur for your feedback on adding "FOV" text. This has been fixed. Ready for review and merge.

diffraction_limit_A = 0.61 * wavelength / conv_angle_rad
defocus_blur_A = abs(defocus) * conv_angle_rad
probe_radius_A = diffraction_limit_A + defocus_blur_A
probe_radius_px = probe_radius_A / self.sampling[0]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this clafirication! I will take a look!

@arthurmccray arthurmccray merged commit 8376164 into electronmicroscopy:dev Mar 11, 2026
4 checks passed
@bobleesj bobleesj deleted the ptycho-scan-position-plot branch March 11, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants