trung-vt commited on
Commit
aa17578
·
1 Parent(s): fb41640
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitignore +1 -0
  2. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/masks/sample_100.0_percent_coarse_J=9_multilevel_random.npy +3 -0
  3. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/masks/sample_70.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  4. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/masks/sample_80.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  5. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/masks/sample_90.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  6. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_multilevel_random.png +3 -0
  7. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_70.0_percent_coarse_J=7_multilevel_random.png +3 -0
  8. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_multilevel_random.png +3 -0
  9. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_90.0_percent_coarse_J=7_multilevel_random.png +3 -0
  10. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/metrics.csv +5 -0
  11. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_multilevel_random.npy +3 -0
  12. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_70.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  13. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_multilevel_random.npy +3 -0
  14. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_90.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  15. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/zero_filled/example_silicon_512x512_sample_100.0_percent_coarse_J=9_multilevel_random.npy +3 -0
  16. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/zero_filled/example_silicon_512x512_sample_70.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  17. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/zero_filled/example_silicon_512x512_sample_80.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  18. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/zero_filled/example_silicon_512x512_sample_90.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  19. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_10.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  20. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_100.0_percent_coarse_J=9_multilevel_random.npy +3 -0
  21. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_20.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  22. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_30.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  23. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_40.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  24. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_50.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  25. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_60.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  26. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_70.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  27. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_80.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  28. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_90.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  29. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/photocurrent_mapping copy.py +880 -0
  30. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_10.0_percent_coarse_J=7_multilevel_random.png +3 -0
  31. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.png +3 -0
  32. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.png +3 -0
  33. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_30.0_percent_coarse_J=7_multilevel_random.png +3 -0
  34. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_40.0_percent_coarse_J=7_multilevel_random.png +3 -0
  35. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.png +3 -0
  36. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_60.0_percent_coarse_J=7_multilevel_random.png +3 -0
  37. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_70.0_percent_coarse_J=7_multilevel_random.png +3 -0
  38. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.png +3 -0
  39. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_90.0_percent_coarse_J=7_multilevel_random.png +3 -0
  40. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/metrics.csv +11 -0
  41. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_10.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  42. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.npy +3 -0
  43. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.npy +3 -0
  44. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_30.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  45. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_40.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  46. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.npy +3 -0
  47. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_60.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  48. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_70.0_percent_coarse_J=7_multilevel_random.npy +3 -0
  49. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.npy +3 -0
  50. 20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_90.0_percent_coarse_J=7_multilevel_random.npy +3 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .DS_Store
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/masks/sample_100.0_percent_coarse_J=9_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0acd32b99c7188ffb30eacfc6f0f0eae72734665c91e0c57c01f389ab059aaed
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/masks/sample_70.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3d2f664334874f6654d4545c71188c2816b32d070de91940fea3d4ccb83a29f1
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/masks/sample_80.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34ba4b8c2e85fa57dac50316de315051168e995e3a1f6f4749d5a044611867f3
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/masks/sample_90.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4daea7346f7521475be1ea7324d9c485ec7e8bc1d29170282feb8551a9b284c9
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_multilevel_random.png ADDED

Git LFS Details

  • SHA256: c6da34263d134c4d94c46bc22b0ef8e9330ce708c75e27590483e3120b41bcc0
  • Pointer size: 131 Bytes
  • Size of remote file: 467 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_70.0_percent_coarse_J=7_multilevel_random.png ADDED

Git LFS Details

  • SHA256: c77884f714757414a7e5a5bb63b1da81e3831714865a9735d82a7672bafb08de
  • Pointer size: 131 Bytes
  • Size of remote file: 872 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_multilevel_random.png ADDED

Git LFS Details

  • SHA256: fa094c034dab2b50fe49ca30928f68752e27786219b83b4efbf8ff76f2862949
  • Pointer size: 131 Bytes
  • Size of remote file: 874 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_90.0_percent_coarse_J=7_multilevel_random.png ADDED

Git LFS Details

  • SHA256: 8fb26481e7381bf01e4c9e3b9428de282e73a519c451715a7eb4f5f0c33660d6
  • Pointer size: 131 Bytes
  • Size of remote file: 876 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/pnp_admm_iters=50_eta=0.01_cg_iters=20_drunet_sigma=0.05/metrics.csv ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
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, 9, 1.0184068554284532e-14, 138.8721466064453, 0.9999859929084778, 1.0, 1.498177368830511e-07, 67.19573211669922, 0.999927282333374, 0.9999985098838806
3
+ 90.0, 7, 0.00042395666241645813, 32.67815017700195, 0.9024097919464111, 0.9962875247001648, 6.114241841714829e-05, 41.08794021606445, 0.9847308993339539, 0.9994654059410095
4
+ 80.0, 7, 0.0006067870417609811, 31.121002197265625, 0.8716933727264404, 0.994682252407074, 9.278859215555713e-05, 39.27641677856445, 0.9777882099151611, 0.9991885423660278
5
+ 70.0, 7, 0.0007914589950814843, 29.96708106994629, 0.8483958840370178, 0.993058443069458, 0.00013010911061428487, 37.808284759521484, 0.9696218371391296, 0.9988621473312378
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ccf0cdaa9d2338ace80e271aa0d04e243153a45ffec17a21f98229e82625628
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_70.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db50555e07c992ea4141d5cd3a09bc00e3074cffe2b5ce32cb60f29a8883439b
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd6cfd5bbd7ad16e7d5a0501922f6be47de89f58561fa998de504981276dfb77
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/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_90.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:396c8369c43568ed29d0ff0664daea5729ad4038be37b8a7311370c3b6825aec
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/zero_filled/example_silicon_512x512_sample_100.0_percent_coarse_J=9_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5e63752867153095c1a2e937e9bfe34b40bb8006b0908cd314a7639bdb693d2
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/zero_filled/example_silicon_512x512_sample_70.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f696ded1bb8ed94ca4c31317cf000994d2e8cf7c6d34d5416ce360f337e1f7aa
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/zero_filled/example_silicon_512x512_sample_80.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0d01444a161bacc53acef2fd25edf127b77ce91b521bb33c1f342c6e7090650
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_10/zero_filled/example_silicon_512x512_sample_90.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a108da6c08b0187f405d56a572dd9f757ff872d1e18392b122facbef1e8861f
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_10.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44cb6ef1be8a7d1e63c22ef1deb388cfd2f3fe34c1b169351fca0b950d9c375d
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_100.0_percent_coarse_J=9_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0acd32b99c7188ffb30eacfc6f0f0eae72734665c91e0c57c01f389ab059aaed
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_20.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40f024694f29aa087ac4532efa12979e11f13aa10f8fe79a2a6d576b4a6ee6d0
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_30.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ec6960ef28ca9ee1f09c79425c4fae6c4cb1548ebff08e487565aa2eeea4362
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_40.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69b04bc63b59ffc2fe29ae4f766d51c8041e5be15566da5f1f61fc8a77d8ebd9
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_50.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e215509cff619ee87903fb1d6ee63acb16a1335cff30b6c52ef80c951333a63
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_60.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:32a8ca031c92327020505a603a6e55dcfe141b7f70dfac049e36248a8aafac90
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_70.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00fa1988ebc7d3e956226eefe26721a57a3d08b63ef6f5a9fb3604471d12e907
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_80.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ce39341d9c5134bf84e0f6b39a9177fbe56c67f9df68b249c9bd8b958d80b4b
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/masks/sample_90.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63e6f3d98543cc04a26b175f1c1e72c8edd312648736175b2f3a124103aa98cc
3
+ size 262272
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/photocurrent_mapping copy.py ADDED
@@ -0,0 +1,880 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = 20
177
+ num_trials_skip = 6
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_ in range(1, 10, 1):
608
+ sampling_ratio = sampling_ / 10.0 # from 0.1 to 0.9
609
+ test_cases.append((sampling_ratio, J_order - 2)) # keep the first J-2 coarse levels, i.e. 6.25% in-order measurements
610
+ num_samples = int(sampling_ratio * num_pixels)
611
+ # 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)
612
+ # if coarse_J > 0:
613
+ # prev_num_coarse_samples = 1 << (2 * (coarse_J - 1))
614
+ # if prev_num_coarse_samples >= num_samples:
615
+ # continue
616
+ # test_cases.append((sampling_ratio, coarse_J))
617
+ test_cases.append((1.0, J_order)) # 100% sampling
618
+
619
+ # # sampling_ratios = [0.1]
620
+ # sampling_ratios = [0.2]
621
+ # # # sampling_ratios = [0.25]
622
+ # # sampling_ratios = [0.5]
623
+ # # # sampling_ratios = [0.7]
624
+ # # # coarse_Js = [5] # keep 2^{coarse_J} x 2^{coarse_J} in-order measurements
625
+ # # # coarse_Js = [7] # keep 2^{coarse_J} x 2^{coarse_J} in-order measurements
626
+ # coarse_Js = list(range(0, J_order))
627
+ # test_cases = []
628
+ # test_cases += [
629
+ # (sampling_ratio, coarse_J)
630
+ # for sampling_ratio in sampling_ratios
631
+ # for coarse_J in coarse_Js
632
+ # ]
633
+ # test_cases = [
634
+ # # (0.3, 3),
635
+ # # (0.2, 2),
636
+ # (0.2, 6),
637
+ # # (0.2, 8),
638
+ # # (0.2, 7),
639
+ # # (0.5, 6),
640
+ # # (0.8, 6),
641
+ # # (1.0, 6),
642
+ # # (1.0, 7),
643
+ # # (0.1, 8),
644
+ # ]
645
+
646
+ # test_cases = test_cases[80:]
647
+
648
+ test_cases.reverse()
649
+
650
+ return test_cases
651
+
652
+
653
+ def run_experiments():
654
+ raw_data: GrayscaleImage2D | Measurement1D = np.load(data_dir / data_filename)
655
+ print(f"Raw data shape: {raw_data.shape}")
656
+ print(f"J_order: {J_order}")
657
+
658
+ if data_type == "image":
659
+ ground_truth_image: GrayscaleImage2D = torch.tensor(raw_data, dtype=torch.float32, device=device)
660
+ if inverses_sign:
661
+ ground_truth_image = -ground_truth_image
662
+ J_data = int(np.log2(ground_truth_image.shape[0]))
663
+ assert J_data == J_order, f"Data J ({J_data}) does not match expected J_order ({J_order})."
664
+ print(f"Ground truth image shape: {ground_truth_image.shape}")
665
+ measurement_vector = None
666
+ elif data_type == "hadamard_measurement_vector":
667
+ # Reconstruct the image from the Hadamard measurement vector
668
+ J_data = int(np.log2(raw_data.shape[0]) / 2)
669
+ assert J_data == J_order, f"Data J ({J_data}) does not match expected J_order ({J_order})."
670
+ measurement_vector = torch.tensor(raw_data, dtype=torch.float32, device=device)
671
+ if inverses_sign:
672
+ measurement_vector = -measurement_vector
673
+
674
+ index_of_max = torch.argmax(measurement_vector).item()
675
+ index_of_min = torch.argmin(measurement_vector).item()
676
+ print(f"Max value in measurement vector: {measurement_vector[index_of_max].item()} at index {index_of_max}")
677
+ print(f"Min value in measurement vector: {measurement_vector[index_of_min].item()} at index {index_of_min}")
678
+ exit()
679
+
680
+ pcm_op_full = PhotocurrentMapOp(J=J_order, device=device)
681
+ with torch.no_grad():
682
+ ground_truth_image = pcm_op_full.pseudo_inv(measurement_vector)
683
+ print(f"Reconstructed ground truth image shape from Hadamard measurement vector: {ground_truth_image.shape}")
684
+
685
+ elif data_type == "original_measurement_data":
686
+ # Make a 1D array with num_lines//2 elements,
687
+ # where each element is the sum of the measured current multiplied by the pattern index sign.
688
+ num_measurements = raw_data.shape[0]
689
+ assert num_measurements % 2 == 0, "Number of measurements should be even."
690
+
691
+ if inverses_sign:
692
+ raw_data[:, 1] = -raw_data[:, 1]
693
+
694
+ index_of_max_raw = np.argmax(raw_data[:, 1])
695
+ index_of_min_raw = np.argmin(raw_data[:, 1])
696
+ min_raw_value = raw_data[index_of_min_raw, 1]
697
+ max_raw_value = raw_data[index_of_max_raw, 1]
698
+ print(f"Max value in original measurement data: {max_raw_value} at index {index_of_max_raw}")
699
+ print(f"Min value in original measurement data: {min_raw_value} at index {index_of_min_raw}")
700
+ # exit()
701
+
702
+ sign_vector = np.round(np.sign(raw_data[:, 0]))
703
+ sign_vector[:2] = [1.0, -1.0] # Ensure the first two patterns are +0 and -0
704
+
705
+ measurement_vector = torch.tensor((raw_data[:, 1] * sign_vector).reshape(-1, 2).sum(axis=1), dtype=torch.float32, device=device)
706
+
707
+ # index_of_max = torch.argmax(measurement_vector).item()
708
+ # index_of_min = torch.argmin(measurement_vector).item()
709
+ # min_value = measurement_vector[index_of_min].item()
710
+ # max_value = measurement_vector[index_of_max].item()
711
+ # print(f"Max value in measurement vector: {max_value} at index {index_of_max}")
712
+ # print(f"Min value in measurement vector: {min_value} at index {index_of_min}")
713
+ # exit()
714
+
715
+ pcm_op_full = PhotocurrentMapOp(J=J_order, device=device)
716
+ print(f"pcm_op_full domain shape: {pcm_op_full.domain_shape}, range shape: {pcm_op_full.range_shape}")
717
+ with torch.no_grad():
718
+ ground_truth_image = pcm_op_full.pseudo_inv(measurement_vector)
719
+ print(f"Reconstructed ground truth image shape from original measurement data: {ground_truth_image.shape}")
720
+
721
+ if tests_scale_ground_truth:
722
+ gt_min, gt_max = ground_truth_image.min().item(), ground_truth_image.max().item()
723
+ ground_truth_image = (ground_truth_image - gt_min) / (gt_max - gt_min)
724
+ print(f"Normalized ground truth image to [0, 1]. Min: {ground_truth_image.min().item()}, Max: {ground_truth_image.max().item()}")
725
+ measurement_vector = None
726
+
727
+ test_cases = make_test_cases()
728
+ # print(f"Total number of test cases: {len(test_cases)}")
729
+ # print(test_cases)
730
+ # for sampling_ratio, coarse_J in test_cases:
731
+ # sampling_percentage = sampling_ratio * 100
732
+ # coarse_percentage = (1<<(2*coarse_J))/(1<<(2*J_order))*100
733
+ # print(f"Sampling: {sampling_percentage}%, coarse_J: {coarse_J} ({coarse_percentage}%)")
734
+ # assert sampling_percentage >= coarse_percentage, (
735
+ # "Sampling percentage must be larger than or equal to coarse percentage. "
736
+ # f"Got sampling {sampling_percentage}% and coarse {coarse_percentage}%."
737
+ # )
738
+ # return
739
+
740
+ # ### Set a directory to save logs and results
741
+ #
742
+ # Each run is stored in a separate subdirectory named with the current date and
743
+ # time, which makes it easier to keep track of different experiments.
744
+
745
+ current_datetime_str = datetime.now().strftime("%Y%m%d_%H%M%S")
746
+ experiment_log_dir = Path("pcm_demo_output") / f"{current_datetime_str}_{data_name}_{randomizing_scheme}_{num_trials}_trials"
747
+ experiment_log_dir.mkdir(parents=True, exist_ok=True)
748
+
749
+ for i_seed in tqdm(range(num_trials_skip, num_trials), desc="Running trials"):
750
+ print(f"\n=== Trial {i_seed} ===")
751
+ log_dir = experiment_log_dir / f"trial_{i_seed}"
752
+ log_dir.mkdir(parents=True, exist_ok=True)
753
+
754
+ # %% [markdown]
755
+ # ## First experiment: PnP-ADMM
756
+ #
757
+ # In this section the PCM PnP-ADMM algorithm is tested on the CIGS data.
758
+
759
+ # %% [markdown]
760
+ # Define the prior function using a pre-trained DRUNet denoiser and the
761
+ # corresponding Plug-and-Play ADMM solver.
762
+ #
763
+ # DRUNet is a deep convolutional denoiser proposed by:
764
+ #
765
+ # > Kai Zhang, Yawei Li, Wangmeng Zuo, Lei Zhang, Luc Van Gool, and
766
+ # > Radu Timofte, "Plug-and-Play Image Restoration with Deep Denoiser Prior,"
767
+ # > IEEE Transactions on Pattern Analysis and Machine Intelligence, 44(10),
768
+ # > 6360–6376, 2022.
769
+ #
770
+ # In the PnP-ADMM framework, the proximal step of a regulariser is replaced by
771
+ # an off-the-shelf denoiser. Here DRUNet acts as a powerful learned prior for
772
+ # the PCM inverse problem, while the data fidelity term is handled by ADMM.
773
+
774
+ # %%
775
+ if runs_pnp_admm:
776
+ method_name = f"pnp_admm_iters={pnp_admm_iters}_eta={pnp_admm_eta}_cg_iters={cg_iters}_drunet_sigma={drunet_sigma}"
777
+ make_csv(method_name=method_name, log_dir=log_dir)
778
+ # for delta_divided_by, subtract_from_J in tqdm(test_cases, desc="Running PnP-ADMM experiments"):
779
+ for sampling_ratio, coarse_J in tqdm(test_cases, desc="Running PnP-ADMM experiments"):
780
+ run_pcm_demo(
781
+ recon_description=f"PnP-ADMM ({pnp_admm_iters} iters, η={pnp_admm_eta}, cg_iters={cg_iters}, σ={drunet_sigma})",
782
+ recon_fn=run_pnp_admm,
783
+ ground_truth_image=ground_truth_image,
784
+ method_name=method_name,
785
+ image_name=data_name,
786
+ J=J_order, # image size is 2^J x 2^J
787
+ sampling_ratio=sampling_ratio,
788
+ coarse_J=coarse_J,
789
+ log_dir=log_dir,
790
+ device=device,
791
+ seed=i_seed,
792
+ )
793
+
794
+
795
+ # %% [markdown]
796
+ # The code above runs the PnP-ADMM reconstruction and compares it to the
797
+ # zero-filled pseudo-inverse.
798
+ #
799
+ # Although PnP-ADMM substantially improves PSNR and SSIM, it can smooth out
800
+ # fine-scale structures. In the context of defect detection, these small
801
+ # features can be crucial, so high PSNR and SSIM alone are not sufficient to
802
+ # guarantee that the reconstruction is fit for purpose.
803
+ #
804
+ # In the next sections, two compressed sensing baselines with a wavelet
805
+ # sparsity prior are explored and compared to the PnP-ADMM result.
806
+
807
+
808
+ # %% [markdown]
809
+ # ## Compressed sensing baseline: FISTA with wavelet sparsity
810
+ #
811
+ # This section applies FISTA with an $\ell_1$-penalty on wavelet coefficients
812
+ # as a classical compressed sensing baseline.
813
+ #
814
+ # Let $\Phi$ denote the PCM forward operator and $\Psi$ a 2D wavelet
815
+ # transform with inverse $\Psi^{-1}$. The composite operator
816
+ # $A = \Phi \Psi^{-1}$ acts on wavelet coefficients $w$.
817
+ # FISTA approximately solves the standard $\ell_1$-regularised problem
818
+ #
819
+ # $$
820
+ # \min_w \frac{1}{2} \lVert A w - y \rVert_2^2
821
+ # + \lambda \lVert w \rVert_1,
822
+ # $$
823
+ #
824
+ # and the final current map is obtained as $x = \Psi^{-1} w$.
825
+ #
826
+ # An optional debiasing step is included at the end to reduce the bias induced
827
+ # by the $\ell_1$ penalty on the active support.
828
+
829
+ # %%
830
+ if runs_fista_l1:
831
+ make_csv(method_name="fista_l1", log_dir=log_dir)
832
+ for sampling_ratio, coarse_J in tqdm(test_cases, desc="Running FISTA-L1 experiments"):
833
+ run_pcm_demo(
834
+ recon_description="FISTA-L1",
835
+ recon_fn=run_fista_l1,
836
+ ground_truth_image=ground_truth_image,
837
+ method_name="fista_l1",
838
+ image_name=data_name,
839
+ J=J_order, # image size is 2^J x 2^J
840
+ sampling_ratio=sampling_ratio,
841
+ coarse_J=coarse_J,
842
+ log_dir=log_dir,
843
+ device=device,
844
+ seed=i_seed,
845
+ )
846
+
847
+ # %% [markdown]
848
+ # ## Compressed sensing baseline: SPGL1 with wavelet sparsity
849
+ #
850
+ # This section applies the SPGL1 algorithm as a second compressed sensing
851
+ # baseline, again using a wavelet sparsity prior in the same setting
852
+ # $A = \Phi \Psi^{-1}$.
853
+ #
854
+ # SPGL1 is a spectral projected gradient method that efficiently solves
855
+ # large-scale $\ell_1$-regularised problems and basis pursuit denoising
856
+ # formulations. In this example it is run with default parameters suitable
857
+ # for the PCM problem size, followed by the same optional debiasing step
858
+ # used for FISTA.
859
+
860
+ # %%
861
+ if runs_spgl1:
862
+ method_name = f"spgl1_factor={factor}"
863
+ make_csv(method_name=method_name, log_dir=log_dir)
864
+ for sampling_ratio, coarse_J in tqdm(test_cases, desc="Running SPGL1 experiments"):
865
+ run_pcm_demo(
866
+ recon_description="SPGL1",
867
+ recon_fn=run_spgl1,
868
+ ground_truth_image=ground_truth_image,
869
+ method_name=method_name,
870
+ image_name=data_name,
871
+ J=J_order, # image size is 2^J x 2^J
872
+ sampling_ratio=sampling_ratio,
873
+ coarse_J=coarse_J,
874
+ log_dir=log_dir,
875
+ device=device,
876
+ seed=i_seed,
877
+ )
878
+
879
+ if __name__ == "__main__":
880
+ run_experiments()
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_10.0_percent_coarse_J=7_multilevel_random.png ADDED

Git LFS Details

  • SHA256: e95aa6688f54be5eb84e797fe13c864a2e085e330280d248a88447da80df9b86
  • Pointer size: 131 Bytes
  • Size of remote file: 742 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.png ADDED

Git LFS Details

  • SHA256: 7788d33ff6676b4fb53d236bcc1541edc6aa27646daa5f83b79e452a28f10485
  • Pointer size: 131 Bytes
  • Size of remote file: 467 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.png ADDED

Git LFS Details

  • SHA256: 6a6c54aad2453f798c36c6d957ca97abccdf4a860f79e358c9c802526ea2a453
  • Pointer size: 131 Bytes
  • Size of remote file: 800 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_30.0_percent_coarse_J=7_multilevel_random.png ADDED

Git LFS Details

  • SHA256: e40fc5174f66d4c3e7bf9fda6dd56c460b4afa5ce510bf64c4d904ef7f0d3a49
  • Pointer size: 131 Bytes
  • Size of remote file: 832 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_40.0_percent_coarse_J=7_multilevel_random.png ADDED

Git LFS Details

  • SHA256: bd415907787d7520eb4bc696501c0b9422cd267777ee698a907304a792cfbbbf
  • Pointer size: 131 Bytes
  • Size of remote file: 852 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.png ADDED

Git LFS Details

  • SHA256: d82028bde5eb5371d2fafe1d48c174ec018f5c640f6de97fbbc062db5c88992c
  • Pointer size: 131 Bytes
  • Size of remote file: 864 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_60.0_percent_coarse_J=7_multilevel_random.png ADDED

Git LFS Details

  • SHA256: 49514f423bb8f97ee959b74b9228a57f75e236d89c4a563869594d9f827254b4
  • Pointer size: 131 Bytes
  • Size of remote file: 867 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_70.0_percent_coarse_J=7_multilevel_random.png ADDED

Git LFS Details

  • SHA256: b648d624065157e63462637a9a80d0d4b558d1e032a410ce5553fbba40d6daaf
  • Pointer size: 131 Bytes
  • Size of remote file: 871 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.png ADDED

Git LFS Details

  • SHA256: addbaf580bdab2870e1ccd901e65452a18461abd71a557fe902bd461f68439e1
  • Pointer size: 131 Bytes
  • Size of remote file: 874 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_90.0_percent_coarse_J=7_multilevel_random.png ADDED

Git LFS Details

  • SHA256: cc2433cdc8eecd496e115e2d9eba1d5280afbac0f8fefa6cf74daadbc4ba43a3
  • Pointer size: 131 Bytes
  • Size of remote file: 876 kB
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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, 9, 1.0184068554284532e-14, 138.8721466064453, 0.9999859929084778, 1.0, 1.4981952745074523e-07, 67.1956787109375, 0.9999273419380188, 0.9999985098838806
3
+ 90.0, 7, 0.0005199720617383718, 31.79156494140625, 0.8841738104820251, 0.9954447746276855, 6.0551563365152106e-05, 41.13010787963867, 0.9849793314933777, 0.999470591545105
4
+ 80.0, 7, 0.0007175832870416343, 30.392641067504883, 0.8555670976638794, 0.9937083721160889, 9.369450708618388e-05, 39.234222412109375, 0.977675199508667, 0.999180793762207
5
+ 70.0, 7, 0.0008509858744218946, 29.652141571044922, 0.8355796337127686, 0.9925343990325928, 0.00013012078125029802, 37.80789566040039, 0.9696718454360962, 0.998862087726593
6
+ 60.0, 7, 0.0011638076975941658, 28.292552947998047, 0.8030414581298828, 0.9897760152816772, 0.00017674350237939507, 36.477928161621094, 0.9593662619590759, 0.9984539151191711
7
+ 50.0, 7, 0.0016132695600390434, 26.874296188354492, 0.7330599427223206, 0.9857990145683289, 0.00025359378196299076, 34.909976959228516, 0.9415607452392578, 0.9977810382843018
8
+ 40.0, 7, 0.0023769941180944443, 25.191083908081055, 0.6535683274269104, 0.9790043830871582, 0.00035941775422543287, 33.39536666870117, 0.9185649752616882, 0.996853768825531
9
+ 30.0, 7, 0.002675558440387249, 24.677221298217773, 0.6167353391647339, 0.9763352870941162, 0.00048572622472420335, 32.08744812011719, 0.8922742605209351, 0.9957473874092102
10
+ 20.0, 7, 0.0032613796647638083, 23.817350387573242, 0.6070817708969116, 0.9710769653320312, 0.0006660553626716137, 30.71626091003418, 0.8559794425964355, 0.9941643476486206
11
+ 10.0, 7, 0.003874317742884159, 23.069412231445312, 0.504093587398529, 0.9655445218086243, 0.002103518694639206, 25.721899032592773, 0.6675649881362915, 0.981448233127594
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_10.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8841a6622115b3bba16bc7cf34afd28ff885e7785c50d026dc510e93fb49945
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27fbb9fc40d8423902b4def1e6351085e88d43d4c2854e86f093c374fcd3dd25
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d02c891452ccd9c8d346ec407fcc533b87c3b2dc3e4ae8a4b5b2975ea357e1bf
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_30.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e71eaf4e6a4c98a9490735294406b9557688215b53c78dcb58f959cc3e8a3a6a
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_40.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3a3d5c401ae6a08ae5e8e704d5effa58d221dbaffea585a9c8682b3f84a03cd
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44ffbeb0abe7d9351ed208328e558510042c4c7589cbca9464774da48223e0ee
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_60.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:750329d0c80b3994bbc6fc7b4be7cc6eb898918a4c891f00220ee0ff9e937250
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_70.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7e1a2d7b749bd858387226b2a2da0a59e170e339e5bbe5622e91690fb65c13f
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:298bb2ee16b4f28374906c0101ecd717ee2956cf814b24a4677ef69a84ac7aed
3
+ size 1048704
20260117_065237_example_silicon_512x512_multilevel_20_trials_pnp_and_spgl1/trial_6/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_90.0_percent_coarse_J=7_multilevel_random.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f3ddc8359f3bb8c34e6098ea4655ab6cafc43e25749423bb6189988c4a3fac92
3
+ size 1048704