From af29362ebe4668e8134ec9f217ad94173b750f61 Mon Sep 17 00:00:00 2001 From: Benjamin Midtvedt Date: Fri, 26 Aug 2022 14:30:17 +0200 Subject: [PATCH 1/2] Fix phase correction at focus and offset calculation --- deeptrack/scatterers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deeptrack/scatterers.py b/deeptrack/scatterers.py index dd393585a..f011f4582 100644 --- a/deeptrack/scatterers.py +++ b/deeptrack/scatterers.py @@ -592,7 +592,7 @@ def _process_properties(self, properties): ) / 2 * min(properties["voxel_size"][:2]) - / np.sin(properties["collection_angle"]) + / np.tan(properties["collection_angle"]) ) return properties @@ -611,6 +611,7 @@ def get( input_polarization, output_polarization, coefficients, + z, **kwargs, ): @@ -686,7 +687,7 @@ def get( (ct > ct_max) * 1j / (k * R3) - * np.exp(1j * k * (R3 - offset_z)) + * np.exp(1j * k * R3) * (S2 * S2_coef + S1 * S1_coef) ) From d055d1adbe422207a9c8ed8ed849450b16a94172 Mon Sep 17 00:00:00 2001 From: Benjamin Midtvedt Date: Fri, 26 Aug 2022 18:13:30 +0200 Subject: [PATCH 2/2] Fix phase correction in propagation --- deeptrack/optics.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/deeptrack/optics.py b/deeptrack/optics.py index 189bd7e73..21ced55a5 100644 --- a/deeptrack/optics.py +++ b/deeptrack/optics.py @@ -706,7 +706,15 @@ def get(self, illuminated_volume, limits, fields, **kwargs): **kwargs, )[0] - propagation_matrix = propagation_matrix + propagation_matrix = propagation_matrix * np.exp( + 1j + * voxel_size[-1] + * 2 + * np.pi + / kwargs["wavelength"] + * kwargs["refractive_index_medium"] + * (z - fz) + ) pf = np.fft.fft2(fields[idx][:, :, 0]) * np.fft.fftshift(propagation_matrix) light_in += pf