AOT-biomaps 2.9.186__py3-none-any.whl → 2.9.294__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 (28) hide show
  1. AOT_biomaps/AOT_Acoustic/StructuredWave.py +2 -2
  2. AOT_biomaps/AOT_Acoustic/_mainAcoustic.py +11 -6
  3. AOT_biomaps/AOT_Experiment/Tomography.py +74 -4
  4. AOT_biomaps/AOT_Experiment/_mainExperiment.py +95 -55
  5. AOT_biomaps/AOT_Recon/AOT_Optimizers/DEPIERRO.py +48 -13
  6. AOT_biomaps/AOT_Recon/AOT_Optimizers/LS.py +406 -13
  7. AOT_biomaps/AOT_Recon/AOT_Optimizers/MAPEM.py +118 -38
  8. AOT_biomaps/AOT_Recon/AOT_Optimizers/MLEM.py +303 -102
  9. AOT_biomaps/AOT_Recon/AOT_Optimizers/PDHG.py +443 -12
  10. AOT_biomaps/AOT_Recon/AOT_PotentialFunctions/RelativeDifferences.py +10 -14
  11. AOT_biomaps/AOT_Recon/AOT_SparseSMatrix/SparseSMatrix_CSR.py +274 -0
  12. AOT_biomaps/AOT_Recon/AOT_SparseSMatrix/SparseSMatrix_SELL.py +328 -0
  13. AOT_biomaps/AOT_Recon/AOT_SparseSMatrix/__init__.py +2 -0
  14. AOT_biomaps/AOT_Recon/AOT_biomaps_kernels.cubin +0 -0
  15. AOT_biomaps/AOT_Recon/AlgebraicRecon.py +243 -113
  16. AOT_biomaps/AOT_Recon/AnalyticRecon.py +26 -41
  17. AOT_biomaps/AOT_Recon/BayesianRecon.py +81 -146
  18. AOT_biomaps/AOT_Recon/PrimalDualRecon.py +157 -94
  19. AOT_biomaps/AOT_Recon/ReconEnums.py +27 -2
  20. AOT_biomaps/AOT_Recon/ReconTools.py +229 -12
  21. AOT_biomaps/AOT_Recon/__init__.py +1 -0
  22. AOT_biomaps/AOT_Recon/_mainRecon.py +60 -53
  23. AOT_biomaps/__init__.py +4 -69
  24. {aot_biomaps-2.9.186.dist-info → aot_biomaps-2.9.294.dist-info}/METADATA +2 -1
  25. aot_biomaps-2.9.294.dist-info/RECORD +47 -0
  26. aot_biomaps-2.9.186.dist-info/RECORD +0 -43
  27. {aot_biomaps-2.9.186.dist-info → aot_biomaps-2.9.294.dist-info}/WHEEL +0 -0
  28. {aot_biomaps-2.9.186.dist-info → aot_biomaps-2.9.294.dist-info}/top_level.txt +0 -0
@@ -2,13 +2,94 @@ from AOT_biomaps.AOT_Recon.ReconEnums import PotentialType
2
2
  from AOT_biomaps.AOT_Recon.AOT_PotentialFunctions.Quadratic import _Omega_QUADRATIC_CPU, _Omega_QUADRATIC_GPU
3
3
  from AOT_biomaps.AOT_Recon.AOT_PotentialFunctions.RelativeDifferences import _Omega_RELATIVE_DIFFERENCE_CPU, _Omega_RELATIVE_DIFFERENCE_GPU
4
4
  from AOT_biomaps.AOT_Recon.AOT_PotentialFunctions.Huber import _Omega_HUBER_PIECEWISE_CPU, _Omega_HUBER_PIECEWISE_GPU
5
- from AOT_biomaps.AOT_Recon.ReconTools import _build_adjacency_sparse
5
+ from AOT_biomaps.AOT_Recon.ReconTools import _build_adjacency_sparse, check_gpu_memory, calculate_memory_requirement
6
6
  from AOT_biomaps.Config import config
7
+
8
+ import warnings
7
9
  import numpy as np
8
10
  import torch
9
11
  from tqdm import trange
10
12
 
11
- def _MAPEM_CPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSavingEachIteration, withTumor, max_saves=5000):
13
+ def MAPEM(
14
+ SMatrix,
15
+ y,
16
+ Omega,
17
+ beta,
18
+ delta=None,
19
+ gamma=None,
20
+ sigma=None,
21
+ numIterations=100,
22
+ isSavingEachIteration=True,
23
+ withTumor=True,
24
+ device=None,
25
+ max_saves=5000,
26
+ show_logs=True):
27
+ """
28
+ This method implements the MAPEM algorithm using either CPU or single-GPU PyTorch acceleration.
29
+ Multi-GPU and Multi-CPU modes are not implemented for this algorithm.
30
+ """
31
+ try:
32
+ tumor_str = "WITH" if withTumor else "WITHOUT"
33
+ # Auto-select device and method
34
+ if device is None:
35
+ if torch.cuda.is_available() and check_gpu_memory(config.select_best_gpu(), calculate_memory_requirement(SMatrix, y), show_logs=show_logs):
36
+ device = torch.device(f"cuda:{config.select_best_gpu()}")
37
+ use_gpu = True
38
+ else:
39
+ device = torch.device("cpu")
40
+ use_gpu = False
41
+ else:
42
+ use_gpu = device.type == "cuda"
43
+ # Dispatch to the appropriate implementation
44
+ if use_gpu:
45
+ return _MAPEM_GPU(SMatrix, y, Omega, beta, delta, gamma, sigma, numIterations, isSavingEachIteration, tumor_str, device, max_saves, show_logs=True)
46
+ else:
47
+ return _MAPEM_CPU(SMatrix, y, Omega, beta, delta, gamma, sigma, numIterations, isSavingEachIteration, tumor_str, max_saves, show_logs=True)
48
+ except Exception as e:
49
+ print(f"Error in MLEM: {type(e).__name__}: {e}")
50
+ return None, None
51
+
52
+ def MAPEM_STOP(
53
+ SMatrix,
54
+ y,
55
+ Omega,
56
+ beta,
57
+ delta=None,
58
+ gamma=None,
59
+ sigma=None,
60
+ numIterations=100,
61
+ isSavingEachIteration=True,
62
+ withTumor=True,
63
+ device=None,
64
+ max_saves=5000,
65
+ show_logs=True):
66
+ """
67
+ This method implements the MAPEM_STOP algorithm using either CPU or single-GPU PyTorch acceleration.
68
+ Multi-GPU and Multi-CPU modes are not implemented for this algorithm.
69
+ """
70
+ try:
71
+ tumor_str = "WITH" if withTumor else "WITHOUT"
72
+ # Auto-select device and method
73
+ if device is None:
74
+ if torch.cuda.is_available() and check_gpu_memory(config.select_best_gpu(), calculate_memory_requirement(SMatrix, y), show_logs=show_logs):
75
+ device = torch.device(f"cuda:{config.select_best_gpu()}")
76
+ use_gpu = True
77
+ else:
78
+ device = torch.device("cpu")
79
+ use_gpu = False
80
+ else:
81
+ use_gpu = device.type == "cuda"
82
+ # Dispatch to the appropriate implementation
83
+ if use_gpu:
84
+ return _MAPEM_GPU_STOP(SMatrix, y, Omega, beta, delta, gamma, sigma, numIterations, isSavingEachIteration, tumor_str, device, max_saves, show_logs=True)
85
+ else:
86
+ return _MAPEM_CPU_STOP(SMatrix, y, Omega, beta, delta, gamma, sigma, numIterations, isSavingEachIteration, tumor_str, max_saves, show_logs=True)
87
+ except Exception as e:
88
+ print(f"Error in MLEM: {type(e).__name__}: {e}")
89
+ return None, None
90
+
91
+
92
+ def _MAPEM_CPU_STOP(SMatrix, y, Omega, beta, delta, gamma, sigma, numIterations, isSavingEachIteration, tumor_str, max_saves, show_logs=True):
12
93
  """
13
94
  MAPEM version CPU simple - sans GPU - torch uniquement
14
95
  """
@@ -42,7 +123,6 @@ def _MAPEM_CPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma,
42
123
  theta_list = [I_0]
43
124
  results = [I_0.numpy()]
44
125
  saved_indices = [0]
45
- previous = -np.inf
46
126
  normalization_factor = SMatrix.sum(dim=(0, 3)).reshape(-1)
47
127
  adj_index, adj_values = _build_adjacency_sparse(Z, X)
48
128
 
@@ -56,13 +136,14 @@ def _MAPEM_CPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma,
56
136
  save_indices.append(numIterations - 1)
57
137
 
58
138
  if Omega == PotentialType.HUBER_PIECEWISE:
59
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse HUBER β:{beta:.4f}, δ:{delta:.4f}) + STOP condition (penalized log-likelihood) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single CPU ----"
139
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse HUBER β:{beta:.4f}, δ:{delta:.4f}) + STOP condition (penalized log-likelihood) ---- {tumor_str} TUMOR ---- processing on single CPU ----"
60
140
  elif Omega == PotentialType.RELATIVE_DIFFERENCE:
61
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse RD β:{beta:.4f}, γ:{gamma:.4f}) + STOP condition (penalized log-likelihood) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single CPU ----"
141
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse RD β:{beta:.4f}, γ:{gamma:.4f}) + STOP condition (penalized log-likelihood) ---- {tumor_str} TUMOR ---- processing on single CPU ----"
62
142
  elif Omega == PotentialType.QUADRATIC:
63
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse QUADRATIC β:{beta:.4f}, σ:{sigma:.4f}) + STOP condition (penalized log-likelihood) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single CPU ----"
143
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse QUADRATIC β:{beta:.4f}, σ:{sigma:.4f}) + STOP condition (penalized log-likelihood) ---- {tumor_str} TUMOR ---- processing on single CPU ----"
64
144
 
65
- for p in trange(numIterations, desc=description):
145
+ iterator = trange(numIterations, desc=description) if show_logs else range(numIterations)
146
+ for it in iterator:
66
147
  theta_p = theta_list[-1]
67
148
  theta_p_flat = theta_p.reshape(-1)
68
149
  q_flat = A_flat @ theta_p_flat
@@ -80,14 +161,13 @@ def _MAPEM_CPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma,
80
161
  theta_next_flat = torch.clamp(theta_next_flat, min=0)
81
162
  theta_next = theta_next_flat.reshape(Z, X)
82
163
  theta_list[-1] = theta_next
83
- if isSavingEachIteration and p in save_indices:
164
+ if isSavingEachIteration and it in save_indices:
84
165
  results.append(theta_next.numpy())
85
- saved_indices.append(p+1)
166
+ saved_indices.append(it+1)
86
167
  log_likelihood = (y_flat * torch.log(q_flat + 1e-8) - (q_flat + 1e-8)).sum()
87
168
  penalized_log_likelihood = log_likelihood - beta * U_value
88
- current = penalized_log_likelihood.item()
89
- if (p + 1) % 100 == 0:
90
- print(f"Iter {p+1}: logL={log_likelihood:.3e}, U={U_value:.3e}, penalized logL={penalized_log_likelihood:.3e}")
169
+ if (it + 1) % 100 == 0:
170
+ print(f"Iter {it+1}: logL={log_likelihood:.3e}, U={U_value:.3e}, penalized logL={penalized_log_likelihood:.3e}")
91
171
 
92
172
  if isSavingEachIteration:
93
173
  return results, saved_indices
@@ -97,7 +177,7 @@ def _MAPEM_CPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma,
97
177
  print(f"An error occurred in _MAPEM_CPU_STOP: {e}")
98
178
  return None, None
99
179
 
100
- def _MAPEM_GPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSavingEachIteration, withTumor, max_saves=5000):
180
+ def _MAPEM_GPU_STOP(SMatrix, y, Omega, beta, delta, gamma, sigma, numIterations, isSavingEachIteration, tumor_str, device, max_saves, show_logs=True):
101
181
  """
102
182
  Maximum A Posteriori (MAP) estimation for Bayesian reconstruction.
103
183
  This method computes the MAP estimate of the parameters given the data.
@@ -123,7 +203,6 @@ def _MAPEM_GPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma,
123
203
  else:
124
204
  raise ValueError(f"Unknown potential type: {Omega}")
125
205
 
126
- device = torch.device(f"cuda:{config.select_best_gpu()}")
127
206
  A_matrix_torch = torch.tensor(SMatrix, dtype=torch.float32).to(device)
128
207
  y_torch = torch.tensor(y, dtype=torch.float32).to(device)
129
208
  T, Z, X, N = SMatrix.shape
@@ -150,13 +229,14 @@ def _MAPEM_GPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma,
150
229
  save_indices.append(numIterations - 1)
151
230
 
152
231
  if Omega == PotentialType.HUBER_PIECEWISE:
153
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse HUBER β:{beta:.4f}, δ:{delta:.4f}) + STOP condition (penalized log-likelihood) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
232
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse HUBER β:{beta:.4f}, δ:{delta:.4f}) + STOP condition (penalized log-likelihood) ---- {tumor_str} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
154
233
  elif Omega == PotentialType.RELATIVE_DIFFERENCE:
155
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse RD β:{beta:.4f}, γ:{gamma:.4f}) + STOP condition (penalized log-likelihood) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
234
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse RD β:{beta:.4f}, γ:{gamma:.4f}) + STOP condition (penalized log-likelihood) ---- {tumor_str} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
156
235
  elif Omega == PotentialType.QUADRATIC:
157
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse QUADRATIC β:{beta:.4f}, σ:{sigma:.4f}) + STOP condition (penalized log-likelihood) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
236
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse QUADRATIC β:{beta:.4f}, σ:{sigma:.4f}) + STOP condition (penalized log-likelihood) ---- {tumor_str} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
158
237
 
159
- for p in trange(numIterations, desc=description):
238
+ iterator = trange(numIterations, desc=description) if show_logs else range(numIterations)
239
+ for it in iterator:
160
240
  theta_p = matrix_theta_torch[-1]
161
241
  theta_p_flat = theta_p.reshape(-1)
162
242
  q_flat = A_flat @ theta_p_flat
@@ -176,18 +256,18 @@ def _MAPEM_GPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma,
176
256
  theta_p_plus_1_flat = torch.clamp(theta_p_plus_1_flat, min=0)
177
257
  theta_next = theta_p_plus_1_flat.reshape(Z, X)
178
258
  matrix_theta_torch[-1] = theta_next
179
- if isSavingEachIteration and p in save_indices:
259
+ if isSavingEachIteration and it in save_indices:
180
260
  matrix_theta_from_gpu_MAPEM.append(theta_next.cpu().numpy())
181
- saved_indices.append(p+1)
261
+ saved_indices.append(it+1)
182
262
  log_likelihood = (y_flat * (torch.log(q_flat + torch.finfo(torch.float32).tiny)) - (q_flat + torch.finfo(torch.float32).tiny)).sum()
183
263
  penalized_log_likelihood = log_likelihood - beta * U_value
184
- if p == 0 or (p + 1) % 100 == 0:
264
+ if it == 0 or (it + 1) % 100 == 0:
185
265
  current = penalized_log_likelihood.item()
186
266
  if current <= previous:
187
267
  nb_false_successive += 1
188
268
  else:
189
269
  nb_false_successive = 0
190
- print(f"Iter {p + 1}: lnL without term ln(m_i !) inside={log_likelihood.item():.8e}, Gibbs energy function U={U_value.item():.4e}, penalized lnL without term ln(m_i !) inside={penalized_log_likelihood.item():.8e}, p lnL (current {current:.8e} - previous {previous:.8e} > 0)={(current - previous > 0)}, nb_false_successive={nb_false_successive}")
270
+ print(f"Iter {it + 1}: lnL without term ln(m_i !) inside={log_likelihood.item():.8e}, Gibbs energy function U={U_value.item():.4e}, penalized lnL without term ln(m_i !) inside={penalized_log_likelihood.item():.8e}, p lnL (current {current:.8e} - previous {previous:.8e} > 0)={(current - previous > 0)}, nb_false_successive={nb_false_successive}")
191
271
  previous = current
192
272
 
193
273
  del A_matrix_torch, y_torch, A_flat, y_flat, I_0, normalization_factor, normalization_factor_flat
@@ -202,7 +282,7 @@ def _MAPEM_GPU_STOP(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma,
202
282
  torch.cuda.empty_cache()
203
283
  return None, None
204
284
 
205
- def _MAPEM_CPU(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSavingEachIteration, withTumor, max_saves=5000):
285
+ def _MAPEM_CPU(SMatrix, y, Omega, beta, delta, gamma, sigma, numIterations, isSavingEachIteration, tumor_str, max_saves, show_logs=True):
206
286
  try:
207
287
  if not isinstance(Omega, PotentialType):
208
288
  raise TypeError(f"Omega must be of type PotentialType, got {type(Omega)}")
@@ -225,7 +305,6 @@ def _MAPEM_CPU(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSa
225
305
  raise ValueError(f"Unknown potential type: {Omega}")
226
306
 
227
307
  T, Z, X, N = SMatrix.shape
228
- J = Z * X
229
308
  A_flat = np.transpose(SMatrix, (0, 3, 1, 2)).reshape(T * N, Z * X)
230
309
  y_flat = y.reshape(-1)
231
310
  theta_0 = np.ones((Z, X), dtype=np.float32)
@@ -246,13 +325,14 @@ def _MAPEM_CPU(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSa
246
325
  save_indices.append(numIterations - 1)
247
326
 
248
327
  if Omega == PotentialType.HUBER_PIECEWISE:
249
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse HUBER β:{beta:.4f}, δ:{delta:.4f}) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single CPU ----"
328
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse HUBER β:{beta:.4f}, δ:{delta:.4f}) ---- {tumor_str} TUMOR ---- processing on single CPU ----"
250
329
  elif Omega == PotentialType.RELATIVE_DIFFERENCE:
251
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse RD β:{beta:.4f}, γ:{gamma:.4f}) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single CPU ----"
330
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse RD β:{beta:.4f}, γ:{gamma:.4f}) ---- {tumor_str} TUMOR ---- processing on single CPU ----"
252
331
  elif Omega == PotentialType.QUADRATIC:
253
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse QUADRATIC β:{beta:.4f}, σ:{sigma:.4f}) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single CPU ----"
332
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse QUADRATIC β:{beta:.4f}, σ:{sigma:.4f}) ---- {tumor_str} TUMOR ---- processing on single CPU ----"
254
333
 
255
- for p in trange(numIterations, desc=description):
334
+ iterator = trange(numIterations, desc=description) if show_logs else range(numIterations)
335
+ for it in iterator:
256
336
  theta_p = matrix_theta_np[-1]
257
337
  theta_p_flat = theta_p.reshape(-1)
258
338
  q_flat = A_flat @ theta_p_flat
@@ -270,9 +350,9 @@ def _MAPEM_CPU(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSa
270
350
  theta_p_plus_1_flat = np.clip(theta_p_plus_1_flat, 0, None)
271
351
  theta_next = theta_p_plus_1_flat.reshape(Z, X)
272
352
  matrix_theta_np.append(theta_next)
273
- if isSavingEachIteration and p in save_indices:
353
+ if isSavingEachIteration and it in save_indices:
274
354
  I_reconMatrix.append(theta_next.copy())
275
- saved_indices.append(p+1)
355
+ saved_indices.append(it+1)
276
356
 
277
357
  if isSavingEachIteration:
278
358
  return I_reconMatrix, saved_indices
@@ -282,7 +362,7 @@ def _MAPEM_CPU(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSa
282
362
  print(f"An error occurred in _MAPEM_CPU: {e}")
283
363
  return None, None
284
364
 
285
- def _MAPEM_GPU(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSavingEachIteration, withTumor, max_saves=5000):
365
+ def _MAPEM_GPU(SMatrix, y, Omega, beta, delta, gamma, sigma, numIterations, isSavingEachIteration, tumor_str, device, max_saves, show_logs=True):
286
366
  """
287
367
  Maximum A Posteriori (MAP) estimation for Bayesian reconstruction using GPU.
288
368
  This method computes the MAP estimate of the parameters given the data.
@@ -308,7 +388,6 @@ def _MAPEM_GPU(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSa
308
388
  else:
309
389
  raise ValueError(f"Unknown potential type: {Omega}")
310
390
 
311
- device = torch.device(f"cuda:{config.select_best_gpu()}")
312
391
  A_matrix_torch = torch.tensor(SMatrix, dtype=torch.float32).to(device)
313
392
  y_torch = torch.tensor(y, dtype=torch.float32).to(device)
314
393
  T, Z, X, N = SMatrix.shape
@@ -333,13 +412,14 @@ def _MAPEM_GPU(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSa
333
412
  save_indices.append(numIterations - 1)
334
413
 
335
414
  if Omega == PotentialType.HUBER_PIECEWISE:
336
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse HUBER β:{beta:.4f}, δ:{delta:.4f}) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
415
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse HUBER β:{beta:.4f}, δ:{delta:.4f}) ---- {tumor_str} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
337
416
  elif Omega == PotentialType.RELATIVE_DIFFERENCE:
338
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse RD β:{beta:.4f}, γ:{gamma:.4f}) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
417
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse RD β:{beta:.4f}, γ:{gamma:.4f}) ---- {tumor_str} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
339
418
  elif Omega == PotentialType.QUADRATIC:
340
- description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse QUADRATIC σ:{sigma:.4f}) ---- {'WITH' if withTumor else 'WITHOUT'} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
419
+ description = f"AOT-BioMaps -- Bayesian Reconstruction Tomography: MAP-EM (Sparse QUADRATIC σ:{sigma:.4f}) ---- {tumor_str} TUMOR ---- processing on single GPU no.{torch.cuda.current_device()} ----"
341
420
 
342
- for p in trange(numIterations, desc=description):
421
+ iterator = trange(numIterations, desc=description) if show_logs else range(numIterations)
422
+ for it in iterator:
343
423
  theta_p = matrix_theta_torch[-1]
344
424
  theta_p_flat = theta_p.reshape(-1)
345
425
  q_flat = A_flat @ theta_p_flat
@@ -359,9 +439,9 @@ def _MAPEM_GPU(SMatrix, y, Omega, numIterations, beta, delta, gamma, sigma, isSa
359
439
  theta_p_plus_1_flat = torch.clamp(theta_p_plus_1_flat, min=0)
360
440
  theta_next = theta_p_plus_1_flat.reshape(Z, X)
361
441
  matrix_theta_torch.append(theta_next)
362
- if isSavingEachIteration and p in save_indices:
442
+ if isSavingEachIteration and it in save_indices:
363
443
  I_reconMatrix.append(theta_next.cpu().numpy())
364
- saved_indices.append(p+1)
444
+ saved_indices.append(it+1)
365
445
 
366
446
  del A_matrix_torch, y_torch, A_flat, y_flat, theta_0, normalization_factor, normalization_factor_flat
367
447
  torch.cuda.empty_cache()