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

silicon 512x512 uniform 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. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/masks/sample_100.0_percent_coarse_J=9_uniform_random.npy +3 -0
  2. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/masks/sample_20.0_percent_coarse_J=7_uniform_random.npy +3 -0
  3. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/masks/sample_50.0_percent_coarse_J=7_uniform_random.npy +3 -0
  4. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/masks/sample_80.0_percent_coarse_J=7_uniform_random.npy +3 -0
  5. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_100.0_percent_coarse_J=9_uniform_random.png +3 -0
  6. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=7_uniform_random.png +3 -0
  7. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=7_uniform_random.png +3 -0
  8. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=7_uniform_random.png +3 -0
  9. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/metrics.csv +4 -0
  10. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_100.0_percent_coarse_J=9_uniform_random.npy +3 -0
  11. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=7_uniform_random.npy +3 -0
  12. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=7_uniform_random.npy +3 -0
  13. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=7_uniform_random.npy +3 -0
  14. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_100.0_percent_coarse_J=9_uniform_random.png +3 -0
  15. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_20.0_percent_coarse_J=7_uniform_random.png +3 -0
  16. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_50.0_percent_coarse_J=7_uniform_random.png +3 -0
  17. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_80.0_percent_coarse_J=7_uniform_random.png +3 -0
  18. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/metrics.csv +4 -0
  19. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_100.0_percent_coarse_J=9_uniform_random.npy +3 -0
  20. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_20.0_percent_coarse_J=7_uniform_random.npy +3 -0
  21. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_50.0_percent_coarse_J=7_uniform_random.npy +3 -0
  22. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_80.0_percent_coarse_J=7_uniform_random.npy +3 -0
  23. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/zero_filled/example_silicon_512x512_sample_100.0_percent_coarse_J=9_uniform_random.npy +3 -0
  24. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/zero_filled/example_silicon_512x512_sample_20.0_percent_coarse_J=7_uniform_random.npy +3 -0
  25. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/zero_filled/example_silicon_512x512_sample_50.0_percent_coarse_J=7_uniform_random.npy +3 -0
  26. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/zero_filled/example_silicon_512x512_sample_80.0_percent_coarse_J=7_uniform_random.npy +3 -0
  27. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/masks/sample_20.0_percent_coarse_J=7_uniform_random.npy +3 -0
  28. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/masks/sample_50.0_percent_coarse_J=7_uniform_random.npy +3 -0
  29. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/masks/sample_80.0_percent_coarse_J=7_uniform_random.npy +3 -0
  30. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/photocurrent_mapping copy.py +881 -0
  31. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=7_uniform_random.png +3 -0
  32. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=7_uniform_random.png +3 -0
  33. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=7_uniform_random.png +3 -0
  34. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/metrics.csv +4 -0
  35. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=7_uniform_random.npy +3 -0
  36. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=7_uniform_random.npy +3 -0
  37. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=7_uniform_random.npy +3 -0
  38. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_20.0_percent_coarse_J=7_uniform_random.png +3 -0
  39. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_50.0_percent_coarse_J=7_uniform_random.png +3 -0
  40. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_80.0_percent_coarse_J=7_uniform_random.png +3 -0
  41. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/metrics.csv +4 -0
  42. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_20.0_percent_coarse_J=7_uniform_random.npy +3 -0
  43. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_50.0_percent_coarse_J=7_uniform_random.npy +3 -0
  44. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_80.0_percent_coarse_J=7_uniform_random.npy +3 -0
  45. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/zero_filled/example_silicon_512x512_sample_20.0_percent_coarse_J=7_uniform_random.npy +3 -0
  46. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/zero_filled/example_silicon_512x512_sample_50.0_percent_coarse_J=7_uniform_random.npy +3 -0
  47. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/zero_filled/example_silicon_512x512_sample_80.0_percent_coarse_J=7_uniform_random.npy +3 -0
  48. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_2/masks/sample_20.0_percent_coarse_J=7_uniform_random.npy +3 -0
  49. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_2/masks/sample_50.0_percent_coarse_J=7_uniform_random.npy +3 -0
  50. 20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_2/masks/sample_80.0_percent_coarse_J=7_uniform_random.npy +3 -0
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/masks/sample_100.0_percent_coarse_J=9_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0acd32b99c7188ffb30eacfc6f0f0eae72734665c91e0c57c01f389ab059aaed
3
+ size 262272
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/masks/sample_20.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08d975fc0f430ce90488355ee474486f5d1297752c07c066c192f72ab4bf1089
3
+ size 262272
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/masks/sample_50.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2c33b815ead366cccd98fd520b879483a0b19ace29667ad87884d00c2dbf65a
3
+ size 262272
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/masks/sample_80.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9b0b77268fde8e3b49b46cb93a062ec73658f446500e7042217adf95c66767e
3
+ size 262272
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_100.0_percent_coarse_J=9_uniform_random.png ADDED

Git LFS Details

  • SHA256: 79eb89a3c066397b78c2c153456590b1af4dd0c8555b91ef18edf004f6918802
  • Pointer size: 131 Bytes
  • Size of remote file: 672 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: 60ce40040e3d0ef0bc17895a6e9ef6d390c6324660c0249bacd1ef3aff8d76fb
  • Pointer size: 131 Bytes
  • Size of remote file: 794 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: 13d56177ec4a9fbbe944eb7a5db91e25332344ddf384964eb6c891abdc394dba
  • Pointer size: 131 Bytes
  • Size of remote file: 855 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: ad14165e16221f6746cff594e3d5f00a55024faa333dfdd643f100169d1c16a3
  • Pointer size: 131 Bytes
  • Size of remote file: 882 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/metrics.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
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
+ 80.0, 7, 0.0008673915290273726, 29.5692138671875, 0.8141728043556213, 0.992389976978302, 7.899784395704046e-05, 39.97521209716797, 0.9804431796073914, 0.999309241771698
3
+ 50.0, 7, 0.0022277969401329756, 25.472606658935547, 0.637307345867157, 0.9803352952003479, 0.0003110810066573322, 34.02263259887695, 0.9316715002059937, 0.9972780346870422
4
+ 20.0, 7, 0.0034481799229979515, 23.575464248657227, 0.5139636993408203, 0.969394326210022, 0.0007311280351132154, 30.311429977416992, 0.8477615118026733, 0.9935988187789917
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_100.0_percent_coarse_J=9_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f83d638995382e7b541b73da293948e7be8c5f30e642ab39562832921bc5741
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34538441d5307eaf5c0f50fd9ba63aa90912a588f72f1e10ddbbab0a9f8d1cb0
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d2f3a32d6cf09fc15b0e9835e3663a8eedc92d173f28fe78017768d0051d2a6
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ab529e3a5d7d0dda42328376fbd1d88244f963b7014cbf591ca4f8459409734
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_100.0_percent_coarse_J=9_uniform_random.png ADDED

Git LFS Details

  • SHA256: eaade792a3dd973e0d417cb50c47b39254f3ddd3d9df45a978c8188739b547a6
  • Pointer size: 131 Bytes
  • Size of remote file: 441 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_20.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: 8d54dacfbc59a1d3699bfa12eeabdda29e0ed049bd5521a52f4869ec85fc6fc1
  • Pointer size: 131 Bytes
  • Size of remote file: 820 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_50.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: 8f53f6f0c7fd82f1b24593ee416d244b8ebd10fe0d80d1b878e529124c8cea2e
  • Pointer size: 131 Bytes
  • Size of remote file: 868 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_0/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_80.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

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

Git LFS Details

  • SHA256: 8c01a92a2a868c29f9570da11a612e36fe5e24af754cd3df294bd5450a9b9ae3
  • Pointer size: 131 Bytes
  • Size of remote file: 790 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: 4f34efe0df1977fef3663c7dd5d34daf5f90505e9357c5d776a5aed25edc4ae2
  • Pointer size: 131 Bytes
  • Size of remote file: 865 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/images/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: 56499214e0046ef104e8c10c44ddbafad079a6553f4a5c85ada28b715866727f
  • Pointer size: 131 Bytes
  • Size of remote file: 884 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/metrics.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
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
+ 80.0, 7, 0.00089330377522856, 29.44137191772461, 0.8160672187805176, 0.9921615719795227, 7.7854871051386e-05, 40.03850555419922, 0.9805998802185059, 0.9993190765380859
3
+ 50.0, 7, 0.002207003301009536, 25.513336181640625, 0.6699858903884888, 0.9805208444595337, 0.000306389934848994, 34.08861541748047, 0.9312506914138794, 0.9973183870315552
4
+ 20.0, 7, 0.0034744185395538807, 23.542543411254883, 0.5567121505737305, 0.969157874584198, 0.0007404985371977091, 30.256122589111328, 0.846380352973938, 0.9935111403465271
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_20.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1fbc46b05eb8c2af209ddd74209333e9abc5c7fc15239bf5ed3789a4d1d83c2
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_50.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a03ee5e92c7510e3d9f4d39a7bf6cede467f646238b77546f8ac719b861efbf
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/recons/example_silicon_512x512_pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05_sample_80.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab11461ca892bc554195f2acd605c9e0ba6b837293bf16c616658c9e28ae40ff
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_20.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: 7ef8ceb17d77443c7c1e0a35546c7a4125d71c84d0e088ca815f3bc0800ddf32
  • Pointer size: 131 Bytes
  • Size of remote file: 825 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_50.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: 0ebf4f8c73c1d15639d4d7e32660de33e3ef2105726c8d362601073f20083e33
  • Pointer size: 131 Bytes
  • Size of remote file: 882 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/images/example_silicon_512x512_spgl1_factor=1_sample_80.0_percent_coarse_J=7_uniform_random.png ADDED

Git LFS Details

  • SHA256: 5808453970dfa1aea64f7f08e0d6b563660ce9881f4dbc2fa5cf8dbafe82a2ea
  • Pointer size: 131 Bytes
  • Size of remote file: 889 kB
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/metrics.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
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
+ 80.0, 7, 0.00089330377522856, 29.44137191772461, 0.8160672187805176, 0.9921615719795227, 0.00044409645488485694, 32.47658920288086, 0.8919059634208679, 0.9961116313934326
3
+ 50.0, 7, 0.002207003301009536, 25.513336181640625, 0.6699858903884888, 0.9805208444595337, 0.0012489010114222765, 27.986083984375, 0.7376909255981445, 0.9890313744544983
4
+ 20.0, 7, 0.0034744185395538807, 23.542543411254883, 0.5567121505737305, 0.969157874584198, 0.002771863015368581, 24.52364730834961, 0.5300854444503784, 0.9755349159240723
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_20.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9aa9ed8132726ac1e72b9dda9fd6687f978b4bbeb3f08523172d41d8bec316f3
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_50.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d90fa5a5a2db15f3755a27821f4b55b93856dcf3ec97b2f43c362adfc0c539ed
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/spgl1_factor=1/recons/example_silicon_512x512_spgl1_factor=1_sample_80.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1b1114d095e4e11e84ffab9d32400797d616676cab7ab89e041494129b49d7a
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/zero_filled/example_silicon_512x512_sample_20.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ade341d17c4c3d47c12ea919580d446c9a87e708dd3ebacec773d4e1823d683
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/zero_filled/example_silicon_512x512_sample_50.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c9484c2f9174bc8bfc6b7336b2c2774aab61e812a834532ba99300b5b5516a5
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_1/zero_filled/example_silicon_512x512_sample_80.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50280ac8c6e3418812a8b62cd8425a3f6d39ad3dec4c3a69ad5683dde26688c6
3
+ size 1048704
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_2/masks/sample_20.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4fc3e1df96f6c935bbb8305a01b0e6173e368f98caa2d071654b26da301a2106
3
+ size 262272
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_2/masks/sample_50.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c28a9b7f3a07f5bbfab5192a2a87a230b52aaeb2cac49b8bd753e712bdbf289
3
+ size 262272
20260118_034512_example_silicon_512x512_uniform_10_trials_pnp_and_spgl1/trial_2/masks/sample_80.0_percent_coarse_J=7_uniform_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a36a26bd969324f93ffb98364706e3d28b6950778faeb6bd9150e40ea7747cd9
3
+ size 262272