Skip to content
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

Phase contrast quality of life improvements #674

Merged
merged 11 commits into from
Aug 20, 2024
Merged

Phase contrast quality of life improvements #674

merged 11 commits into from
Aug 20, 2024

Conversation

gvarnavi
Copy link
Member

Various quality of life improvements for the phase module. Namely:

  • Pixel dimensions invariant BO metrics
  • Optional in-place preprocessing of datacube
  • max_batch_size option in parallax preprocess and reconstruct (only useful for shifting cross-correlated VBFs)
  • aligned_bf_image_guess option in parallax preprocess to initialize cross-correlation with
  • new guess_common_aberrations function which accepts microscope geometry parameters (rotation/transpose), as-well as common aberrations (defocus, stig, coma, spherical), and computes the analytical BF shifts -- using them to compute the aligned (and optionally upsampled) BF image
    • note this returns a static figure, but is easy to make into a widget inside a jupyter notebook
    import ipywidgets
    
    def widget_wrapper(rotation_angle_deg, transpose, defocus, upsampling_factor):
        """ wrapper to only pass interactive sliders of interest """
        return parallax.guess_common_aberrations(
            rotation_angle_deg = rotation_angle_deg,
            transpose = transpose,
            defocus = defocus,
            kde_upsample_factor = upsampling_factor,
        )
        
    ipywidgets.interact(
        widget_wrapper,
        rotation_angle_deg = -15,
        transpose = False,
        defocus = 1.5e4,
        upsampling_factor = 1,
    );

Copy link
Member

@sezelt sezelt left a comment

Choose a reason for hiding this comment

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

For the in-place datacube modification, I think we may want to somehow prevent someone from accidentally preprocessing the same dataset more than once. Perhaps there is a clean way to set some flag on the datacube or add an entry to its metadata to indicate that it has already been modified, and then warn or error if you try to run it again.

I like the blind parallax a lot. It would be nice if the plotting was behind a flag, so that I could use this as the basis of a parallax feature in the GUI. Also, can you really handle transpose just by changing the direction of the rotation? Maybe it's happening at a different stage than I am used to but that just seemed fishy.

@gvarnavi
Copy link
Member Author

gvarnavi commented Aug 12, 2024

For the in-place datacube modification, I think we may want to somehow prevent someone from accidentally preprocessing the same dataset more than once. Perhaps there is a clean way to set some flag on the datacube or add an entry to its metadata to indicate that it has already been modified, and then warn or error if you try to run it again.

To be honest I'm not a huge fan of this feature, but a user working on very large datasets asked for it and figured I'd oblige. I think if the user is explicitly setting in_place_datacube_modification = True it should be on the user to make sure they only do it once? e.g. load the data in the same cell or something.

I like the blind parallax a lot. It would be nice if the plotting was behind a flag, so that I could use this as the basis of a parallax feature in the GUI.

Sure, I'll add a flag for the plotting. It would be amazing to add this functionality to the GUI!

Also, can you really handle transpose just by changing the direction of the rotation? Maybe it's happening at a different stage than I am used to but that just seemed fishy.

It suffices to perform these two operations, yes:

  1. passively rotate the Fourier-coordinate system by negative theta
        if transpose:
            rotation_angle_deg *= -1
  1. flip the shifts after they're computed:
        if transpose:
            shifts_ang = xp.flip(shifts_ang, axis=1)

@sezelt
Copy link
Member

sezelt commented Aug 12, 2024

I see, I just missed the second step of flipping.

@smribet smribet merged commit 2d8ce83 into dev Aug 20, 2024
9 checks passed
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.

3 participants