Repository navigation
Conversation
This branch has not been deployed
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.
Hi, after a long time trying to use DeepTrack2 for fitting real holography images I found there was a bug in the scattered field. I checked against another python package called HoloPy and with this PR fixes they agree.
TL;DR: the Mie coefficients and S1/S2 are fine (they match HoloPy to 1e-8). The bugs are in the step that turns S1/S2 into a field on the image plane.
Bugs
-1j / (k R). The textbook formula (Bohren & Huffman eq. 4.75) isexp(ikR) / (-ikR) * S, and1/(-i) = +i.2π·Δn·d/λgives ~1.4 rad.-2π / ((k dx)² cos θ)S(θ)is per unit solid angle, but the FFT grid is flat in (kx, ky).(k dx)²term, the scattered strength depends on the simulation pixel size.1/cos θ, high angles are under-weighted. Fitting a field generated with HoloPy of a 228 nm sphere gives 190 nm with a good residual because it tries to compensate the missing light at high angles with a smaller bead.K dz sqrt(1 - (NA/n)² ρ²)at ρ = 0 isK dz, so every propagation step multiplies the plane wave byexp(i K dz).z_max, leavingexp(-i K z_min). Its phase depends on where the volume sits, but MieSphere fields are added at the focus without it.dt.Spherefar away in the corner changes a MieSphere's image by up to 5.4, on an image ranging 0.56–1.33 (633 nm)Darkfield(|field - 1|²) has a background of up to 2.0 instead of 0.Fixes
scatterers.py: flipped the sign in geometric mode and added the missing factor in hybrid.test_scatterers.py:+i k0 Δn V.optics.py:sqrt(...) - 1in_pupil_numpyand_pupil_torch, propagate relative to the illumination, as the Mie fields already are.test_optics.py::test_Brightfield_illumination_phase_independent_of_volume(numpy + torch).test_dlcc.py::test_3_B: I regenerated the gold values, because the stored numbers were with the old sign. The old values are roughly the new ones mirrored around 1 (0.85 ↔ 1.17), which is what the sign flip does. Please double-check you're OK with this one.With the fix, hybrid mode matches HoloPy:
Heads up
phase_shift_correctionmultiplies byexp(ikz + iπ/2). Was that tuned on top of the old sign? With this fix, the iSCAT contrast shifts by π. I didn't touch it because I don't have an iSCAT reference to check against.