From e1ee2fb65a601dea275b3e7007393578e7015d04 Mon Sep 17 00:00:00 2001 From: Julie Marie Date: Fri, 13 Sep 2024 20:57:05 +0200 Subject: [PATCH 1/5] add virtual detector ptychography for single-slice --- py4DSTEM/process/phase/ptychographic_methods.py | 17 ++++++++++++++++- .../process/phase/singleslice_ptychography.py | 8 ++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/py4DSTEM/process/phase/ptychographic_methods.py b/py4DSTEM/process/phase/ptychographic_methods.py index 2e47a5e23..d46762345 100644 --- a/py4DSTEM/process/phase/ptychographic_methods.py +++ b/py4DSTEM/process/phase/ptychographic_methods.py @@ -1573,7 +1573,9 @@ def cross_correlate_amplitudes_to_probe_aperture( return self - def _gradient_descent_fourier_projection(self, amplitudes, overlap, fourier_mask): + def _gradient_descent_fourier_projection( + self, amplitudes, overlap, fourier_mask, virtual_detector_masks + ): """ Ptychographic fourier projection method for GD method. @@ -1586,6 +1588,7 @@ def _gradient_descent_fourier_projection(self, amplitudes, overlap, fourier_mask fourier_mask: np.ndarray Mask to apply at the detector-plane for zeroing-out unreliable gradients Useful when detector has artifacts such as dead-pixels + virtual_detector_masks: Returns -------- @@ -1609,6 +1612,15 @@ def _gradient_descent_fourier_projection(self, amplitudes, overlap, fourier_mask xp=xp, ) + if virtual_detector_masks is not None: + masked_values = xp.sum( + fourier_overlap[:, None, :, :] * virtual_detector_masks[None, :, :, :], + axis=(-1, -2), + ).transpose() + fourier_overlap = xp.zeros_like(fourier_overlap) + for mask, value in zip(virtual_detector_masks, masked_values): + fourier_overlap[:, mask] = value[:, None] / xp.sum(mask) + if fourier_mask is not None: fourier_overlap *= fourier_mask @@ -1743,6 +1755,7 @@ def _forward( amplitudes, exit_waves, fourier_mask, + virtual_detector_masks, use_projection_scheme, projection_a, projection_b, @@ -1765,6 +1778,7 @@ def _forward( fourier_mask: np.ndarray Mask to apply at the detector-plane for zeroing-out unreliable gradients Useful when detector has artifacts such as dead-pixels + virtual_detector_masks: add docstring use_projection_scheme: bool, If True, use generalized projection update projection_a: float @@ -1811,6 +1825,7 @@ def _forward( amplitudes, overlap, fourier_mask, + virtual_detector_masks, ) return shifted_probes, object_patches, overlap, exit_waves, error diff --git a/py4DSTEM/process/phase/singleslice_ptychography.py b/py4DSTEM/process/phase/singleslice_ptychography.py index d391dd293..f895776a0 100644 --- a/py4DSTEM/process/phase/singleslice_ptychography.py +++ b/py4DSTEM/process/phase/singleslice_ptychography.py @@ -649,6 +649,7 @@ def reconstruct( shrinkage_rad: float = 0.0, fix_potential_baseline: bool = True, detector_fourier_mask: np.ndarray = None, + virtual_detector_masks: Sequence[np.ndarray] = None, store_iterations: bool = False, progress_bar: bool = True, reset: bool = None, @@ -758,6 +759,9 @@ def reconstruct( detector_fourier_mask: np.ndarray Corner-centered mask to multiply the detector-plane gradients with (a value of zero supresses those pixels). Useful when detector has artifacts such as dead-pixels. Usually binary. + virtual_detector_masks: ndarray, optional + List of corner-centered boolean masks to bin during forward model, + to allow comparison with arbitrary segmented detector datasets. store_iterations: bool, optional If True, reconstructed objects and probes are stored at each iteration progress_bar: bool, optional @@ -843,6 +847,9 @@ def reconstruct( if detector_fourier_mask is not None: detector_fourier_mask = xp.asarray(detector_fourier_mask) + if virtual_detector_masks is not None: + virtual_detector_masks = xp.asarray(virtual_detector_masks) + # main loop for a0 in tqdmnd( num_iter, @@ -890,6 +897,7 @@ def reconstruct( amplitudes_device, self._exit_waves, detector_fourier_mask, + virtual_detector_masks, use_projection_scheme, projection_a, projection_b, From c21e78d78c1d990522f45469c8fde72630d75db5 Mon Sep 17 00:00:00 2001 From: Julie Marie Date: Fri, 13 Sep 2024 21:24:43 +0200 Subject: [PATCH 2/5] add docstrings --- py4DSTEM/process/phase/ptychographic_methods.py | 8 ++++++-- py4DSTEM/process/phase/singleslice_ptychography.py | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/py4DSTEM/process/phase/ptychographic_methods.py b/py4DSTEM/process/phase/ptychographic_methods.py index d46762345..e0c74722f 100644 --- a/py4DSTEM/process/phase/ptychographic_methods.py +++ b/py4DSTEM/process/phase/ptychographic_methods.py @@ -1588,7 +1588,9 @@ def _gradient_descent_fourier_projection( fourier_mask: np.ndarray Mask to apply at the detector-plane for zeroing-out unreliable gradients Useful when detector has artifacts such as dead-pixels - virtual_detector_masks: + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. Returns -------- @@ -1778,7 +1780,9 @@ def _forward( fourier_mask: np.ndarray Mask to apply at the detector-plane for zeroing-out unreliable gradients Useful when detector has artifacts such as dead-pixels - virtual_detector_masks: add docstring + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. use_projection_scheme: bool, If True, use generalized projection update projection_a: float diff --git a/py4DSTEM/process/phase/singleslice_ptychography.py b/py4DSTEM/process/phase/singleslice_ptychography.py index f895776a0..6e46138f9 100644 --- a/py4DSTEM/process/phase/singleslice_ptychography.py +++ b/py4DSTEM/process/phase/singleslice_ptychography.py @@ -759,9 +759,9 @@ def reconstruct( detector_fourier_mask: np.ndarray Corner-centered mask to multiply the detector-plane gradients with (a value of zero supresses those pixels). Useful when detector has artifacts such as dead-pixels. Usually binary. - virtual_detector_masks: ndarray, optional - List of corner-centered boolean masks to bin during forward model, - to allow comparison with arbitrary segmented detector datasets. + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. store_iterations: bool, optional If True, reconstructed objects and probes are stored at each iteration progress_bar: bool, optional From 8a08b5fa1f75188d9f3da506a7bc8bd3c633bc2d Mon Sep 17 00:00:00 2001 From: Julie Marie Date: Fri, 13 Sep 2024 21:30:08 +0200 Subject: [PATCH 3/5] raist NotImplementedError for projection sets --- py4DSTEM/process/phase/ptychographic_methods.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/py4DSTEM/process/phase/ptychographic_methods.py b/py4DSTEM/process/phase/ptychographic_methods.py index e0c74722f..2389298cd 100644 --- a/py4DSTEM/process/phase/ptychographic_methods.py +++ b/py4DSTEM/process/phase/ptychographic_methods.py @@ -1654,6 +1654,7 @@ def _projection_sets_fourier_projection( overlap, exit_waves, fourier_mask, + virtual_detector_masks, projection_a, projection_b, projection_c, @@ -1685,6 +1686,9 @@ def _projection_sets_fourier_projection( Mask to apply at the detector-plane for zeroing-out unreliable gradients Useful when detector has artifacts such as dead-pixels Currently not implemented for projection-sets + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. projection_a: float projection_b: float projection_c: float @@ -1700,6 +1704,9 @@ def _projection_sets_fourier_projection( if fourier_mask is not None: raise NotImplementedError() + if virtual_detector_masks is not None: + raise NotImplementedError() + xp = self._xp projection_x = 1 - projection_a - projection_b projection_y = 1 - projection_c @@ -1819,6 +1826,7 @@ def _forward( overlap, exit_waves, fourier_mask, + virtual_detector_masks, projection_a, projection_b, projection_c, From 0a4ecf5cd74d61c0974a2658b63d1ba92b1f1bc1 Mon Sep 17 00:00:00 2001 From: gvarnavi Date: Sat, 14 Sep 2024 23:35:30 +0300 Subject: [PATCH 4/5] adding virtual detector support for mixed-probe fourier projection --- .../process/phase/ptychographic_methods.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/py4DSTEM/process/phase/ptychographic_methods.py b/py4DSTEM/process/phase/ptychographic_methods.py index 2389298cd..7a38ec0bb 100644 --- a/py4DSTEM/process/phase/ptychographic_methods.py +++ b/py4DSTEM/process/phase/ptychographic_methods.py @@ -2766,7 +2766,9 @@ def _return_farfield_amplitudes(self, fourier_overlap): xp = self._xp return xp.sqrt(xp.sum(xp.abs(fourier_overlap) ** 2, axis=1)) - def _gradient_descent_fourier_projection(self, amplitudes, overlap, fourier_mask): + def _gradient_descent_fourier_projection( + self, amplitudes, overlap, fourier_mask, virtual_detector_masks + ): """ Ptychographic fourier projection method for GD method. @@ -2779,6 +2781,9 @@ def _gradient_descent_fourier_projection(self, amplitudes, overlap, fourier_mask fourier_mask: np.ndarray Mask to apply at the detector-plane for zeroing-out unreliable gradients Useful when detector has artifacts such as dead-pixels + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. Returns -------- @@ -2802,8 +2807,19 @@ def _gradient_descent_fourier_projection(self, amplitudes, overlap, fourier_mask xp=xp, ) + if virtual_detector_masks is not None: + masked_values = xp.sum( + fourier_overlap[:, :, None, :, :] + * virtual_detector_masks[None, None, :, :, :], + axis=(-1, -2), + ).transpose(2, 0, 1) + fourier_overlap = xp.zeros_like(fourier_overlap) + for mask, value in zip(virtual_detector_masks, masked_values): + fourier_overlap[..., mask] = value[:, :, None] / xp.sum(mask) + if fourier_mask is not None: fourier_overlap *= fourier_mask + farfield_amplitudes = self._return_farfield_amplitudes(fourier_overlap) error = xp.sum(xp.abs(amplitudes - farfield_amplitudes) ** 2) @@ -2813,6 +2829,7 @@ def _gradient_descent_fourier_projection(self, amplitudes, overlap, fourier_mask fourier_modified_overlap = amplitude_modification[:, None] * fourier_overlap fourier_modified_overlap = fourier_modified_overlap - fourier_overlap + if fourier_mask is not None: fourier_modified_overlap *= fourier_mask @@ -2836,6 +2853,7 @@ def _projection_sets_fourier_projection( overlap, exit_waves, fourier_mask, + virtual_detector_masks, projection_a, projection_b, projection_c, @@ -2867,6 +2885,9 @@ def _projection_sets_fourier_projection( Mask to apply at the detector-plane for zeroing-out unreliable gradients Useful when detector has artifacts such as dead-pixels Currently not implemented for projection sets + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. projection_a: float projection_b: float projection_c: float @@ -2882,6 +2903,9 @@ def _projection_sets_fourier_projection( if fourier_mask is not None: raise NotImplementedError() + if virtual_detector_masks is not None: + raise NotImplementedError() + xp = self._xp projection_x = 1 - projection_a - projection_b projection_y = 1 - projection_c From 76a5da2a2e6883230df159b608ab09caf5b9cbe2 Mon Sep 17 00:00:00 2001 From: gvarnavi Date: Sat, 14 Sep 2024 23:53:50 +0300 Subject: [PATCH 5/5] adding to all classes --- .../process/phase/magnetic_ptychographic_tomography.py | 8 ++++++++ py4DSTEM/process/phase/magnetic_ptychography.py | 8 ++++++++ .../process/phase/mixedstate_multislice_ptychography.py | 8 ++++++++ py4DSTEM/process/phase/mixedstate_ptychography.py | 8 ++++++++ py4DSTEM/process/phase/multislice_ptychography.py | 8 ++++++++ py4DSTEM/process/phase/ptychographic_tomography.py | 8 ++++++++ py4DSTEM/process/phase/xray_magnetic_ptychography.py | 8 ++++++++ 7 files changed, 56 insertions(+) diff --git a/py4DSTEM/process/phase/magnetic_ptychographic_tomography.py b/py4DSTEM/process/phase/magnetic_ptychographic_tomography.py index 8265c1325..68367922b 100644 --- a/py4DSTEM/process/phase/magnetic_ptychographic_tomography.py +++ b/py4DSTEM/process/phase/magnetic_ptychographic_tomography.py @@ -869,6 +869,7 @@ def reconstruct( shrinkage_rad: float = 0.0, fix_potential_baseline: bool = True, detector_fourier_mask: np.ndarray = None, + virtual_detector_masks: Sequence[np.ndarray] = None, tv_denoise: bool = True, tv_denoise_weights=None, tv_denoise_inner_iter=40, @@ -984,6 +985,9 @@ def reconstruct( detector_fourier_mask: np.ndarray Corner-centered mask to multiply the detector-plane gradients with (a value of zero supresses those pixels). Useful when detector has artifacts such as dead-pixels. Usually binary. + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. store_iterations: bool, optional If True, reconstructed objects and probes are stored at each iteration progress_bar: bool, optional @@ -1073,6 +1077,9 @@ def reconstruct( if detector_fourier_mask is not None: detector_fourier_mask = xp.asarray(detector_fourier_mask) + if virtual_detector_masks is not None: + virtual_detector_masks = xp.asarray(virtual_detector_masks) + if gaussian_filter_sigma_m is None: gaussian_filter_sigma_m = gaussian_filter_sigma_e @@ -1180,6 +1187,7 @@ def reconstruct( amplitudes_device, self._exit_waves, detector_fourier_mask, + virtual_detector_masks, use_projection_scheme, projection_a, projection_b, diff --git a/py4DSTEM/process/phase/magnetic_ptychography.py b/py4DSTEM/process/phase/magnetic_ptychography.py index 975f6ac84..15a9871d6 100644 --- a/py4DSTEM/process/phase/magnetic_ptychography.py +++ b/py4DSTEM/process/phase/magnetic_ptychography.py @@ -1193,6 +1193,7 @@ def reconstruct( shrinkage_rad: float = 0.0, fix_potential_baseline: bool = True, detector_fourier_mask: np.ndarray = None, + virtual_detector_masks: Sequence[np.ndarray] = None, store_iterations: bool = False, collective_measurement_updates: bool = True, progress_bar: bool = True, @@ -1309,6 +1310,9 @@ def reconstruct( detector_fourier_mask: np.ndarray Corner-centered mask to multiply the detector-plane gradients with (a value of zero supresses those pixels). Useful when detector has artifacts such as dead-pixels. Usually binary. + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. store_iterations: bool, optional If True, reconstructed objects and probes are stored at each iteration collective_measurement_updates: bool @@ -1404,6 +1408,9 @@ def reconstruct( if detector_fourier_mask is not None: detector_fourier_mask = xp.asarray(detector_fourier_mask) + if virtual_detector_masks is not None: + virtual_detector_masks = xp.asarray(virtual_detector_masks) + if gaussian_filter_sigma_m is None: gaussian_filter_sigma_m = gaussian_filter_sigma_e @@ -1486,6 +1493,7 @@ def reconstruct( amplitudes_device, self._exit_waves, detector_fourier_mask, + virtual_detector_masks, use_projection_scheme=use_projection_scheme, projection_a=projection_a, projection_b=projection_b, diff --git a/py4DSTEM/process/phase/mixedstate_multislice_ptychography.py b/py4DSTEM/process/phase/mixedstate_multislice_ptychography.py index 3bacf1870..ee291690e 100644 --- a/py4DSTEM/process/phase/mixedstate_multislice_ptychography.py +++ b/py4DSTEM/process/phase/mixedstate_multislice_ptychography.py @@ -767,6 +767,7 @@ def reconstruct( shrinkage_rad: float = 0.0, fix_potential_baseline: bool = True, detector_fourier_mask: np.ndarray = None, + virtual_detector_masks: Sequence[np.ndarray] = None, pure_phase_object: bool = False, tv_denoise_chambolle: bool = True, tv_denoise_weight_chambolle=None, @@ -881,6 +882,9 @@ def reconstruct( detector_fourier_mask: np.ndarray Corner-centered mask to multiply the detector-plane gradients with (a value of zero supresses those pixels). Useful when detector has artifacts such as dead-pixels. Usually binary. + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. pure_phase_object: bool, optional If True, object amplitude is set to unity tv_denoise_chambolle: bool @@ -978,6 +982,9 @@ def reconstruct( if detector_fourier_mask is not None: detector_fourier_mask = xp.asarray(detector_fourier_mask) + if virtual_detector_masks is not None: + virtual_detector_masks = xp.asarray(virtual_detector_masks) + # main loop for a0 in tqdmnd( num_iter, @@ -1025,6 +1032,7 @@ def reconstruct( amplitudes_device, self._exit_waves, detector_fourier_mask, + virtual_detector_masks, use_projection_scheme, projection_a, projection_b, diff --git a/py4DSTEM/process/phase/mixedstate_ptychography.py b/py4DSTEM/process/phase/mixedstate_ptychography.py index 9b12d09e0..b3ed1b532 100644 --- a/py4DSTEM/process/phase/mixedstate_ptychography.py +++ b/py4DSTEM/process/phase/mixedstate_ptychography.py @@ -676,6 +676,7 @@ def reconstruct( shrinkage_rad: float = 0.0, fix_potential_baseline: bool = True, detector_fourier_mask: np.ndarray = None, + virtual_detector_masks: Sequence[np.ndarray] = None, store_iterations: bool = False, progress_bar: bool = True, reset: bool = None, @@ -787,6 +788,9 @@ def reconstruct( detector_fourier_mask: np.ndarray Corner-centered mask to multiply the detector-plane gradients with (a value of zero supresses those pixels). Useful when detector has artifacts such as dead-pixels. Usually binary. + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. store_iterations: bool, optional If True, reconstructed objects and probes are stored at each iteration progress_bar: bool, optional @@ -872,6 +876,9 @@ def reconstruct( if detector_fourier_mask is not None: detector_fourier_mask = xp.asarray(detector_fourier_mask) + if virtual_detector_masks is not None: + virtual_detector_masks = xp.asarray(virtual_detector_masks) + # main loop for a0 in tqdmnd( num_iter, @@ -919,6 +926,7 @@ def reconstruct( amplitudes_device, self._exit_waves, detector_fourier_mask, + virtual_detector_masks, use_projection_scheme, projection_a, projection_b, diff --git a/py4DSTEM/process/phase/multislice_ptychography.py b/py4DSTEM/process/phase/multislice_ptychography.py index 65a347b83..7a678511a 100644 --- a/py4DSTEM/process/phase/multislice_ptychography.py +++ b/py4DSTEM/process/phase/multislice_ptychography.py @@ -739,6 +739,7 @@ def reconstruct( shrinkage_rad: float = 0.0, fix_potential_baseline: bool = True, detector_fourier_mask: np.ndarray = None, + virtual_detector_masks: Sequence[np.ndarray] = None, pure_phase_object: bool = False, tv_denoise_chambolle: bool = True, tv_denoise_weight_chambolle=None, @@ -853,6 +854,9 @@ def reconstruct( detector_fourier_mask: np.ndarray Corner-centered mask to multiply the detector-plane gradients with (a value of zero supresses those pixels). Useful when detector has artifacts such as dead-pixels. Usually binary. + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. pure_phase_object: bool, optional If True, object amplitude is set to unity tv_denoise_chambolle: bool @@ -954,6 +958,9 @@ def reconstruct( if detector_fourier_mask is not None: detector_fourier_mask = xp.asarray(detector_fourier_mask) + if virtual_detector_masks is not None: + virtual_detector_masks = xp.asarray(virtual_detector_masks) + # main loop for a0 in tqdmnd( num_iter, @@ -1001,6 +1008,7 @@ def reconstruct( amplitudes_device, self._exit_waves, detector_fourier_mask, + virtual_detector_masks, use_projection_scheme, projection_a, projection_b, diff --git a/py4DSTEM/process/phase/ptychographic_tomography.py b/py4DSTEM/process/phase/ptychographic_tomography.py index 037ef4849..3a2490e2d 100644 --- a/py4DSTEM/process/phase/ptychographic_tomography.py +++ b/py4DSTEM/process/phase/ptychographic_tomography.py @@ -788,6 +788,7 @@ def reconstruct( shrinkage_rad: float = 0.0, fix_potential_baseline: bool = True, detector_fourier_mask: np.ndarray = None, + virtual_detector_masks: Sequence[np.ndarray] = None, tv_denoise: bool = True, tv_denoise_weights: float = None, tv_denoise_inner_iter=40, @@ -901,6 +902,9 @@ def reconstruct( detector_fourier_mask: np.ndarray Corner-centered mask to apply at the detector-plane for zeroing-out unreliable gradients. Useful when detector has artifacts such as dead-pixels. Usually binary. + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. store_iterations: bool, optional If True, reconstructed objects and probes are stored at each iteration progress_bar: bool, optional @@ -979,6 +983,9 @@ def reconstruct( if detector_fourier_mask is not None: detector_fourier_mask = xp.asarray(detector_fourier_mask) + if virtual_detector_masks is not None: + virtual_detector_masks = xp.asarray(virtual_detector_masks) + # main loop for a0 in tqdmnd( num_iter, @@ -1071,6 +1078,7 @@ def reconstruct( amplitudes_device, self._exit_waves, detector_fourier_mask, + virtual_detector_masks, use_projection_scheme, projection_a, projection_b, diff --git a/py4DSTEM/process/phase/xray_magnetic_ptychography.py b/py4DSTEM/process/phase/xray_magnetic_ptychography.py index b1b8a5862..773dde206 100644 --- a/py4DSTEM/process/phase/xray_magnetic_ptychography.py +++ b/py4DSTEM/process/phase/xray_magnetic_ptychography.py @@ -1165,6 +1165,7 @@ def reconstruct( tv_denoise_weight: float = None, tv_denoise_inner_iter: float = 40, detector_fourier_mask: np.ndarray = None, + virtual_detector_masks: Sequence[np.ndarray] = None, store_iterations: bool = False, collective_measurement_updates: bool = True, progress_bar: bool = True, @@ -1281,6 +1282,9 @@ def reconstruct( detector_fourier_mask: np.ndarray Corner-centered mask to multiply the detector-plane gradients with (a value of zero supresses those pixels). Useful when detector has artifacts such as dead-pixels. Usually binary. + virtual_detector_masks: np.ndarray + List of corner-centered boolean masks for binning forward model exit waves, + to allow comparison with arbitrary geometry detector datasets. store_iterations: bool, optional If True, reconstructed objects and probes are stored at each iteration collective_measurement_updates: bool @@ -1376,6 +1380,9 @@ def reconstruct( if detector_fourier_mask is not None: detector_fourier_mask = xp.asarray(detector_fourier_mask) + if virtual_detector_masks is not None: + virtual_detector_masks = xp.asarray(virtual_detector_masks) + if gaussian_filter_sigma_m is None: gaussian_filter_sigma_m = gaussian_filter_sigma_e @@ -1458,6 +1465,7 @@ def reconstruct( amplitudes_device, self._exit_waves, detector_fourier_mask, + virtual_detector_masks, use_projection_scheme=use_projection_scheme, projection_a=projection_a, projection_b=projection_b,