Skip to content

Commit

Permalink
fix TEM widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
gvarnavi committed Jul 29, 2024
1 parent ac54d49 commit 423bdb9
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 427 deletions.
10 changes: 4 additions & 6 deletions 08_TEM.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ After building an atomic potential as described in the [](#algorithms_page), the
```{figure} #app:tem_imaging
:name: fig_tem_phase
:placeholder: ./static/tem_imaging.png
**TEM imaging of SrTiO$_$ grains**:
**TEM imaging of SrTiO$_3$ grains**:
```



### Diffraction

```{figure}
```{figure} #app:tem_diffraction
:name: fig_tem_diffraction
:placeholder: ./static/tem_diffraction.png
**TEM diffraction of STO as a function of thickness**:
Expand All @@ -41,17 +41,15 @@ In TEM, aberrations modify the exit wave ({math}`\Psi_{exit}`) after the multisl
```{math}
:label: eq:TEM_aberrations
\begin{align}
\Psi_{image}(\bm{k}) = \Psi_{exit}(\bm{k}) \mathrm{e}^{-i\chi(\bm{k})},
\end{align}
\Psi_{image}(\bm{k}) = \Psi_{exit}(\bm{k}) \mathrm{e}^{-i\chi(\bm{k})},
```

One example of the importance of aberrations and wavfunction modification is shown in [](#tem_contrast). Although the wavfunction at the imaging plane ({math}`\Psi_{image}(\bm{k}`)) may be complex, only the intensity of the exit wave is measured by detectors. Weakly scattering samples, impart very little ampltidue contrast on the incident beam, so most of the structural information is encoded in the phase of the exit wave. This is especially well known in the case of imaging of biological materials, as these structures are beam-sensitive and composed of low atomic number (weakly scattering elements). This effect is evident in the left pannel of [](#tem_contrast), where as the dose decreases, it is very challenging to observe the simulated covid spike protein.

```{figure} #app:tem_contrast
:name: fig_tem_phase
:placeholder: ./static/tem_contrast.png
**TEM imaging of covid spike protein **: (left) In focus, (middle) defocued, and (right) Zernike phase plate TEM images. [Covid structure](https://www.rcsb.org/structure/3jcl) from {cite}`walls2016cryo`
**TEM imaging of covid spike protein**: (left) In focus, (middle) defocued, and (right) Zernike phase plate TEM images. [Covid structure](https://www.rcsb.org/structure/3jcl) from {cite}`walls2016cryo`
```

For the same, dose the image contrast can be increased by modfying the wavefunctions through the introduction of aberrations. This is most often done with defocus, which is illustrated in the middle pannel. The resulting image has improved contrast, making it easier to visualize the covid spike protein. The middle pannel shows the defocused image, but the aberrations can often be corrected for later in post-processing.
Expand Down
113 changes: 47 additions & 66 deletions notebooks/TEM_imaging.ipynb → notebooks/08.1_TEM_imaging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"id": "43989778-1e53-41ff-8eb2-0a8eda0396e0",
"metadata": {},
"source": [
"# STO BF/DF TEM\n",
"> Stephanie Ribet | 26 July 2024\n",
"\n",
"> Structure from George Varnavides"
"---\n",
"title: TEM Imaging\n",
"authors: [Stephanie Ribet, Georgios Varnavides]\n",
"date: 2024/07/26\n",
"---"
]
},
{
Expand All @@ -26,11 +27,7 @@
"metadata": {},
"outputs": [],
"source": [
"#| label: app:tem_imaging\n",
"\n",
"%matplotlib widget\n",
"\n",
"\n",
"import ase\n",
"import abtem\n",
"\n",
Expand All @@ -39,7 +36,7 @@
"from scipy.spatial import Voronoi, voronoi_plot_2d, cKDTree\n",
"\n",
"from matplotlib.patches import Circle\n",
"from ipywidgets import HBox, VBox, widgets, interact, Dropdown, Label, Layout\n"
"from ipywidgets import HBox, VBox, widgets, interact, Dropdown, Label, Layout"
]
},
{
Expand All @@ -63,28 +60,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"id": "7dd8a0b0-0ebc-4268-83a5-b577237344d9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Cell([178.53620324239898, 189.36624, 44.634050810599746])"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"STO_atoms.cell"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"id": "b949df4c-c2cf-40a3-b770-822ade89b3b2",
"metadata": {
"scrolled": true
Expand Down Expand Up @@ -142,7 +118,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"id": "73834767-d40d-4c14-bf35-8fb66c88b862",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -176,7 +152,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"id": "4aceff97-684d-4288-b2d7-b051679b72b5",
"metadata": {},
"outputs": [],
Expand All @@ -186,24 +162,24 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"id": "30ecb602-7b65-4ab9-9c08-d9e0ccbb46ec",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[########################################] | 100% Completed | 2.30 ss\n"
"[########################################] | 100% Completed | 3.81 ss\n"
]
},
{
"data": {
"text/plain": [
"<abtem.waves.Waves at 0x17c0de7b0>"
"<abtem.waves.Waves at 0x7047b970ba90>"
]
},
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -214,7 +190,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"id": "560d0d60-361c-4a71-a7f2-0a73ad0c8ba1",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -277,7 +253,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"id": "56a07873-35e9-4519-9db4-edd7db32cc82",
"metadata": {},
"outputs": [],
Expand All @@ -287,30 +263,15 @@
"x = np.fft.fftfreq(s[0], 1/s[0])\n",
"y = np.fft.fftfreq(s[1], 1/s[1])\n",
"\n",
"yy, xx = np.meshgrid(x, y)\n"
"yy, xx = np.meshgrid(x, y)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 12,
"id": "fd12f232-8f93-4cbf-b1c6-b983e0210dbf",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b48f69644adc45828bde303cad98dcda",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Canvas(footer_visible=False, header_visible=False, layout=Layout(height='400px', width='675px')…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"with plt.ioff():\n",
" dpi = 72\n",
Expand Down Expand Up @@ -446,8 +407,6 @@
")\n",
"\n",
"\n",
"\n",
"\n",
"fig.canvas.resizable = False\n",
"fig.canvas.header_visible = False\n",
"fig.canvas.footer_visible = False\n",
Expand All @@ -465,18 +424,40 @@
" )\n",
" # ),\n",
" ],\n",
")\n",
"\n",
"display(widget);\n",
"#\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "e23e1caa-d087-492c-b58c-2c0cd05cbf53",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a2c3b236f157477eb53a95171e36caf6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Canvas(footer_visible=False, header_visible=False, layout=Layout(height='400px', width='675px')…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#| label: app:tem_imaging\n",
"\n",
"# plt.show()"
"display(widget);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e23e1caa-d087-492c-b58c-2c0cd05cbf53",
"id": "f2f7f1cd-20dd-4081-93d3-bad9ef653fca",
"metadata": {},
"outputs": [],
"source": []
Expand All @@ -498,7 +479,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
182 changes: 182 additions & 0 deletions notebooks/08.2_TEM_diffraction.ipynb

Large diffs are not rendered by default.

355 changes: 0 additions & 355 deletions notebooks/TEM_diffraction.ipynb

This file was deleted.

0 comments on commit 423bdb9

Please sign in to comment.