Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"source": [
"# Tutorial homogenous cylinder"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## import"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"import numpy as np\n",
"\n",
"root_folder = os.path.dirname(os.getcwd())\n",
"sys.path.insert(0, root_folder)\n",
"from neutron_geomcorr.geometry_correction import GeometryCorrection\n",
"import glob\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"\n",
"from ipywidgets import widgets, interact"
]
},
{
"cell_type": "markdown",
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"source": [
"## initialize object "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"outputs": [],
"source": [
"list_tiff = glob.glob('data/tiff/homogeneous*.tif')\n",
"\n",
"# initialize object\n",
"o_cgc = GeometryCorrection(list_files=list_tiff)\n",
"o_cgc.load_files(notebook=True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"run_control": {
"frozen": false,
"read_only": false
}
},
"source": [
"## Display images"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"outputs": [],
"source": [
"list_images = o_cgc.list_data\n",
"\n",
"fig1, (ax1, ax2) = plt.subplots(1, 2)\n",
" \n",
"def plot(index):\n",
" \n",
" ax1.clear()\n",
" ax1.imshow(list_images[index])\n",
" \n",
" ax2.clear()\n",
" ax2.plot(list_images[index][0,:])\n",
" \n",
"interact(plot,\n",
" index = widgets.IntSlider(value=0,\n",
" max=len(list_images)-1),\n",
" continuous_update=False)"
]
},
{
"cell_type": "markdown",
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"source": [
"## Define parameters "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"outputs": [],
"source": [
"# center of cylinder\n",
"pixel_center = 256\n",
"\n",
"# radius of cylinder\n",
"radius = 200\n",
"\n",
"# define the parameters\n",
"o_cgc.define_parameters(outer_radius=radius, pixel_center=pixel_center)"
]
},
{
"cell_type": "markdown",
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"source": [
"## Run correction "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"outputs": [],
"source": [
"o_cgc.correct(notebook=True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"source": [
"## Display data corrected "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"outputs": [],
"source": [
"list_images_corrected = o_cgc.list_data_corrected\n",
"\n",
"fig2, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(8,3))\n",
" \n",
"def plot(index):\n",
" \n",
" ax1.clear()\n",
" ax1.imshow(list_images_corrected[index])\n",
" \n",
" ax2.clear()\n",
" max_y_value = np.nanmax(list_images_corrected[index][0, 1:])\n",
" ax2.plot(list_images_corrected[index][0,:])\n",
" ax2.set_ylim(0,max_y_value+1)\n",
" \n",
" ax3.clear()\n",
" ax3.plot(list_images_corrected[index][0,:])\n",
" \n",
" plt.tight_layout()\n",
" \n",
"interact(plot,\n",
" index = widgets.IntSlider(value=0,\n",
" max=len(list_images_corrected)-1),\n",
" continuous_update=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"run_control": {
"frozen": false,
"read_only": false
}
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6.4"
},
"toc": {
"colors": {
"hover_highlight": "#DAA520",
"running_highlight": "#FF0000",
"selected_highlight": "#FFD700"
},
"moveMenuLeft": true,
"nav_menu": {
"height": "118px",
"width": "252px"
},
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 4,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading