Skip to content

Commit

Permalink
3d phase wrap safety
Browse files Browse the repository at this point in the history
  • Loading branch information
talonchandler committed Sep 10, 2024
1 parent 2e155fe commit 783b916
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion waveorder/models/phase_thick_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
from torch import Tensor

from waveorder import optics, util
from waveorder import optics, sampling, util
from waveorder.models import isotropic_fluorescent_thick_3d


Expand Down Expand Up @@ -40,6 +40,59 @@ def calculate_transfer_function(
numerical_aperture_illumination,
numerical_aperture_detection,
invert_phase_contrast=False,
):
transverse_nyquist = sampling.transverse_nyquist(
wavelength_illumination,
numerical_aperture_illumination,
numerical_aperture_detection,
)
axial_nyquist = sampling.axial_nyquist(
wavelength_illumination,
numerical_aperture_detection,
index_of_refraction_media,
)

yx_factor = int(np.ceil(yx_pixel_size / transverse_nyquist))
z_factor = int(np.ceil(z_pixel_size / axial_nyquist))

real_potential_transfer_function, imag_potential_transfer_function = (
_calculate_wrap_unsafe_transfer_function(
(
zyx_shape[0] * z_factor,
zyx_shape[1] * yx_factor,
zyx_shape[2] * yx_factor,
),
yx_pixel_size / yx_factor,
z_pixel_size / z_factor,
wavelength_illumination,
z_padding,
index_of_refraction_media,
numerical_aperture_illumination,
numerical_aperture_detection,
invert_phase_contrast=invert_phase_contrast,
)
)

return (
sampling.nd_fourier_central_cuboid(
real_potential_transfer_function, zyx_shape
),
sampling.nd_fourier_central_cuboid(
imag_potential_transfer_function, zyx_shape
),
)


def _calculate_wrap_unsafe_transfer_function(
zyx_shape,
yx_pixel_size,
z_pixel_size,
wavelength_illumination,
z_padding,
index_of_refraction_media,
numerical_aperture_illumination,
numerical_aperture_detection,
invert_phase_contrast=False,
):
radial_frequencies = util.generate_radial_frequencies(
zyx_shape[1:], yx_pixel_size
Expand Down

0 comments on commit 783b916

Please sign in to comment.