Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 23, 2024
1 parent cb1bd01 commit 87fa0f1
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 208 deletions.
90 changes: 45 additions & 45 deletions notebooks/demo_denoise_mode.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
"import matplotlib.pyplot as plt\n",
"\n",
"# Set the GPU device ID to 0 for this notebook session\n",
"os.environ['CUDA_VISIBLE_DEVICES'] = '0'\n",
"os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n",
"\n",
"this_dir = os.path.abspath(\"\")\n",
"data_dir = os.path.join(this_dir, '../tests/bm3dornl-data')\n",
"datafile = os.path.join(data_dir, 'tomostack_small.h5')\n",
"data_dir = os.path.join(this_dir, \"../tests/bm3dornl-data\")\n",
"datafile = os.path.join(data_dir, \"tomostack_small.h5\")\n",
"\n",
"# Load the data and select a noisy sinogram\n",
"with h5py.File(datafile, 'r') as f:\n",
" tomo_stack_noisy = f['noisy_tomostack'][:]\n",
"with h5py.File(datafile, \"r\") as f:\n",
" tomo_stack_noisy = f[\"noisy_tomostack\"][:]\n",
"\n",
"# Select a sinogram with low SNR\n",
"sino_low_snr = tomo_stack_noisy[:, 10, :]\n",
Expand All @@ -62,13 +62,13 @@
"# Plot the sinograms\n",
"plt.figure(figsize=(15, 5))\n",
"plt.subplot(121)\n",
"plt.imshow(sino_low_snr, cmap='gray')\n",
"plt.imshow(sino_low_snr, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Sinogram with low SNR')\n",
"plt.title(\"Sinogram with low SNR\")\n",
"plt.subplot(122)\n",
"plt.imshow(sino_high_snr, cmap='gray')\n",
"plt.imshow(sino_high_snr, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Sinogram with high SNR')\n",
"plt.title(\"Sinogram with high SNR\")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -143,33 +143,33 @@
"# bottom: high_sino, diff\n",
"plt.figure(figsize=(15, 10))\n",
"plt.subplot(231)\n",
"plt.imshow(sino_low_snr, cmap='gray')\n",
"plt.imshow(sino_low_snr, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Sinogram with low SNR')\n",
"plt.title(\"Sinogram with low SNR\")\n",
"plt.subplot(232)\n",
"plt.imshow(sino_low_snr_denoised, cmap='gray')\n",
"plt.imshow(sino_low_snr_denoised, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Denoised sinogram with low SNR')\n",
"plt.title(\"Denoised sinogram with low SNR\")\n",
"plt.subplot(233)\n",
"diff = sino_low_snr - sino_low_snr_denoised\n",
"cval = np.quantile(np.abs(diff), 0.98)\n",
"plt.imshow(diff, cmap='seismic', vmin=-cval, vmax=cval)\n",
"plt.imshow(diff, cmap=\"seismic\", vmin=-cval, vmax=cval)\n",
"plt.colorbar()\n",
"plt.title('Difference')\n",
"plt.title(\"Difference\")\n",
"plt.subplot(234)\n",
"plt.imshow(sino_high_snr, cmap='gray')\n",
"plt.imshow(sino_high_snr, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Sinogram with high SNR')\n",
"plt.title(\"Sinogram with high SNR\")\n",
"plt.subplot(235)\n",
"plt.imshow(sino_high_snr_denoised, cmap='gray')\n",
"plt.imshow(sino_high_snr_denoised, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Denoised sinogram with high SNR')\n",
"plt.title(\"Denoised sinogram with high SNR\")\n",
"plt.subplot(236)\n",
"diff = sino_high_snr - sino_high_snr_denoised\n",
"cval = np.quantile(np.abs(diff), 0.98)\n",
"plt.imshow(diff, cmap='seismic', vmin=-cval, vmax=cval)\n",
"plt.imshow(diff, cmap=\"seismic\", vmin=-cval, vmax=cval)\n",
"plt.colorbar()\n",
"plt.title('Difference')\n",
"plt.title(\"Difference\")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -207,33 +207,33 @@
"# bottom: high_sino, diff\n",
"plt.figure(figsize=(15, 10))\n",
"plt.subplot(231)\n",
"plt.imshow(sino_low_snr, cmap='gray')\n",
"plt.imshow(sino_low_snr, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Sinogram with low SNR')\n",
"plt.title(\"Sinogram with low SNR\")\n",
"plt.subplot(232)\n",
"plt.imshow(sino_low_snr_denoised, cmap='gray')\n",
"plt.imshow(sino_low_snr_denoised, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Denoised sinogram with low SNR')\n",
"plt.title(\"Denoised sinogram with low SNR\")\n",
"plt.subplot(233)\n",
"diff = sino_low_snr - sino_low_snr_denoised\n",
"cval = np.quantile(np.abs(diff), 0.98)\n",
"plt.imshow(diff, cmap='seismic', vmin=-cval, vmax=cval)\n",
"plt.imshow(diff, cmap=\"seismic\", vmin=-cval, vmax=cval)\n",
"plt.colorbar()\n",
"plt.title('Difference')\n",
"plt.title(\"Difference\")\n",
"plt.subplot(234)\n",
"plt.imshow(sino_high_snr, cmap='gray')\n",
"plt.imshow(sino_high_snr, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Sinogram with high SNR')\n",
"plt.title(\"Sinogram with high SNR\")\n",
"plt.subplot(235)\n",
"plt.imshow(sino_high_snr_denoised, cmap='gray')\n",
"plt.imshow(sino_high_snr_denoised, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Denoised sinogram with high SNR')\n",
"plt.title(\"Denoised sinogram with high SNR\")\n",
"plt.subplot(236)\n",
"diff = sino_high_snr - sino_high_snr_denoised\n",
"cval = np.quantile(np.abs(diff), 0.98)\n",
"plt.imshow(diff, cmap='seismic', vmin=-cval, vmax=cval)\n",
"plt.imshow(diff, cmap=\"seismic\", vmin=-cval, vmax=cval)\n",
"plt.colorbar()\n",
"plt.title('Difference')\n",
"plt.title(\"Difference\")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -271,33 +271,33 @@
"# bottom: high_sino, diff\n",
"plt.figure(figsize=(15, 10))\n",
"plt.subplot(231)\n",
"plt.imshow(sino_low_snr, cmap='gray')\n",
"plt.imshow(sino_low_snr, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Sinogram with low SNR')\n",
"plt.title(\"Sinogram with low SNR\")\n",
"plt.subplot(232)\n",
"plt.imshow(sino_low_snr_denoised, cmap='gray')\n",
"plt.imshow(sino_low_snr_denoised, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Denoised sinogram with low SNR')\n",
"plt.title(\"Denoised sinogram with low SNR\")\n",
"plt.subplot(233)\n",
"diff = sino_low_snr - sino_low_snr_denoised\n",
"cval = np.quantile(np.abs(diff), 0.98)\n",
"plt.imshow(diff, cmap='seismic', vmin=-cval, vmax=cval)\n",
"plt.imshow(diff, cmap=\"seismic\", vmin=-cval, vmax=cval)\n",
"plt.colorbar()\n",
"plt.title('Difference')\n",
"plt.title(\"Difference\")\n",
"plt.subplot(234)\n",
"plt.imshow(sino_high_snr, cmap='gray')\n",
"plt.imshow(sino_high_snr, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Sinogram with high SNR')\n",
"plt.title(\"Sinogram with high SNR\")\n",
"plt.subplot(235)\n",
"plt.imshow(sino_high_snr_denoised, cmap='gray')\n",
"plt.imshow(sino_high_snr_denoised, cmap=\"gray\")\n",
"plt.colorbar()\n",
"plt.title('Denoised sinogram with high SNR')\n",
"plt.title(\"Denoised sinogram with high SNR\")\n",
"plt.subplot(236)\n",
"diff = sino_high_snr - sino_high_snr_denoised\n",
"cval = np.quantile(np.abs(diff), 0.98)\n",
"plt.imshow(diff, cmap='seismic', vmin=-cval, vmax=cval)\n",
"plt.imshow(diff, cmap=\"seismic\", vmin=-cval, vmax=cval)\n",
"plt.colorbar()\n",
"plt.title('Difference')\n",
"plt.title(\"Difference\")\n",
"plt.show()"
]
},
Expand Down
Loading

0 comments on commit 87fa0f1

Please sign in to comment.