trung-vt commited on
Commit
098d6a7
·
1 Parent(s): 7dbea8b

CIGS 256x256 multilevel random

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/photocurrent_mapping copy.py +871 -0
  2. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/psnr_boxplot.png +3 -0
  3. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/summary_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05.csv +11 -0
  4. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_10.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  5. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_100.0_percent_coarse_J=8_multilevel_random.npy +3 -0
  6. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_20.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  7. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_30.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  8. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_40.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  9. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_50.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  10. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_60.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  11. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_70.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  12. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_80.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  13. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_90.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  14. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_10.0_percent_coarse_J=6_multilevel_random.png +3 -0
  15. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_100.0_percent_coarse_J=8_multilevel_random.png +3 -0
  16. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=6_multilevel_random.png +3 -0
  17. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_30.0_percent_coarse_J=6_multilevel_random.png +3 -0
  18. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_40.0_percent_coarse_J=6_multilevel_random.png +3 -0
  19. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=6_multilevel_random.png +3 -0
  20. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_60.0_percent_coarse_J=6_multilevel_random.png +3 -0
  21. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_70.0_percent_coarse_J=6_multilevel_random.png +3 -0
  22. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=6_multilevel_random.png +3 -0
  23. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_90.0_percent_coarse_J=6_multilevel_random.png +3 -0
  24. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/metrics.csv +11 -0
  25. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_10.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  26. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_100.0_percent_coarse_J=8_multilevel_random.npy +3 -0
  27. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  28. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_30.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  29. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_40.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  30. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  31. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_60.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  32. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_70.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  33. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  34. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_90.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  35. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_10.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  36. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_100.0_percent_coarse_J=8_multilevel_random.npy +3 -0
  37. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_20.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  38. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_30.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  39. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_40.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  40. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_50.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  41. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_60.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  42. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_70.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  43. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_80.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  44. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_90.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  45. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_10.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  46. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_100.0_percent_coarse_J=8_multilevel_random.npy +3 -0
  47. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_20.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  48. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_30.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  49. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_40.0_percent_coarse_J=6_multilevel_random.npy +3 -0
  50. 20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_50.0_percent_coarse_J=6_multilevel_random.npy +3 -0
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/photocurrent_mapping copy.py ADDED
@@ -0,0 +1,871 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # %% [markdown]
2
+ # # Plug-and-play ADMM for Photocurrent Mapping image reconstruction
3
+ #
4
+ # This notebook demonstrates Plug-and-Play (PnP) ADMM image reconstruction for
5
+ # Photocurrent Mapping (PCM) data.
6
+ #
7
+ # Starting from a high-resolution current map of a CIGS solar cell, subsampled
8
+ # PCM measurements are simulated using the `PhotocurrentMapOp` operator. Several
9
+ # reconstruction methods are then compared:
10
+ #
11
+ # - Zero-filled pseudo-inverse reconstruction.
12
+ # - Two compressed sensing baselines with a wavelet sparsity prior:
13
+ # FISTA with an $\ell_1$ penalty and SPGL1.
14
+ # - PnP-ADMM with a pre-trained DRUNet denoiser as prior.
15
+ #
16
+ # The goal is not to optimise performance, but to illustrate how
17
+ # classical sparse reconstruction methods and PnP can be combined with the LION
18
+ # operators for PCM.
19
+
20
+
21
+ # %% [markdown]
22
+ # ## Setup
23
+
24
+ # %% [markdown]
25
+ # ### Device configuration
26
+ #
27
+ # Set the default device to a GPU if available. If multiple GPUs are present,
28
+ # the desired GPU index can be specified here.
29
+
30
+ # %%
31
+ from __future__ import annotations
32
+ import torch
33
+
34
+ device = torch.device("mps" if torch.backends.mps.is_available() else "cuda:0" if torch.cuda.is_available() else "cpu")
35
+ torch.set_default_device(device)
36
+
37
+ # %% [markdown]
38
+ # ### Imports
39
+ #
40
+ # Import the required libraries, including LION operators and reconstruction algorithms for PCM.
41
+
42
+ # %%
43
+ from datetime import datetime
44
+ from pathlib import Path
45
+ from typing import Callable, Iterable
46
+
47
+ import deepinv
48
+ import matplotlib
49
+ import matplotlib.pyplot as plt
50
+ from matplotlib.colors import ListedColormap
51
+ import numpy as np
52
+ from jaxtyping import Float
53
+ from torchmetrics.image import PeakSignalNoiseRatio, StructuralSimilarityIndexMeasure
54
+ from functools import partial
55
+ from tqdm import tqdm as std_tqdm
56
+
57
+ from LION.classical_algorithms.fista import fista_l1
58
+ from LION.classical_algorithms.spgl1_torch import spgl1_torch
59
+ from LION.operators.Wavelet2D import Wavelet2D
60
+ from LION.operators.CompositeOp import CompositeOp
61
+ from LION.operators.DebiasOp import debias_ls
62
+
63
+ # LION imports
64
+ from LION.operators.PhotocurrentMapOp import PhotocurrentMapOp
65
+ from LION.operators.uniform_random_sample import uniform_random_sample
66
+ from LION.operators.multilevel_sample import multilevel_sample
67
+ from LION.reconstructors.PnP import PnP
68
+
69
+ # from LION.utils.scale import choose_measurement_scale_factor
70
+
71
+ from plot_helper import PlotHelper
72
+
73
+
74
+ # Use tqdm with dynamic column width that adapts to the terminal width
75
+ tqdm = partial(std_tqdm, dynamic_ncols=True)
76
+ tqdm_no_leave = partial(std_tqdm, dynamic_ncols=True, leave=False)
77
+
78
+ GrayscaleImage2D = Float[torch.Tensor, "height width"]
79
+ Measurement1D = Float[torch.Tensor, "num_measurements"]
80
+
81
+ # %% [markdown]
82
+ # ### Define the data file paths
83
+ #
84
+ # The example uses a single $256 \times 256$ current map of a CIGS solar cell
85
+ # stored as a NumPy array. This image will serve as the ground truth in the
86
+ # experiments.
87
+
88
+ # %%
89
+ data_dir = Path("data/photocurrent_data")
90
+ # data_dir = Path("your/path/to/photocurrent_data")
91
+
92
+ assert data_dir.exists(), f"Data directory {data_dir} does not exist."
93
+
94
+ # These images are provided with pixels in range [0, 1]
95
+ data_name, zoom, loc, loc1, loc2, roi = "CIGS_256x256", 2.5, "center left", 3, 4, (110, 210, 40, 40) # (x, y, w, h) with y increasing downwards
96
+ # data_name, zoom, loc, loc1, loc2, roi = "silicon_256x256", 2.5, "lower right", 2, 1, (194, 1, 60, 60) # (x, y, w, h) with y increasing downwards
97
+ # data_name, zoom, loc, loc1, loc2, roi = "silicon_512x512", 3, "lower right", 2, 1, (400, 5, 100, 100) # (x, y, w, h) with y increasing downwards
98
+ # data_name, zoom, loc, loc1, loc2, roi = "organic_256x256", 2.5, "lower left", 2, 1, (70, 5, 50, 50) # (x, y, w, h) with y increasing downwards
99
+ # data_name, zoom, loc, loc1, loc2, roi = "perovskite_256x256", 2.5, "upper left", 3, 4, (90, 190, 50, 50) # (x, y, w, h) with y increasing downwards
100
+ data_name = "example_" + data_name # prefix with "example_"
101
+ is_out_of_distribution = False
102
+ clim = (0.0, 1.0)
103
+ inverses_sign = False
104
+ # R_high, R_low = 1.0, 0.0 # default for normalized images
105
+ is_out_of_distribution = False
106
+
107
+ # # This sample was provided in image form at 512x512 resolution but the pixels are real measured current values
108
+ # data_name, zoom, loc, loc1, loc2, roi = "Si_256_512x512", 2.5, "lower left", 2, 1, (160, 60, 120, 120)
109
+ # clim = (0.0, 3e-5)
110
+ # inverses_sign = True
111
+ # R_high = 1e-4
112
+ # R_low = -5e-6
113
+ # factor = 1e5 # to scale up the photocurrent values for better numerical stability in SPGL1
114
+
115
+ # # This sample was provided in image form at 512x512 resolution but the pixels are real measured current values
116
+ # data_name, zoom, loc, loc1, loc2, roi = "Si_2_256_512x512", 2.5, "lower right", 2, 1, (322, 85, 100, 100)
117
+ # clim = (0.0, 1.5e-5)
118
+ # inverses_sign = True
119
+ # R_high = 2e-5
120
+ # R_low = -2e-6
121
+ # factor = 1e5 # to scale up the photocurrent values for better numerical stability in SPGL1
122
+
123
+ if "256x256" in data_name:
124
+ J_order = 8 # J=8 => 2^8=256
125
+ elif "512x512" in data_name:
126
+ J_order = 9 # J=9 => 2^9=512
127
+ else:
128
+ raise ValueError(f"Unknown data_name {data_name}, cannot determine order_size.")
129
+
130
+ # # # This is the same data as Si_256_512x512 but provided as measurement data and only up to 256x256 resolution
131
+ # data_name, zoom, loc, loc1, loc2, roi = "Si_256_measurement_data", 2, "lower left", 2, 1, (80, 30, 60, 60)
132
+ # # data_name, zoom, loc, loc1, loc2, roi = "Si_256_hadamard_measurement_vector", 2, "lower left", 2, 1, (80, 30, 60, 60)
133
+ # # data_name, zoom, loc, loc1, loc2, roi = "Si_256_reconstructed_image", 2, "lower left", 2, 1, (80, 30, 60, 60)
134
+ # clim = (0.0, 1e-6)
135
+ # R_high = 1e-6
136
+ # R_low = -1e-6
137
+ # factor = 1e7 # to scale up the photocurrent values for better numerical stability in SPGL1
138
+ # J_order = 8 # 2^8 x 2^8 = 256 x 256
139
+
140
+ # # # This is the same data as Si_2_256_512x512 but provided as measurement data and only up to 256x256 resolution
141
+ # data_name, zoom, loc, loc1, loc2, roi = "Si_2_256_measurement_data", 2, "lower left", 2, 1, (32, 42, 50, 50)
142
+ # # data_name, zoom, loc, loc1, loc2, roi = "Si_2_256_hadamard_measurement_vector", 2, "lower left", 2, 1, (32, 42, 50, 50)
143
+ # # data_name, zoom, loc, loc1, loc2, roi = "Si_2_256_reconstructed_image", 2, "lower left", 2, 1, (32, 42, 50, 50)
144
+ # clim = (0.0, 4e-7)
145
+ # R_high = 1e-6
146
+ # R_low = -1e-6
147
+ # factor = 1e7 # to scale up the photocurrent values for better numerical stability in SPGL1
148
+ # J_order = 8 # 2^8 x 2^8 = 256 x 256
149
+
150
+ scale_eps = 1e-12
151
+ # is_out_of_distribution = True
152
+ # inverses_sign = True
153
+
154
+ tests_scale_ground_truth = False
155
+
156
+ data_filename = f"{data_name}.npy"
157
+ print("Loading data file:", data_filename)
158
+ assert (data_dir / data_filename).exists(), f"Data {data_filename} not found in {data_dir}."
159
+
160
+ # data_type = "original_measurement_data"
161
+ # data_type = "hadamard_measurement_vector"
162
+ data_type = "image"
163
+ print(f"The type of raw data is: {data_type}")
164
+
165
+ noise_seed = 42
166
+ noise_std = 0 # No noise
167
+ # noise_std = 0.05 # standard deviation of additive homoscedastic Gaussian white noise added to measurements
168
+
169
+ num_trials = 20
170
+
171
+ runs_pnp_admm = True
172
+ # pnp_admm_iters = 1
173
+ # pnp_admm_iters = 20
174
+ pnp_admm_iters = 50
175
+ # pnp_admm_iters = 100
176
+ # pnp_admm_iters = 150
177
+ # pnp_admm_eta = 0.00001 # Undersampling artifacts may remain if eta is too small
178
+ # pnp_admm_eta = 0.00005 # Could still work
179
+ # pnp_admm_eta = 0.0001 # Could still work
180
+ # pnp_admm_eta = 0.001
181
+ # pnp_admm_eta = 0.005
182
+ pnp_admm_eta = 0.01 # Generally good
183
+ # pnp_admm_eta = 0.02
184
+ # pnp_admm_eta = 0.03
185
+ # pnp_admm_eta = 0.04
186
+ # pnp_admm_eta = 0.05
187
+ # pnp_admm_eta = 0.1
188
+ # pnp_admm_eta = 1
189
+ # pnp_admm_eta = 10
190
+ # pnp_admm_eta = 20
191
+ # pnp_admm_eta = 50
192
+ # pnp_admm_eta = 100 # Got nan for 100% sampling?
193
+ cg_iters = 20
194
+ # cg_iters = 50
195
+ cg_eps = 1e-20 # No real change compared to default, CG usually terminates quickly especially when measurements are small
196
+ # drunet_sigma = 0.01 # noise level for DRUNet denoiser
197
+ # drunet_sigma = 0.02 # noise level for DRUNet denoiser
198
+ drunet_sigma = 0.05 # noise level for DRUNet denoiser
199
+ # drunet_sigma = 0.1 # noise level for DRUNet denoiser
200
+
201
+ runs_fista_l1 = False
202
+
203
+ runs_spgl1 = False
204
+
205
+ randomizing_scheme = "multilevel"
206
+ # randomizing_scheme = "uniform"
207
+
208
+ cmap_max = 0.8 # take only the lower 0-80% of afmhot, reduce brightness
209
+ # cmap_max = 0.9 # take only the lower 0-90% of afmhot to avoid the white top
210
+ # cmap_max = 1.0 # take all of afmhot
211
+ adds_insets = True
212
+ # adds_insets = False
213
+ plot_helper = PlotHelper(
214
+ roi=roi,
215
+ zoom=zoom,
216
+ loc=loc,
217
+ show_rect=True,
218
+ cmap=ListedColormap(matplotlib.colormaps['afmhot'](np.linspace(
219
+ 0.0,
220
+ cmap_max,
221
+ 256,
222
+ ))),
223
+ clim=clim,
224
+ loc1=loc1,
225
+ loc2=loc2
226
+ )
227
+
228
+ # %% [markdown]
229
+ # Define a general function to run the photocurrent mapping reconstruction using a reconstruction method.
230
+ #
231
+ # The helper function `run_pcm_demo`:
232
+ #
233
+ # - Builds the PCM operator and simulates subsampled measurements.
234
+ # - Computes the zero-filled pseudo-inverse reconstruction.
235
+ # - Runs a chosen reconstruction method given by `recon_fn`.
236
+ # - Reports PSNR and SSIM for both reconstructions, displays and saves the images.
237
+
238
+
239
+ # %% mystnb={"code_prompt_show": "Show utility details"} tags=["hide-cell"]
240
+ def show_images_with_inset(
241
+ images: list[torch.Tensor],
242
+ fig_filepath: Path,
243
+ plot_helper: PlotHelper,
244
+ titles: list[str] | None = None,
245
+ suptitle: str | None = None,
246
+ adds_insets: bool = True,
247
+ ) -> None:
248
+ """Plot images."""
249
+ n_images = len(images)
250
+ fig, axes = plt.subplots(1, n_images, squeeze=False, figsize=(n_images * 4, 4))
251
+
252
+ for i in range(n_images):
253
+ img_np = images[i].squeeze().cpu().numpy()
254
+ ax: plt.Axes = axes[0][i]
255
+ if adds_insets:
256
+ plot_helper.add_zoom_inset(ax, img_np)
257
+ else:
258
+ ax.imshow(img_np, cmap=plot_helper.cmap, clim=plot_helper.clim)
259
+ ax.axis("off")
260
+ if titles:
261
+ ax.set_title(titles[i], fontsize=10)
262
+ if suptitle:
263
+ fig.subplots_adjust(bottom=0.18)
264
+ fig.text(0.5, 0.02, suptitle, ha="center", va="bottom", fontsize=16)
265
+ fig.savefig(fig_filepath, dpi=150)
266
+ plt.close(fig)
267
+
268
+
269
+ def make_csv(method_name: str, log_dir: Path | str) -> None:
270
+ log_dir = Path(log_dir) / method_name
271
+ log_dir.mkdir(parents=True, exist_ok=True)
272
+ csv_path = log_dir / "metrics.csv"
273
+ with csv_path.open("w") as f:
274
+ f.write(
275
+ "sampling_percentage, coarse_J, "
276
+ "mse_zero_filled, psnr_zero_filled, ssim_zero_filled, pearson_corr_zero_filled, "
277
+ "mse_recon, psnr_recon, ssim_recon, pearson_corr_recon\n"
278
+ )
279
+
280
+
281
+ # %%
282
+ def run_pcm_demo(
283
+ recon_description: str,
284
+ recon_fn: Callable[[PhotocurrentMapOp, Measurement1D, GrayscaleImage2D], GrayscaleImage2D],
285
+ ground_truth_image: GrayscaleImage2D,
286
+ method_name: str,
287
+ image_name: str,
288
+ J: int, # image size will be 2^J x 2^J
289
+ sampling_ratio: float,
290
+ coarse_J: int,
291
+ measurement_vector: Measurement1D | None = None,
292
+ log_dir: Path | str = ".",
293
+ device: torch.device | str = "cuda:0",
294
+ seed: int = 0,
295
+ ):
296
+ zero_filled_dir = Path(log_dir) / "zero_filled"
297
+ zero_filled_dir.mkdir(parents=True, exist_ok=True)
298
+ masks_dir = Path(log_dir) / "masks"
299
+ masks_dir.mkdir(parents=True, exist_ok=True)
300
+
301
+ log_dir = Path(log_dir) / method_name
302
+ log_dir.mkdir(parents=True, exist_ok=True)
303
+ N = 1 << J
304
+ im_tensor = ground_truth_image.unsqueeze(0).unsqueeze(0) # (1,1,H,W)
305
+
306
+ sampling_percentage = sampling_ratio * 100
307
+ in_order_measurements_percentage = (1 << (2 * coarse_J)) / (N * N) * 100
308
+ print()
309
+ print(f"Sampling rate: {sampling_percentage}%")
310
+ print(f"Coarse levels to keep: {coarse_J} ({in_order_measurements_percentage}%)")
311
+
312
+ rng = np.random.default_rng(seed)
313
+ num_samples = int(sampling_ratio * N * N)
314
+ if randomizing_scheme == "multilevel":
315
+ sampled_indices = multilevel_sample(
316
+ J=J, num_samples=num_samples, coarse_J=coarse_J, alpha=1.0, rng=rng
317
+ )
318
+ elif randomizing_scheme == "uniform":
319
+ sampled_indices = uniform_random_sample(
320
+ J=J, num_samples=num_samples, coarse_J=coarse_J, rng=rng
321
+ )
322
+ else:
323
+ raise ValueError(f"Unknown sampling_scheme {randomizing_scheme}.")
324
+ pcm_op = PhotocurrentMapOp(J=J, sampled_indices=sampled_indices, device=device)
325
+
326
+ if measurement_vector is not None:
327
+ print(f"Using provided measurement vector with shape {measurement_vector.shape}.")
328
+ y_subsampled_tensor_noiseless = measurement_vector[sampled_indices]
329
+ else:
330
+ y_subsampled_tensor_noiseless = pcm_op(im_tensor)
331
+
332
+ y_subsampled_tensor = y_subsampled_tensor_noiseless # No noise
333
+
334
+ # noise_rng = torch.Generator(device=device)
335
+ # noise_rng.manual_seed(noise_seed)
336
+ # homoscedastic_noise = y_subsampled_tensor_noiseless.normal_(
337
+ # mean=0.0, std=noise_std, generator=noise_rng
338
+ # )
339
+ # noise = homoscedastic_noise
340
+ # noise = torch.zeros_like(y_subsampled_tensor_noiseless)
341
+ # assert torch.equal(noise, torch.zeros_like(noise)), "Noise is not zero!"
342
+
343
+ # y_subsampled_tensor = y_subsampled_tensor_noiseless + noise
344
+
345
+ zero_filled_recon_tensor = (
346
+ pcm_op.pseudo_inv(y_subsampled_tensor).unsqueeze(0).unsqueeze(0)
347
+ )
348
+
349
+ recon_tensor = (
350
+ recon_fn(
351
+ pcm_op=pcm_op,
352
+ pcm_measurement=y_subsampled_tensor,
353
+ initial_image=zero_filled_recon_tensor.squeeze(),
354
+ )
355
+ .unsqueeze(0)
356
+ .unsqueeze(0)
357
+ )
358
+
359
+ data_range = (im_tensor.max() - im_tensor.min()).item()
360
+ psnr = PeakSignalNoiseRatio(data_range=data_range).to(device)
361
+ ssim = StructuralSimilarityIndexMeasure(data_range=data_range).to(device)
362
+
363
+ psnr_zero_filled = psnr(zero_filled_recon_tensor, im_tensor)
364
+ psnr_recon = psnr(recon_tensor, im_tensor)
365
+
366
+ ssim_zero_filled = ssim(zero_filled_recon_tensor, im_tensor)
367
+ ssim_recon = ssim(recon_tensor, im_tensor)
368
+
369
+ mse_zero_filled = torch.mean((zero_filled_recon_tensor - im_tensor) ** 2).item()
370
+ mse_recon = torch.mean((recon_tensor - im_tensor) ** 2).item()
371
+
372
+ pearson_corr_zero_filled = torch.corrcoef(torch.stack([zero_filled_recon_tensor.flatten(), im_tensor.flatten()]))[0,1].item()
373
+ pearson_corr_recon = torch.corrcoef(torch.stack([recon_tensor.flatten(), im_tensor.flatten()]))[0,1].item()
374
+
375
+ csv_path = log_dir / "metrics.csv"
376
+ with csv_path.open("a") as f:
377
+ f.write(
378
+ f"{sampling_percentage}, {coarse_J}, "
379
+ f"{mse_zero_filled}, {psnr_zero_filled}, {ssim_zero_filled}, {pearson_corr_zero_filled}, "
380
+ f"{mse_recon}, {psnr_recon}, {ssim_recon}, {pearson_corr_recon}\n"
381
+ )
382
+
383
+ filename = f"{image_name}_{method_name}_sample_{sampling_percentage}_percent_coarse_J={coarse_J}_{randomizing_scheme}_random"
384
+ zero_filled_filename = f"{image_name}_sample_{sampling_percentage}_percent_coarse_J={coarse_J}_{randomizing_scheme}_random"
385
+ recons_dir = log_dir / "recons"
386
+ recons_dir.mkdir(parents=True, exist_ok=True)
387
+ np.save(zero_filled_dir / f"{zero_filled_filename}.npy", zero_filled_recon_tensor.squeeze().cpu().numpy())
388
+ np.save(recons_dir / f"{filename}.npy", recon_tensor.squeeze().cpu().numpy())
389
+
390
+ mask_of_masks_np = np.zeros(N * N, dtype=bool)
391
+ mask_of_masks_np[sampled_indices] = True
392
+ np.save(masks_dir / f"sample_{sampling_percentage}_percent_coarse_J={coarse_J}_{randomizing_scheme}_random.npy", mask_of_masks_np.reshape(N, N))
393
+
394
+ images_dir = log_dir / "images"
395
+ images_dir.mkdir(parents=True, exist_ok=True)
396
+
397
+ show_images_with_inset(
398
+ [im_tensor, zero_filled_recon_tensor, recon_tensor],
399
+ fig_filepath=images_dir / f"{filename}.png",
400
+ plot_helper=plot_helper,
401
+ titles=[
402
+ "Original Image",
403
+ f"Inverse WHT (Zero-filled)\nPSNR: {psnr_zero_filled:.2f} dB, SSIM: {ssim_zero_filled:.4f}\nMSE: {mse_zero_filled:.3e}, Pearson Corr.: {pearson_corr_zero_filled:.4f}",
404
+ f"{recon_description}\nPSNR: {psnr_recon:.2f} dB, SSIM: {ssim_recon:.4f}\nMSE: {mse_recon:.3e}, Pearson Corr.: {pearson_corr_recon:.4f}",
405
+ ],
406
+ suptitle=(
407
+ f"PCM Reconstructions, J={J} ({N}x{N} image)\n"
408
+ + f"Sample {sampling_percentage:.2f}%, keep {coarse_J} coarse levels ({in_order_measurements_percentage}% here), the rest: {randomizing_scheme} random"
409
+ ),
410
+ adds_insets=adds_insets,
411
+ )
412
+
413
+ # %%
414
+ denoiser_DRUNet = deepinv.models.DRUNet(
415
+ pretrained="download", in_channels=1, out_channels=1, device=device
416
+ )
417
+
418
+ def run_pnp_admm(
419
+ pcm_op: PhotocurrentMapOp, pcm_measurement: Measurement1D, initial_image: GrayscaleImage2D
420
+ ) -> GrayscaleImage2D:
421
+ admm_iterations = pnp_admm_iters
422
+ admm_eta = pnp_admm_eta
423
+ cg_max_iter = cg_iters
424
+ _cg_eps = cg_eps
425
+ cg_rel_tol = 0.0
426
+
427
+ # print(
428
+ # f"Running PnP-ADMM reconstruction: {admm_iterations} iterations, cg_max_iter={cg_max_iter}..."
429
+ # )
430
+
431
+ if is_out_of_distribution:
432
+ a = max(R_high - R_low, scale_eps)
433
+
434
+ # pcm_measurement = (pcm_measurement - R_low) / a if is_out_of_distribution else pcm_measurement
435
+
436
+ def denoiser_fn(x: GrayscaleImage2D) -> GrayscaleImage2D:
437
+ with torch.no_grad():
438
+ model_input = (x - R_low) / a if is_out_of_distribution else x
439
+ model_output = (
440
+ denoiser_DRUNet(model_input.unsqueeze(0).unsqueeze(0), sigma=drunet_sigma)
441
+ .squeeze(0)
442
+ .squeeze(0)
443
+ )
444
+ model_output = a * model_output + R_low if is_out_of_distribution else model_output
445
+ return model_output
446
+
447
+ pnp = PnP(physics=pcm_op, prior_fn=denoiser_fn, default_algorithm="ADMM")
448
+ recon = pnp.admm_algorithm(
449
+ measurement=pcm_measurement,
450
+ eta=admm_eta,
451
+ max_iter=admm_iterations,
452
+ cg_max_iter=cg_max_iter,
453
+ cg_eps=_cg_eps,
454
+ cg_rel_tol=cg_rel_tol,
455
+ prog_bar=tqdm,
456
+ # cg_prog_bar=tqdm,
457
+ )
458
+ # recon = pnp.forward_backward_splitting(
459
+ # sino=pcm_measurement,
460
+ # )
461
+
462
+ return recon
463
+ # return a * recon + R_low if is_out_of_distribution else recon
464
+
465
+
466
+
467
+
468
+ # %%
469
+ def run_fista_l1(
470
+ pcm_op: PhotocurrentMapOp, pcm_measurement: Measurement1D, initial_image: GrayscaleImage2D
471
+ ) -> GrayscaleImage2D:
472
+
473
+ lam = 10 # Good for Daubechies 4 wavelet transform
474
+ # max_iter = 300
475
+ max_iter = 100
476
+ tol = 1e-5
477
+
478
+ debias_max_iter = 10
479
+ debias_support_tol = 1e-5
480
+ debias_tol = 1e-7
481
+
482
+ height, width = pcm_op.domain_shape
483
+ # Wavelet transform Psi
484
+ wavelet = Wavelet2D((height, width), wavelet_name="db4", device=device)
485
+ # Composite operator A = Phi Psi^{-1}
486
+ A_op = CompositeOp(wavelet, pcm_op, device=device)
487
+
488
+ # print("Running FISTA reconstruction: " f"{max_iter} iterations, lambda={lam}...")
489
+ w_hat = fista_l1(
490
+ op=A_op,
491
+ y=pcm_measurement,
492
+ lam=lam,
493
+ max_iter=max_iter,
494
+ tol=tol,
495
+ L=None,
496
+ verbose=False,
497
+ prog_bar=tqdm,
498
+ )
499
+
500
+ # Optional debiasing
501
+ # print(f"Running debiasing: {debias_max_iter} iterations...")
502
+ w_debias = debias_ls(
503
+ op=A_op,
504
+ y=pcm_measurement,
505
+ w=w_hat,
506
+ support_tol=debias_support_tol,
507
+ max_iter=debias_max_iter,
508
+ tol=debias_tol,
509
+ prog_bar=tqdm,
510
+ )
511
+
512
+ # Current map reconstruction
513
+ cs_result_tensor = wavelet.inverse(w_debias)
514
+
515
+ return cs_result_tensor
516
+
517
+
518
+
519
+ # %%
520
+ def run_spgl1(
521
+ pcm_op: PhotocurrentMapOp, pcm_measurement: Measurement1D, initial_image: GrayscaleImage2D
522
+ ) -> GrayscaleImage2D:
523
+
524
+ # max_iter = 1000
525
+ # max_iter = 200
526
+ max_iter = 100
527
+ # opt_tol = 1e-4
528
+ # bp_tol = 1e-6
529
+ # opt_tol = 1e-5
530
+ # bp_tol = 1e-7
531
+
532
+ debias_max_iter = 10
533
+ # debias_max_iter = 100
534
+ debias_support_tol = 1e-5
535
+ # debias_support_tol = 1e-6
536
+ # debias_support_tol = 1e-7
537
+ debias_tol = 1e-7
538
+
539
+ height, width = pcm_op.domain_shape
540
+ # Wavelet transform Psi
541
+ wavelet = Wavelet2D((height, width), wavelet_name="db4", device=device)
542
+ # Composite operator A = Phi Psi^{-1}
543
+ A_op = CompositeOp(wavelet, pcm_op, device=device)
544
+
545
+ # rhs_l2_norm = torch.linalg.norm(pcm_measurement).item()
546
+ # # relative_feasibility_tolerance = 1e-6
547
+ # relative_feasibility_tolerance = 1e-9
548
+ # absolute_feasibility_tolerance = relative_feasibility_tolerance * rhs_l2_norm
549
+
550
+ pcm_measurement = pcm_measurement * factor # scale up
551
+
552
+ # print("Running SPGL1 reconstruction: " f"{max_iter} iterations ...")
553
+ w_hat, _ = spgl1_torch(
554
+ op=A_op,
555
+ y=pcm_measurement,
556
+ iter_lim=max_iter,
557
+ # opt_tol=absolute_feasibility_tolerance,
558
+ # bp_tol=relative_feasibility_tolerance,
559
+ verbosity=0,
560
+ # opt_tol=opt_tol,
561
+ # bp_tol=bp_tol,
562
+ )
563
+ # Optional debiasing
564
+ # print(f"Running debiasing: {debias_max_iter} iterations...")
565
+ w_debias = debias_ls(
566
+ op=A_op,
567
+ y=pcm_measurement,
568
+ w=w_hat,
569
+ support_tol=debias_support_tol,
570
+ max_iter=debias_max_iter,
571
+ tol=debias_tol,
572
+ prog_bar=tqdm,
573
+ )
574
+
575
+ # Current map reconstruction
576
+ cs_result_tensor = wavelet.inverse(w_debias)
577
+
578
+ cs_result_tensor = cs_result_tensor / factor # scale back down
579
+
580
+ return cs_result_tensor
581
+
582
+
583
+ def make_test_cases() -> list[tuple[float, int]]:
584
+ min_coarse_J = 0
585
+ # min_coarse_J = 5
586
+ # min_coarse_J = J_order - 3 # keep 1.5625% of in-order measurements at least
587
+ # (sampling_ratio, coarse_J)
588
+ test_cases = []
589
+ num_pixels = 1 << (2 * J_order) # N*N
590
+ # for sampling_ in range(0, 9, 1):
591
+ # sampling_ratio = (sampling_ + 1) / 100.0 # from 0.01 to 0.09
592
+ # num_samples = int(sampling_ratio * num_pixels)
593
+ # for coarse_J in range(min_coarse_J, J_order): # from 0 to J_order-1 (not including J_order because that is 100% sampling)
594
+ # if coarse_J > 0:
595
+ # prev_num_coarse_samples = 1 << (2 * (coarse_J - 1))
596
+ # if prev_num_coarse_samples >= num_samples:
597
+ # continue
598
+ # test_cases.append((sampling_ratio, coarse_J))
599
+ for sampling_ in range(1, 10, 1):
600
+ sampling_ratio = sampling_ / 10.0 # from 0.1 to 0.9
601
+ test_cases.append((sampling_ratio, J_order - 2)) # keep the first J-2 coarse levels, i.e. 6.25% in-order measurements
602
+ num_samples = int(sampling_ratio * num_pixels)
603
+ # for coarse_J in range(min_coarse_J, J_order): # from 0 to J_order-1 (not including J_order because that is 100% sampling)
604
+ # if coarse_J > 0:
605
+ # prev_num_coarse_samples = 1 << (2 * (coarse_J - 1))
606
+ # if prev_num_coarse_samples >= num_samples:
607
+ # continue
608
+ # test_cases.append((sampling_ratio, coarse_J))
609
+ test_cases.append((1.0, J_order)) # 100% sampling
610
+
611
+ # # sampling_ratios = [0.1]
612
+ # sampling_ratios = [0.2]
613
+ # # # sampling_ratios = [0.25]
614
+ # # sampling_ratios = [0.5]
615
+ # # # sampling_ratios = [0.7]
616
+ # # # coarse_Js = [5] # keep 2^{coarse_J} x 2^{coarse_J} in-order measurements
617
+ # # # coarse_Js = [7] # keep 2^{coarse_J} x 2^{coarse_J} in-order measurements
618
+ # coarse_Js = list(range(0, J_order))
619
+ # test_cases = []
620
+ # test_cases += [
621
+ # (sampling_ratio, coarse_J)
622
+ # for sampling_ratio in sampling_ratios
623
+ # for coarse_J in coarse_Js
624
+ # ]
625
+ # test_cases = [
626
+ # # (0.3, 3),
627
+ # # (0.2, 2),
628
+ # (0.2, 6),
629
+ # # (0.2, 8),
630
+ # # (0.2, 7),
631
+ # # (0.5, 6),
632
+ # # (0.8, 6),
633
+ # # (1.0, 6),
634
+ # # (1.0, 7),
635
+ # # (0.1, 8),
636
+ # ]
637
+
638
+ # test_cases = test_cases[80:]
639
+
640
+ test_cases.reverse()
641
+
642
+ return test_cases
643
+
644
+
645
+ def run_experiments():
646
+ raw_data: GrayscaleImage2D | Measurement1D = np.load(data_dir / data_filename)
647
+ print(f"Raw data shape: {raw_data.shape}")
648
+ print(f"J_order: {J_order}")
649
+
650
+ if data_type == "image":
651
+ ground_truth_image: GrayscaleImage2D = torch.tensor(raw_data, dtype=torch.float32, device=device)
652
+ if inverses_sign:
653
+ ground_truth_image = -ground_truth_image
654
+ J_data = int(np.log2(ground_truth_image.shape[0]))
655
+ assert J_data == J_order, f"Data J ({J_data}) does not match expected J_order ({J_order})."
656
+ print(f"Ground truth image shape: {ground_truth_image.shape}")
657
+ measurement_vector = None
658
+ elif data_type == "hadamard_measurement_vector":
659
+ # Reconstruct the image from the Hadamard measurement vector
660
+ J_data = int(np.log2(raw_data.shape[0]) / 2)
661
+ assert J_data == J_order, f"Data J ({J_data}) does not match expected J_order ({J_order})."
662
+ measurement_vector = torch.tensor(raw_data, dtype=torch.float32, device=device)
663
+ if inverses_sign:
664
+ measurement_vector = -measurement_vector
665
+
666
+ index_of_max = torch.argmax(measurement_vector).item()
667
+ index_of_min = torch.argmin(measurement_vector).item()
668
+ print(f"Max value in measurement vector: {measurement_vector[index_of_max].item()} at index {index_of_max}")
669
+ print(f"Min value in measurement vector: {measurement_vector[index_of_min].item()} at index {index_of_min}")
670
+ exit()
671
+
672
+ pcm_op_full = PhotocurrentMapOp(J=J_order, device=device)
673
+ with torch.no_grad():
674
+ ground_truth_image = pcm_op_full.pseudo_inv(measurement_vector)
675
+ print(f"Reconstructed ground truth image shape from Hadamard measurement vector: {ground_truth_image.shape}")
676
+
677
+ elif data_type == "original_measurement_data":
678
+ # Make a 1D array with num_lines//2 elements,
679
+ # where each element is the sum of the measured current multiplied by the pattern index sign.
680
+ num_measurements = raw_data.shape[0]
681
+ assert num_measurements % 2 == 0, "Number of measurements should be even."
682
+
683
+ if inverses_sign:
684
+ raw_data[:, 1] = -raw_data[:, 1]
685
+
686
+ index_of_max_raw = np.argmax(raw_data[:, 1])
687
+ index_of_min_raw = np.argmin(raw_data[:, 1])
688
+ min_raw_value = raw_data[index_of_min_raw, 1]
689
+ max_raw_value = raw_data[index_of_max_raw, 1]
690
+ print(f"Max value in original measurement data: {max_raw_value} at index {index_of_max_raw}")
691
+ print(f"Min value in original measurement data: {min_raw_value} at index {index_of_min_raw}")
692
+ # exit()
693
+
694
+ sign_vector = np.round(np.sign(raw_data[:, 0]))
695
+ sign_vector[:2] = [1.0, -1.0] # Ensure the first two patterns are +0 and -0
696
+
697
+ measurement_vector = torch.tensor((raw_data[:, 1] * sign_vector).reshape(-1, 2).sum(axis=1), dtype=torch.float32, device=device)
698
+
699
+ # index_of_max = torch.argmax(measurement_vector).item()
700
+ # index_of_min = torch.argmin(measurement_vector).item()
701
+ # min_value = measurement_vector[index_of_min].item()
702
+ # max_value = measurement_vector[index_of_max].item()
703
+ # print(f"Max value in measurement vector: {max_value} at index {index_of_max}")
704
+ # print(f"Min value in measurement vector: {min_value} at index {index_of_min}")
705
+ # exit()
706
+
707
+ pcm_op_full = PhotocurrentMapOp(J=J_order, device=device)
708
+ print(f"pcm_op_full domain shape: {pcm_op_full.domain_shape}, range shape: {pcm_op_full.range_shape}")
709
+ with torch.no_grad():
710
+ ground_truth_image = pcm_op_full.pseudo_inv(measurement_vector)
711
+ print(f"Reconstructed ground truth image shape from original measurement data: {ground_truth_image.shape}")
712
+
713
+ if tests_scale_ground_truth:
714
+ gt_min, gt_max = ground_truth_image.min().item(), ground_truth_image.max().item()
715
+ ground_truth_image = (ground_truth_image - gt_min) / (gt_max - gt_min)
716
+ print(f"Normalized ground truth image to [0, 1]. Min: {ground_truth_image.min().item()}, Max: {ground_truth_image.max().item()}")
717
+ measurement_vector = None
718
+
719
+ test_cases = make_test_cases()
720
+ # print(f"Total number of test cases: {len(test_cases)}")
721
+ # print(test_cases)
722
+ # for sampling_ratio, coarse_J in test_cases:
723
+ # sampling_percentage = sampling_ratio * 100
724
+ # coarse_percentage = (1<<(2*coarse_J))/(1<<(2*J_order))*100
725
+ # print(f"Sampling: {sampling_percentage}%, coarse_J: {coarse_J} ({coarse_percentage}%)")
726
+ # assert sampling_percentage >= coarse_percentage, (
727
+ # "Sampling percentage must be larger than or equal to coarse percentage. "
728
+ # f"Got sampling {sampling_percentage}% and coarse {coarse_percentage}%."
729
+ # )
730
+ # return
731
+
732
+ # ### Set a directory to save logs and results
733
+ #
734
+ # Each run is stored in a separate subdirectory named with the current date and
735
+ # time, which makes it easier to keep track of different experiments.
736
+
737
+ current_datetime_str = datetime.now().strftime("%Y%m%d_%H%M%S")
738
+ experiment_log_dir = Path("pcm_demo_output") / f"{current_datetime_str}_{data_name}_{randomizing_scheme}_noise_{noise_std}"
739
+ experiment_log_dir.mkdir(parents=True, exist_ok=True)
740
+
741
+ for i_seed in range(num_trials):
742
+ log_dir = experiment_log_dir / f"trial_{i_seed}"
743
+ log_dir.mkdir(parents=True, exist_ok=True)
744
+
745
+ # %% [markdown]
746
+ # ## First experiment: PnP-ADMM
747
+ #
748
+ # In this section the PCM PnP-ADMM algorithm is tested on the CIGS data.
749
+
750
+ # %% [markdown]
751
+ # Define the prior function using a pre-trained DRUNet denoiser and the
752
+ # corresponding Plug-and-Play ADMM solver.
753
+ #
754
+ # DRUNet is a deep convolutional denoiser proposed by:
755
+ #
756
+ # > Kai Zhang, Yawei Li, Wangmeng Zuo, Lei Zhang, Luc Van Gool, and
757
+ # > Radu Timofte, "Plug-and-Play Image Restoration with Deep Denoiser Prior,"
758
+ # > IEEE Transactions on Pattern Analysis and Machine Intelligence, 44(10),
759
+ # > 6360–6376, 2022.
760
+ #
761
+ # In the PnP-ADMM framework, the proximal step of a regulariser is replaced by
762
+ # an off-the-shelf denoiser. Here DRUNet acts as a powerful learned prior for
763
+ # the PCM inverse problem, while the data fidelity term is handled by ADMM.
764
+
765
+ # %%
766
+ if runs_pnp_admm:
767
+ method_name = f"pnp_admm_iters={pnp_admm_iters}_eta={pnp_admm_eta}_cg_iters={cg_iters}_drunet_sigma={drunet_sigma}"
768
+ make_csv(method_name=method_name, log_dir=log_dir)
769
+ # for delta_divided_by, subtract_from_J in tqdm(test_cases, desc="Running PnP-ADMM experiments"):
770
+ for sampling_ratio, coarse_J in tqdm(test_cases, desc="Running PnP-ADMM experiments"):
771
+ run_pcm_demo(
772
+ recon_description=f"PnP-ADMM ({pnp_admm_iters} iters, η={pnp_admm_eta}, cg_iters={cg_iters}, σ={drunet_sigma})",
773
+ recon_fn=run_pnp_admm,
774
+ ground_truth_image=ground_truth_image,
775
+ method_name=method_name,
776
+ image_name=data_name,
777
+ J=J_order, # image size is 2^J x 2^J
778
+ sampling_ratio=sampling_ratio,
779
+ coarse_J=coarse_J,
780
+ log_dir=log_dir,
781
+ device=device,
782
+ seed=i_seed,
783
+ )
784
+
785
+
786
+ # %% [markdown]
787
+ # The code above runs the PnP-ADMM reconstruction and compares it to the
788
+ # zero-filled pseudo-inverse.
789
+ #
790
+ # Although PnP-ADMM substantially improves PSNR and SSIM, it can smooth out
791
+ # fine-scale structures. In the context of defect detection, these small
792
+ # features can be crucial, so high PSNR and SSIM alone are not sufficient to
793
+ # guarantee that the reconstruction is fit for purpose.
794
+ #
795
+ # In the next sections, two compressed sensing baselines with a wavelet
796
+ # sparsity prior are explored and compared to the PnP-ADMM result.
797
+
798
+
799
+ # %% [markdown]
800
+ # ## Compressed sensing baseline: FISTA with wavelet sparsity
801
+ #
802
+ # This section applies FISTA with an $\ell_1$-penalty on wavelet coefficients
803
+ # as a classical compressed sensing baseline.
804
+ #
805
+ # Let $\Phi$ denote the PCM forward operator and $\Psi$ a 2D wavelet
806
+ # transform with inverse $\Psi^{-1}$. The composite operator
807
+ # $A = \Phi \Psi^{-1}$ acts on wavelet coefficients $w$.
808
+ # FISTA approximately solves the standard $\ell_1$-regularised problem
809
+ #
810
+ # $$
811
+ # \min_w \frac{1}{2} \lVert A w - y \rVert_2^2
812
+ # + \lambda \lVert w \rVert_1,
813
+ # $$
814
+ #
815
+ # and the final current map is obtained as $x = \Psi^{-1} w$.
816
+ #
817
+ # An optional debiasing step is included at the end to reduce the bias induced
818
+ # by the $\ell_1$ penalty on the active support.
819
+
820
+ # %%
821
+ if runs_fista_l1:
822
+ make_csv(method_name="fista_l1", log_dir=log_dir)
823
+ for sampling_ratio, coarse_J in tqdm(test_cases, desc="Running FISTA-L1 experiments"):
824
+ run_pcm_demo(
825
+ recon_description="FISTA-L1",
826
+ recon_fn=run_fista_l1,
827
+ ground_truth_image=ground_truth_image,
828
+ method_name="fista_l1",
829
+ image_name=data_name,
830
+ J=J_order, # image size is 2^J x 2^J
831
+ sampling_ratio=sampling_ratio,
832
+ coarse_J=coarse_J,
833
+ log_dir=log_dir,
834
+ device=device,
835
+ seed=i_seed,
836
+ )
837
+
838
+ # %% [markdown]
839
+ # ## Compressed sensing baseline: SPGL1 with wavelet sparsity
840
+ #
841
+ # This section applies the SPGL1 algorithm as a second compressed sensing
842
+ # baseline, again using a wavelet sparsity prior in the same setting
843
+ # $A = \Phi \Psi^{-1}$.
844
+ #
845
+ # SPGL1 is a spectral projected gradient method that efficiently solves
846
+ # large-scale $\ell_1$-regularised problems and basis pursuit denoising
847
+ # formulations. In this example it is run with default parameters suitable
848
+ # for the PCM problem size, followed by the same optional debiasing step
849
+ # used for FISTA.
850
+
851
+ # %%
852
+ if runs_spgl1:
853
+ method_name = f"spgl1_factor={factor}"
854
+ make_csv(method_name=method_name, log_dir=log_dir)
855
+ for sampling_ratio, coarse_J in tqdm(test_cases, desc="Running SPGL1 experiments"):
856
+ run_pcm_demo(
857
+ recon_description="SPGL1",
858
+ recon_fn=run_spgl1,
859
+ ground_truth_image=ground_truth_image,
860
+ method_name=method_name,
861
+ image_name=data_name,
862
+ J=J_order, # image size is 2^J x 2^J
863
+ sampling_ratio=sampling_ratio,
864
+ coarse_J=coarse_J,
865
+ log_dir=log_dir,
866
+ device=device,
867
+ seed=i_seed,
868
+ )
869
+
870
+ if __name__ == "__main__":
871
+ run_experiments()
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/psnr_boxplot.png ADDED

Git LFS Details

  • SHA256: c04ea09c4fca7006d44986274ef1ce0a71c7b7e17053fa3597340853d60ed2cb
  • Pointer size: 130 Bytes
  • Size of remote file: 34.8 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/summary_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05.csv ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ sampling_percentage,coarse_J,mse_zero_filled_mean,psnr_zero_filled_mean,ssim_zero_filled_mean,pearson_corr_zero_filled_mean,mse_recon_mean,psnr_recon_mean,ssim_recon_mean,pearson_corr_recon_mean,mse_zero_filled_std,psnr_zero_filled_std,ssim_zero_filled_std,pearson_corr_zero_filled_std,mse_recon_std,psnr_recon_std,ssim_recon_std,pearson_corr_recon_std,n
2
+ 10,6,0.0049759672954678095,22.48213424682617,0.6290407836437225,0.9860986828804016,0.00068388120562298,31.326403045654295,0.9226931035518646,0.998099946975708,0.0001334869548734993,0.11954087737522925,0.040482560378647815,0.00037535374606735843,0.00024743334582817873,1.4450850238028683,0.038343685511234085,0.0006880985400152409,10
3
+ 20,6,0.00414979080669577,23.272941207885744,0.4908105283975601,0.9884199321269989,3.736910002771765e-05,43.76534767150879,0.9915925979614257,0.9998947501182556,0.00017995006083698406,0.19117723189238536,0.016988837543490478,0.0005050089409869903,5.26917221123449e-06,0.6382947880810018,0.0010097827541688418,1.4636330175208455e-05,10
4
+ 30,6,0.00337826858740293,24.173873329162596,0.4605019748210907,0.9905827283859253,1.4808035211899551e-05,47.76597633361816,0.9947864532470703,0.9999573409557343,0.0002544632506834412,0.33319337387712306,0.008652161075445825,0.0007124260770298549,1.5430711834349293e-06,0.45737350408385674,0.000353138461159788,4.289054779693723e-06,10
5
+ 40,6,0.00261802936438466,25.276904678344728,0.46965573728084564,0.9927094936370849,5.43189621566853e-06,52.11592559814453,0.9974614560604096,0.999983286857605,0.0001601423253399916,0.26251023898933773,0.011891411554004583,0.00044752725854232863,5.041030148243606e-07,0.3880173759435062,0.00017081728037700975,1.37742767610928e-06,10
6
+ 50,6,0.0018839083379134,26.71017990112305,0.5153935074806213,0.9947586834430695,2.4894396574381973e-06,55.49063224792481,0.9985484659671784,0.9999914765357971,0.00014345923711246505,0.33051160241510136,0.021438289714365198,0.00040005630932965524,8.356798637053078e-08,0.14555895163318217,5.81119851292609e-05,2.513152488376167e-07,10
7
+ 60,6,0.00120721720159049,28.641771125793458,0.6379795670509338,0.9966439545154572,1.7714949194669316e-06,56.966866683959964,0.9988732814788819,0.9999934911727906,8.828467335205342e-05,0.31121838658500806,0.017374918232624242,0.00024570614125845035,3.6147915568120724e-08,0.08874574508008383,2.4458035651776858e-05,1.2182958695427842e-07,10
8
+ 70,6,0.00088552435045125,29.989383888244628,0.7051267683506012,0.9975389301776886,1.2405802522152954e-06,58.51508483886719,0.9991774380207061,0.9999949216842652,6.884015293174226e-05,0.34027589778578254,0.006800215019458208,0.0001914280401297259,3.863168466148024e-08,0.1346385224435547,1.9429571199971013e-05,1.3416562887953075e-07,10
9
+ 80,6,0.00069843325181859,31.024864196777344,0.7208002269268036,0.9980590283870697,9.065601318525296e-07,59.882506942749025,0.9993553817272186,0.9999959170818329,6.324654461380915e-05,0.405054501679867,0.009387762531789917,0.00017577032217173575,5.476638434687708e-08,0.25934941033906045,4.006336198191913e-05,1.9108637235241472e-07,10
10
+ 90,6,0.0005046906095230299,32.44403972625732,0.7545597136020661,0.998597401380539,8.948798608798825e-07,60.05365982055664,0.9992615878582001,0.9999959111213684,5.6561818340565304e-05,0.4911829742603853,0.01358906877343157,0.00015713353303116692,2.2996127392738865e-07,1.0706437431828937,0.00022114034787565424,6.445391010924842e-07,10
11
+ 100,8,5.5434867444028105e-15,142.01162719726562,0.9999699592590332,1.0,1.3440617863125226e-07,68.16525268554688,0.999876856803894,0.9999980330467224,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,10
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_10.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f40e9d914a2fd9011ba0ebe573f299553b2d5ff9c012cffa633b21062cd56c7
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_100.0_percent_coarse_J=8_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:72bf42bd9c376d68820d774b6ce353f9fd4f71523379d25ad5aca0af4510e04e
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_20.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:862a011c0dbae6ec44d8c074965bac103a2e58526e86d669efaa974aee782ca2
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_30.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c9e12949d875f345b1831f64fe7baf1c24739a1a332b3e01a7f57b15b71ce62
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_40.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca121db1ff5b46a7d75f229c12995a969eda6d6a200c202297ee1bba871d54d4
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_50.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5a62d8e12ff59c7cf15b99fb672fba59620860af968c5e548b04d41fd4d8ab8
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_60.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2edfc78a02cab69e60145d5bc281c58f9cdb3f3fa6b4657b9f6a75189b502be6
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_70.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb30bf2a5f405188668385d2cab853dacd881fc9a8404a6ec4592f2dea8bfe16
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_80.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b6945689e9b3b88461e96c1e2ce76519b9caf86a69e0f2b986db5fbd15e42e2
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/masks/sample_90.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb9127ade788d2790f72a95c27f5ece1069d463645e2c221521e043e0883d580
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_10.0_percent_coarse_J=6_multilevel_random.png ADDED

Git LFS Details

  • SHA256: 098ba913acc06442f4fff8664decbc6ad119deae50756e7a1b873cbd9c21608b
  • Pointer size: 131 Bytes
  • Size of remote file: 338 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_100.0_percent_coarse_J=8_multilevel_random.png ADDED

Git LFS Details

  • SHA256: 1e816357e7b391507f6f5ca462d30e5fd5395b21114c2070528bc0389ddfdeb7
  • Pointer size: 131 Bytes
  • Size of remote file: 183 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=6_multilevel_random.png ADDED

Git LFS Details

  • SHA256: 5f95deaf41434209a765c6c1d44f47bb9a139c978ed957cee73e22c2b4591165
  • Pointer size: 131 Bytes
  • Size of remote file: 365 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_30.0_percent_coarse_J=6_multilevel_random.png ADDED

Git LFS Details

  • SHA256: 1b267f46f531bc33200bb9ad3dd9d99a8371faf708345edfce0424e61e8809f8
  • Pointer size: 131 Bytes
  • Size of remote file: 375 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_40.0_percent_coarse_J=6_multilevel_random.png ADDED

Git LFS Details

  • SHA256: f9a9e39aa5bb4c378be50399dd1bb19f73f4310cd52269577ff43918570c1b2d
  • Pointer size: 131 Bytes
  • Size of remote file: 375 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=6_multilevel_random.png ADDED

Git LFS Details

  • SHA256: a879b457141901407541374abdc8c3fdb1758d870b4d0540ee50058e9392d81d
  • Pointer size: 131 Bytes
  • Size of remote file: 373 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_60.0_percent_coarse_J=6_multilevel_random.png ADDED

Git LFS Details

  • SHA256: c2cfba2f5c074924b8def28c536fb7c1dd31815f02ff49a903b227c5e1c499da
  • Pointer size: 131 Bytes
  • Size of remote file: 366 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_70.0_percent_coarse_J=6_multilevel_random.png ADDED

Git LFS Details

  • SHA256: 0f08c93ffbd9ca6ef36d5abc0b41e7c93c8808448a9495da776a33b7c373d259
  • Pointer size: 131 Bytes
  • Size of remote file: 360 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=6_multilevel_random.png ADDED

Git LFS Details

  • SHA256: ee8294e8939823b3041f8ef9babe37d34a95abfd6873a0d277fd977f5c8395b8
  • Pointer size: 131 Bytes
  • Size of remote file: 355 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_90.0_percent_coarse_J=6_multilevel_random.png ADDED

Git LFS Details

  • SHA256: ff16a068c32562e6553913ba6eb8f618b7eeb34cbfd57949380a61a494edd7d7
  • Pointer size: 131 Bytes
  • Size of remote file: 347 kB
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/metrics.csv ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ sampling_percentage, coarse_J, mse_zero_filled, psnr_zero_filled, ssim_zero_filled, pearson_corr_zero_filled, mse_recon, psnr_recon, ssim_recon, pearson_corr_recon
2
+ 100.0, 8, 5.5434867444028105e-15, 142.01162719726562, 0.9999699592590332, 1.0, 1.3440617863125226e-07, 68.16525268554688, 0.999876856803894, 0.9999980330467224
3
+ 90.0, 6, 0.0005947189056314528, 31.706335067749023, 0.7411805391311646, 0.9983473420143127, 7.726030162302777e-07, 60.56988525390625, 0.9993786811828613, 0.9999961853027344
4
+ 80.0, 6, 0.0007423167116940022, 30.743562698364258, 0.7192955017089844, 0.9979370832443237, 8.877104846760631e-07, 59.96673583984375, 0.9993798732757568, 0.9999960660934448
5
+ 70.0, 6, 0.000969039392657578, 29.58603858947754, 0.7001399397850037, 0.9973066449165344, 1.2699781564151635e-06, 58.4114875793457, 0.9991625547409058, 0.9999947547912598
6
+ 60.0, 6, 0.0013428681995719671, 28.169118881225586, 0.6457928419113159, 0.9962664246559143, 1.7789141111279605e-06, 56.94790267944336, 0.9988555908203125, 0.9999935626983643
7
+ 50.0, 6, 0.0020655118860304356, 26.299177169799805, 0.49415600299835205, 0.9942521452903748, 2.4656380901433295e-06, 55.53015899658203, 0.9985977411270142, 0.9999914765357971
8
+ 40.0, 6, 0.0025214313063770533, 25.4329833984375, 0.4655645191669464, 0.9929794073104858, 5.029258318245411e-06, 52.43441390991211, 0.9975652694702148, 0.9999844431877136
9
+ 30.0, 6, 0.0033273231238126755, 24.228506088256836, 0.46951091289520264, 0.9907255172729492, 1.3472606042341795e-05, 48.15493392944336, 0.9951256513595581, 0.9999611377716064
10
+ 20.0, 6, 0.004250198602676392, 23.165361404418945, 0.48277127742767334, 0.9881381392478943, 3.711112367454916e-05, 43.75440979003906, 0.9918062686920166, 0.999895453453064
11
+ 10.0, 6, 0.004978986456990242, 22.478044509887695, 0.6115691065788269, 0.9860903024673462, 0.0003886528720613569, 33.553836822509766, 0.9659581184387207, 0.9989197850227356
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_10.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:673eea7e5433ba32bd7233c34f641682103e6c21a682bf15e1a59565bffa08a3
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_100.0_percent_coarse_J=8_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06b6e2623e205797687f067e016cbeca0b213f167432cf1367129cab659fdcb9
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de9057d2715bcd8af138aab2c25ed4e288559a3f7a7a9fd04012dcb5db0dabf9
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_30.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38bd234a6da241d6fe22833f9e9988f256f4bc060627b8eb72926cb5e387d41b
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_40.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76746c8d36a98dea340c2c5ee01fa247a11a50c9bca4e6db60127bcec7a35d51
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25ddc2ce3605869cf9ef917d37488136d4aa2f85425091c1701652288b438b66
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_60.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d629b81688b83649de9e2c5a488c87ed833c2c49730a2a5d3dab9b3102f8013
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_70.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57968e2771fb7562e0b5516af3cba4adc782747bc573f482c8c80b55ed2f99e5
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e8e37a81ec2a08cc091c775892d9a925e3b0bc48d189b99e6290f100956efd61
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_CIGS_256x256_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_90.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c7a57d7afbf2f6ce6c91c3e34561206b98b5bc4ecf2093834147325a2a68d65
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_10.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc00c123150f8da9acaf30e02ec4943c02d5599430609764fd5ba4e522c093c5
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_100.0_percent_coarse_J=8_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:092b720a766faf9985f8afc7f8c5f2298d56bdc14e91ad337c304cdf4ee157fc
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_20.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c2e0b6faa832a8edadd8d7c78b4ee71c2fc5512a7aca030debed1b2deef69d7
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_30.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76b3143c891db8b416d784170cef3dff0ac931829bd2425481eb67b5bad861bb
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_40.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:074ac4eda96127850b6257906c4c1ca7d59866717dfc0c76022aabb1ee2d313e
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_50.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f590919feae93ab35b63a2f2e7c7630146cbc26e2db32197886408844958628a
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_60.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:604cab7aa3245d92edb0bb7b462ef2e4d4decbcf7bb1a4097044d5c9ff39df0d
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_70.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cd6836ae1f76ecec56c1b7574c0959dbfda2da09cd6b176ca9aae5fb905906c
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_80.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1892dcd97736a744e540c1c7507eb1555ae8c98c3c1de894b3b77fdbb3fff676
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_0/zero_filled/example_CIGS_256x256_sample_90.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b63a0791f960f2003815516f5329da435d34becc949af106385bfada6e0860c1
3
+ size 262272
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_10.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:602382ad70edc1592c771439d4a28c41a57d9099f4fa8a244031b2d557a6499f
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_100.0_percent_coarse_J=8_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:72bf42bd9c376d68820d774b6ce353f9fd4f71523379d25ad5aca0af4510e04e
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_20.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee3a2cc4b13700c3b5743172482da06089d5baafd7da779ab4391745c0871cbd
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_30.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e0eff99d55207df9c27ad9aac91702eb5b84c35797b5a690ccb209ee154a37b
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_40.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:51aff1edad8ae8f44e2e8ce50c9ffa84f336cefa879f27c303a0fa3d0be4d3ee
3
+ size 65664
20260116_053534_example_CIGS_256x256_multilevel_20_trials_pnp/trial_1/masks/sample_50.0_percent_coarse_J=6_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00addfb98d89919938beb8afa30efcd8119c50531df9a811df82295ca7649863
3
+ size 65664