{ "cells": [ { "cell_type": "markdown", "id": "98845dbc", "metadata": {}, "source": [ "# Simple interactive sinogram check\n", "Notebook author: Felipe Delestro (fima@dtu.dk)\n", "\n", "This Notebooks provides a simple interactive sinogram visualization" ] }, { "cell_type": "code", "execution_count": 1, "id": "4f4a0b0c", "metadata": {}, "outputs": [], "source": [ " import qim3d\n", " import matplotlib.pyplot as plt\n", " import ipywidgets" ] }, { "cell_type": "code", "execution_count": 2, "id": "6c539f03", "metadata": {}, "outputs": [], "source": [ "vol = qim3d.io.load(\"../resources/img3d/small_foram.h5\", dataset_name=\"exchange/data\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "455a5e35", "metadata": {}, "outputs": [], "source": [ "def plot_sinogram(vol, zpos, ypos):\n", " fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(8,10), sharey=True)\n", " \n", " axs[0].imshow(vol[zpos,:,:])\n", " axs[0].axhline(ypos, color=\"#FF6633\")\n", " axs[0].axis(\"off\")\n", " \n", " axs[1].imshow(vol[:,ypos,:])\n", " axs[1].axis(\"off\")\n", " \n", " plt.show()" ] }, { "cell_type": "code", "execution_count": 4, "id": "634512ff", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "5764f0764f034cfb9a78ff7dd4d9ade7", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(IntSlider(value=360, description='zpos', max=720), IntSlider(value=130, description='ypo…" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ipywidgets.interactive(plot_sinogram,\n", " vol = ipywidgets.fixed(vol),\n", " zpos = ipywidgets.IntSlider(min=0, max=vol.shape[0]-1, value=int(vol.shape[0]/2)),\n", " ypos = ipywidgets.IntSlider(min=0, max=vol.shape[1]-1, value=int(vol.shape[1]/2)))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 5 }