AOT-biomaps 2.1.3__py3-none-any.whl → 2.9.233__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of AOT-biomaps might be problematic. Click here for more details.

Files changed (50) hide show
  1. AOT_biomaps/AOT_Acoustic/AcousticEnums.py +64 -0
  2. AOT_biomaps/AOT_Acoustic/AcousticTools.py +221 -0
  3. AOT_biomaps/AOT_Acoustic/FocusedWave.py +244 -0
  4. AOT_biomaps/AOT_Acoustic/IrregularWave.py +66 -0
  5. AOT_biomaps/AOT_Acoustic/PlaneWave.py +43 -0
  6. AOT_biomaps/AOT_Acoustic/StructuredWave.py +392 -0
  7. AOT_biomaps/AOT_Acoustic/__init__.py +15 -0
  8. AOT_biomaps/AOT_Acoustic/_mainAcoustic.py +978 -0
  9. AOT_biomaps/AOT_Experiment/Focus.py +55 -0
  10. AOT_biomaps/AOT_Experiment/Tomography.py +505 -0
  11. AOT_biomaps/AOT_Experiment/__init__.py +9 -0
  12. AOT_biomaps/AOT_Experiment/_mainExperiment.py +532 -0
  13. AOT_biomaps/AOT_Optic/Absorber.py +24 -0
  14. AOT_biomaps/AOT_Optic/Laser.py +70 -0
  15. AOT_biomaps/AOT_Optic/OpticEnums.py +17 -0
  16. AOT_biomaps/AOT_Optic/__init__.py +10 -0
  17. AOT_biomaps/AOT_Optic/_mainOptic.py +204 -0
  18. AOT_biomaps/AOT_Recon/AOT_Optimizers/DEPIERRO.py +191 -0
  19. AOT_biomaps/AOT_Recon/AOT_Optimizers/LS.py +106 -0
  20. AOT_biomaps/AOT_Recon/AOT_Optimizers/MAPEM.py +456 -0
  21. AOT_biomaps/AOT_Recon/AOT_Optimizers/MLEM.py +333 -0
  22. AOT_biomaps/AOT_Recon/AOT_Optimizers/PDHG.py +221 -0
  23. AOT_biomaps/AOT_Recon/AOT_Optimizers/__init__.py +5 -0
  24. AOT_biomaps/AOT_Recon/AOT_PotentialFunctions/Huber.py +90 -0
  25. AOT_biomaps/AOT_Recon/AOT_PotentialFunctions/Quadratic.py +86 -0
  26. AOT_biomaps/AOT_Recon/AOT_PotentialFunctions/RelativeDifferences.py +59 -0
  27. AOT_biomaps/AOT_Recon/AOT_PotentialFunctions/__init__.py +3 -0
  28. AOT_biomaps/AOT_Recon/AlgebraicRecon.py +1023 -0
  29. AOT_biomaps/AOT_Recon/AnalyticRecon.py +154 -0
  30. AOT_biomaps/AOT_Recon/BayesianRecon.py +230 -0
  31. AOT_biomaps/AOT_Recon/DeepLearningRecon.py +35 -0
  32. AOT_biomaps/AOT_Recon/PrimalDualRecon.py +210 -0
  33. AOT_biomaps/AOT_Recon/ReconEnums.py +375 -0
  34. AOT_biomaps/AOT_Recon/ReconTools.py +273 -0
  35. AOT_biomaps/AOT_Recon/__init__.py +11 -0
  36. AOT_biomaps/AOT_Recon/_mainRecon.py +288 -0
  37. AOT_biomaps/Config.py +95 -0
  38. AOT_biomaps/Settings.py +45 -13
  39. AOT_biomaps/__init__.py +271 -18
  40. aot_biomaps-2.9.233.dist-info/METADATA +22 -0
  41. aot_biomaps-2.9.233.dist-info/RECORD +43 -0
  42. {AOT_biomaps-2.1.3.dist-info → aot_biomaps-2.9.233.dist-info}/WHEEL +1 -1
  43. AOT_biomaps/AOT_Acoustic.py +0 -1881
  44. AOT_biomaps/AOT_Experiment.py +0 -541
  45. AOT_biomaps/AOT_Optic.py +0 -219
  46. AOT_biomaps/AOT_Reconstruction.py +0 -1416
  47. AOT_biomaps/config.py +0 -54
  48. AOT_biomaps-2.1.3.dist-info/METADATA +0 -20
  49. AOT_biomaps-2.1.3.dist-info/RECORD +0 -11
  50. {AOT_biomaps-2.1.3.dist-info → aot_biomaps-2.9.233.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,86 @@
1
+ import numpy as np
2
+ import torch
3
+ from numba import njit
4
+
5
+ @njit
6
+ def _Omega_QUADRATIC_CPU(theta_flat, j_idx, k_idx, values, sigma=1.0):
7
+ """
8
+ Optimized CPU implementation of the quadratic potential using Numba.
9
+
10
+ Parameters:
11
+ theta_flat (np.ndarray): shape (J,)
12
+ j_idx (np.ndarray): indices j (shape N_edges,)
13
+ k_idx (np.ndarray): indices k (shape N_edges,)
14
+ values (np.ndarray): edge weights (shape N_edges,)
15
+ sigma (float): standard deviation (scalar)
16
+
17
+ Returns:
18
+ grad_U (np.ndarray): shape (J,)
19
+ hess_U (np.ndarray): shape (J,)
20
+ U_value (float): scalar
21
+ """
22
+ n_nodes = theta_flat.shape[0]
23
+ n_edges = j_idx.shape[0]
24
+
25
+ grad_U = np.zeros(n_nodes)
26
+ hess_U = np.zeros(n_nodes)
27
+ U_value = 0.0
28
+
29
+ for i in range(n_edges):
30
+ j = j_idx[i]
31
+ k = k_idx[i]
32
+ v = values[i]
33
+ diff = theta_flat[j] - theta_flat[k]
34
+
35
+ psi = 0.5 * (diff / sigma) ** 2
36
+ psi *= v
37
+ U_value += psi
38
+
39
+ grad = -v * diff / sigma**2
40
+ hess = v / sigma**2
41
+
42
+ grad_U[j] += grad
43
+ hess_U[j] += hess
44
+
45
+ U_value *= 0.5
46
+ return grad_U, hess_U, U_value
47
+
48
+ def _Omega_QUADRATIC_GPU(theta_flat, index, values, device, sigma=1.0):
49
+ """
50
+ GPU implementation of the quadratic potential function, gradient and Hessian.
51
+
52
+ Parameters:
53
+ theta_flat (torch.Tensor): (J,) tensor on GPU
54
+ index (Tuple[torch.Tensor, torch.Tensor]): (j_idx, k_idx), indices of adjacent pixels
55
+ values (torch.Tensor): (N_edges,) weights, typically 1 or distance-based
56
+ sigma (float): smoothness hyperparameter
57
+
58
+ Returns:
59
+ grad_U (torch.Tensor): gradient of the potential function, shape (J,)
60
+ hess_U (torch.Tensor): diagonal of the Hessian, shape (J,)
61
+ U_value (torch.Tensor): scalar, energy
62
+ """
63
+ j_idx, k_idx = index
64
+ diff = theta_flat[j_idx] - theta_flat[k_idx]
65
+
66
+ # Energy
67
+ psi_pair = 0.5 * (diff / sigma) ** 2
68
+ psi_pair = values * psi_pair
69
+
70
+ # Gradient
71
+ grad_pair = values * (-diff / sigma**2)
72
+
73
+ # Hessian
74
+ hess_pair = values * (1.0 / sigma**2)
75
+
76
+ # Allocate buffers on correct device
77
+ grad_U = torch.zeros_like(theta_flat, device=device)
78
+ hess_U = torch.zeros_like(theta_flat, device=device)
79
+
80
+ # Accumulate
81
+ grad_U.index_add_(0, j_idx, grad_pair)
82
+ hess_U.index_add_(0, j_idx, hess_pair)
83
+
84
+ U_value = 0.5 * psi_pair.sum()
85
+
86
+ return grad_U, hess_U, U_value
@@ -0,0 +1,59 @@
1
+ import numpy as np
2
+ import torch
3
+ from numba import njit
4
+
5
+ @njit
6
+ def _Omega_RELATIVE_DIFFERENCE_CPU(theta_flat, index, values, gamma):
7
+ j_idx, k_idx = index
8
+ theta_j = theta_flat[j_idx]
9
+ theta_k = theta_flat[k_idx]
10
+ diff = theta_k - theta_j
11
+ abs_diff = np.abs(diff)
12
+ denom = theta_k + theta_j + gamma * abs_diff + 1e-8
13
+ num = diff ** 2
14
+ psi_pair = num / denom
15
+ psi_pair = values * psi_pair
16
+ # First derivative ∂U/∂θ_j
17
+ dpsi = (2 * diff * denom - num * (1 + gamma * np.sign(diff))) / (denom ** 2)
18
+ grad_pair = values * (-dpsi) # Note the negative sign: U contains ψ(θ_k, θ_j), seeking ∂/∂θ_j
19
+ # Second derivative ∂²U/∂θ_j² (numerically stable, approximate treatment)
20
+ d2psi = (2 * denom ** 2 - 4 * diff * denom * (1 + gamma * np.sign(diff))
21
+ + 2 * num * (1 + gamma * np.sign(diff)) ** 2) / (denom ** 3 + 1e-8)
22
+ hess_pair = values * d2psi
23
+ grad_U = np.zeros_like(theta_flat)
24
+ hess_U = np.zeros_like(theta_flat)
25
+ np.add.at(grad_U, j_idx, grad_pair)
26
+ np.add.at(hess_U, j_idx, hess_pair)
27
+ # Compute U_value
28
+ U_value = 0.5 * np.sum(psi_pair)
29
+ return grad_U, hess_U, U_value
30
+
31
+ def _Omega_RELATIVE_DIFFERENCE_GPU(theta_flat, index, values, device, gamma):
32
+ j_idx, k_idx = index
33
+ theta_j = theta_flat[j_idx]
34
+ theta_k = theta_flat[k_idx]
35
+ diff = theta_k - theta_j
36
+ abs_diff = torch.abs(diff)
37
+ denom = theta_k + theta_j + gamma * abs_diff + 1e-8
38
+ num = diff ** 2
39
+ psi_pair = num / denom
40
+ psi_pair = values * psi_pair
41
+ # Compute gradient contributions
42
+ dpsi = (2 * diff * denom - num * (1 + gamma * torch.sign(diff))) / (denom ** 2)
43
+ grad_pair = values * (-dpsi)
44
+ # Compute Hessian contributions
45
+ d2psi = (2 * denom ** 2 - 4 * diff * denom * (1 + gamma * torch.sign(diff))
46
+ + 2 * num * (1 + gamma * torch.sign(diff)) ** 2) / (denom ** 3 + 1e-8)
47
+ hess_pair = values * d2psi
48
+ # Initialize gradient and Hessian on the correct device
49
+ grad_U = torch.zeros_like(theta_flat, device=device)
50
+ hess_U = torch.zeros_like(theta_flat, device=device)
51
+ # Accumulate gradient contributions
52
+ grad_U.index_add_(0, j_idx, grad_pair)
53
+ grad_U.index_add_(0, k_idx, -grad_pair)
54
+ # Accumulate Hessian contributions
55
+ hess_U.index_add_(0, j_idx, hess_pair)
56
+ hess_U.index_add_(0, k_idx, hess_pair)
57
+ # Compute U_value
58
+ U_value = 0.5 * psi_pair.sum()
59
+ return grad_U, hess_U, U_value
@@ -0,0 +1,3 @@
1
+ from .Huber import *
2
+ from .Quadratic import *
3
+ from .RelativeDifferences import *