Repository navigation
fix(models): scale z padding by the axial upsampling factor in 3D transfer functions - #608
Open
arashmparsa wants to merge 2 commits into
Open
arashmparsa wants to merge 2 commits into
arashmparsa wants to merge 2 commits into
Conversation
…nsfer functions calculate_transfer_function in phase_thick_3d and isotropic_fluorescent_thick_3d computes the transfer function on a grid upsampled to axial Nyquist (z_factor) and then crops it in Fourier space to zyx_shape[0] + 2 * z_padding slices. The padding was passed to the upsampled grid unscaled, so that grid spanned (Z + 2 * z_padding / z_factor) * z_pixel_size instead of (Z + 2 * z_padding) * z_pixel_size, and the cropped transfer function was sampled on the wrong axial frequencies whenever z_padding > 0 and z_pixel_size is coarser than axial Nyquist. Pass z_padding * z_factor to the upsampled grid. Add tests that the axial response does not change with z padding when z is upsampled.
…transfer_function isotropic_fluorescent_thick_3d.apply_transfer_function (also used by phase_thick_3d.apply_transfer_function) handled z_padding > 0 by slicing optical_transfer_function[z_padding:-z_padding]. The OTF is in unshifted FFT order, so that slice removes the DC term and the lowest axial frequencies: the simulated stack sums to zero and keeps only high-frequency content. Zero-pad the object to the OTF's padded grid, apply the OTF, and crop the simulated data back to the object's shape.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
waveorder's
phase_thick_3dandisotropic_fluorescent_thick_3dbuild their transfer function on a z grid upsampled to axial Nyquist byz_factor, then crop it toZ + 2 * z_paddingslices. The padding reached the upsampled grid unscaled, so withz_factor = 2the transfer function was sampled at the wrong axial frequencies. Padding should not change the PSF, but on main it does:The change passes
z_padding * z_factorto the upsampled grid, one line per model; withz_factor = 1nothing changes. A second commit makesapply_transfer_functionzero-pad the object instead of slicing the unshifted OTF, which dropped the DC term so simulated stacks summed to zero. The new tests fail on main and pass here, andpytest tests/modelspasses. Results withz_padding > 0on coarse z stacks will change. Heads-up: draft #597 keeps the old padding inSampling.upsampled().Related issue
Summary
Testing
Checklist