From ef13e46fca889bff5d7a93c8fe854e1e44e3bc20 Mon Sep 17 00:00:00 2001
From: Jens Lucht <jens.lucht@uni-goettingen.de>
Date: Mon, 16 Dec 2024 15:37:53 +0100
Subject: [PATCH 1/4] Fixed sampling condition for Fresnel TF.

---
 src/hotopy/holo/propagation.py | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/hotopy/holo/propagation.py b/src/hotopy/holo/propagation.py
index c4d018c..a3383cf 100644
--- a/src/hotopy/holo/propagation.py
+++ b/src/hotopy/holo/propagation.py
@@ -31,7 +31,7 @@ Helpers
 
 import logging
 import numpy as np
-from math import ceil
+import math
 import torch
 from torch import conj, real, exp, square, as_tensor, is_complex
 from torch.fft import fftn, ifftn
@@ -93,9 +93,26 @@ def expand_fresnel_numbers(fresnel_nums, *, ndim=None, shape=None):
     return np.broadcast_to(fresnel_nums, (m, ndim))
 
 
-def get_fresnel_critical_sampling(shape, fresnel_nums):
-    # critical sampling for given fresnel numbers, according to Zhang et al 2020 ?
-    return ceil(0.5 / np.min(fresnel_nums))
+def get_fresnel_critical_sampling(fresnel_nums) -> int:
+    r"""
+    Return critical sampling condition for given image dimensions and pixel Fresnel number(s).
+
+    This functions returns the minimal sampling points required in any dimensions. It is,
+
+    .. math:: \frac{1}{\min_i F_{(i)}},
+
+    where :math:`F_{(i)}` it the Fresnel number in the i-th axis.
+
+    Parameters
+    ----------
+    fresnel_nums: float, array_like
+
+    Returns
+    -------
+    sampling: int
+        Minimal required sampling for given Fresnel number(s).
+    """
+    return math.ceil(1 / np.min(fresnel_nums))
 
 
 def check_fresnelTF_sampling(shape, fresnel_nums):
@@ -103,7 +120,7 @@ def check_fresnelTF_sampling(shape, fresnel_nums):
     According to Zhang (TODO)
     """
     # sufficient sampling in all axes?
-    return min(shape) >= get_fresnel_critical_sampling(shape, fresnel_nums)
+    return min(shape) >= get_fresnel_critical_sampling(fresnel_nums)
 
 
 def phase_chirp(shape, fresnel_nums, real=False, ndim=None, dtype=None):
-- 
GitLab


From 93d36b35722d1dd3824cc1f6795510e208867da5 Mon Sep 17 00:00:00 2001
From: Jens Lucht <jens.lucht@uni-goettingen.de>
Date: Mon, 16 Dec 2024 15:38:11 +0100
Subject: [PATCH 2/4] Update docs

---
 src/hotopy/holo/__init__.py    | 6 ++++--
 src/hotopy/holo/propagation.py | 9 ++++++---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/hotopy/holo/__init__.py b/src/hotopy/holo/__init__.py
index b352f75..6c81737 100644
--- a/src/hotopy/holo/__init__.py
+++ b/src/hotopy/holo/__init__.py
@@ -32,11 +32,13 @@ Transport of Intensity (TIE) used for laboratory X-ray sources.
     GeneralizedPaganin
 
 
-Forward propagation
--------------------
+Propagation submodule (:mod:`.propagation`)
+---------------------------------
 .. autosummary::
     :toctree: generated/
 
+    propagation
+
     FresnelTFPropagator
     simulate_hologram
 
diff --git a/src/hotopy/holo/propagation.py b/src/hotopy/holo/propagation.py
index a3383cf..022f870 100644
--- a/src/hotopy/holo/propagation.py
+++ b/src/hotopy/holo/propagation.py
@@ -1,8 +1,11 @@
 """
-====================================================
-Propagation methods (:mod:`hotopy.holo.propagation`)
-====================================================
+======================================================
+Propagation submodule (:mod:`hotopy.holo.propagation`)
+======================================================
 
+Numerical propagation methods for holographic X-ray imaging. Here a subset of propagations methods needed mainly for
+phase retrieval algorithms is implemented. For more versatile propagators we refer to our
+`Python package fresnel <https://gitlab.gwdg.de/irp/fresnel>`_.
 
 Propagators
 -----------
-- 
GitLab


From a5a6390435eee5e4b3c3ae55e43e0415479b3997 Mon Sep 17 00:00:00 2001
From: Jens Lucht <jens.lucht@uni-goettingen.de>
Date: Mon, 16 Dec 2024 15:40:50 +0100
Subject: [PATCH 3/4] Fix docstring

---
 src/hotopy/holo/propagation.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/hotopy/holo/propagation.py b/src/hotopy/holo/propagation.py
index 022f870..9f337fb 100644
--- a/src/hotopy/holo/propagation.py
+++ b/src/hotopy/holo/propagation.py
@@ -98,7 +98,7 @@ def expand_fresnel_numbers(fresnel_nums, *, ndim=None, shape=None):
 
 def get_fresnel_critical_sampling(fresnel_nums) -> int:
     r"""
-    Return critical sampling condition for given image dimensions and pixel Fresnel number(s).
+    Return critical sampling condition for given pixel Fresnel number(s).
 
     This functions returns the minimal sampling points required in any dimensions. It is,
 
-- 
GitLab


From e605a6f246d385d5e4165ac9804930700cf553ff Mon Sep 17 00:00:00 2001
From: Jens Lucht <jens.lucht@uni-goettingen.de>
Date: Mon, 16 Dec 2024 15:45:13 +0100
Subject: [PATCH 4/4] Fix use of get_fresnel_critical_sampling

---
 src/hotopy/holo/propagation.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/hotopy/holo/propagation.py b/src/hotopy/holo/propagation.py
index 9f337fb..67a5295 100644
--- a/src/hotopy/holo/propagation.py
+++ b/src/hotopy/holo/propagation.py
@@ -286,7 +286,7 @@ class FresnelTFPropagator(FourierConvolutionPropagator):
     def _init_kernel(self):
         # verify sufficient padding
         if not check_fresnelTF_sampling(self._pad_shape, self._fresnel_numbers):
-            n_min = get_fresnel_critical_sampling(self._pad_shape, self._fresnel_numbers)
+            n_min = get_fresnel_critical_sampling(self._fresnel_numbers)
             logger.warning(
                 UserWarning(
                     f"{self.__class__.__name__}: "
-- 
GitLab