Skip to content

Commit

Permalink
wrap-safe vector transfer function
Browse files Browse the repository at this point in the history
  • Loading branch information
talonchandler committed Sep 27, 2024
1 parent 974a700 commit 995c90d
Showing 1 changed file with 57 additions and 2 deletions.
59 changes: 57 additions & 2 deletions waveorder/models/inplane_oriented_thick_pol3d_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np

from torch import Tensor
from waveorder import optics, stokes, util
from waveorder import optics, sampling, stokes, util
from waveorder.visuals.napari_visuals import add_transfer_function_to_viewer


Expand Down Expand Up @@ -37,6 +37,61 @@ 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))

sfZYX_transfer_function, intensity_to_stokes_matrix = (
_calculate_wrap_unsafe_transfer_function(
swing,
scheme,
(
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,
)
)
sfzyx_out_shape = (3, 3, zyx_shape[0] + 2 * z_padding,) + zyx_shape[1:]
return (
sampling.nd_fourier_central_cuboid(
sfZYX_transfer_function, sfzyx_out_shape
),
intensity_to_stokes_matrix,
)


def _calculate_wrap_unsafe_transfer_function(
swing,
scheme,
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,
):
intensity_to_stokes_matrix = stokes.calculate_intensity_to_stokes_matrix(
swing, scheme=scheme
Expand Down Expand Up @@ -108,7 +163,6 @@ def calculate_transfer_function(
z_position_list,
)


G = optics.generate_defocus_greens_tensor(
x_frequencies,
y_frequencies,
Expand Down Expand Up @@ -181,6 +235,7 @@ def visualize_transfer_function(viewer, sfZYX_transfer_function, zyx_scale):
layer_name="Transfer Function",
)


def apply_transfer_function(
fzyx_object,
sfZYX_transfer_function,
Expand Down

0 comments on commit 995c90d

Please sign in to comment.