Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorials infrastructure: switch to text-based notebook workflow #59

Closed
wants to merge 38 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7ee54d5
Adding jupytext options to Makefile
Jun 23, 2021
0803983
Migrating from the "old" format: toc is not a mapping
Jun 23, 2021
55ff765
Moving builds to their folder
Jun 23, 2021
f3bf746
Building site instead of book
Jun 23, 2021
de2d146
Adding Makefile on website
Jun 23, 2021
e345a61
Removing website Makefile refs
Jun 23, 2021
1d4e64c
Adding website/conf.py
Jun 23, 2021
37c53d5
Starting index.md
Jun 23, 2021
3086296
Adding Indices and tables to index.md
Jun 23, 2021
0c22b39
Ignoring website local builds
Jun 23, 2021
568fe59
An example — testing jupytext conversion
Jun 23, 2021
2437a6a
Adding example to toctree on index.md
Jun 23, 2021
831741f
Creating a link from website/images to ../images
Jun 23, 2021
e818bc4
Testing toc structure
Jun 23, 2021
747d842
Organizing folders
Jun 23, 2021
f217e16
Changing intro.md
Jun 24, 2021
9244886
Testing python instead of ipython3 on {code-cell}s
Sep 13, 2021
872d226
jb-article -> jb-book
Sep 14, 2021
9803c81
Adding more converted notebooks
Sep 14, 2021
7af90a1
Changing - to _ on adv3 filename
Sep 15, 2021
fa7fed3
Adding some of the newly converted notebooks to the toc
Sep 15, 2021
71f8a0b
Fix tabs in Makefile
stefanv Dec 2, 2021
ae4c3fe
Require book directory for building html
stefanv Dec 2, 2021
caea7c1
Fix incorrect build path
stefanv Dec 2, 2021
f18a5cd
website -> site
Dec 2, 2021
78a689b
website -> site
Dec 2, 2021
83728db
website -> site
Dec 2, 2021
d4325e7
Refactor the build system
stefanv Dec 3, 2021
9edcefd
Fix skdemo
stefanv Dec 3, 2021
ef683cc
Fix up color_and_exposure module
stefanv Dec 3, 2021
f95be21
Fix image links
stefanv Dec 3, 2021
28d0e4c
Fix notebooks; fix skdemo; fix notebook build path
stefanv Dec 3, 2021
4103ab0
Require imagecodecs for reading tiffs
stefanv Dec 3, 2021
db180a5
Fix filters imports
stefanv Dec 3, 2021
64cea04
threshold_adaptive is not threshold_local
stefanv Dec 3, 2021
bfcc8c5
Final fixes to adv0_chromosomes
stefanv Dec 3, 2021
ad248c4
Fix adv1_lesion_quantification
stefanv Dec 3, 2021
6edeb56
Fix adv2_microarray
stefanv Dec 10, 2021
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
Prev Previous commit
Next Next commit
Testing toc structure
alexdesiqueira committed Jun 23, 2021
commit e818bc425b85edc1d90a3cb23acf4788f66827e2
101 changes: 101 additions & 0 deletions website/content/adv1-lesion-quantification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.10.3
kernelspec:
display_name: Python 3
language: python
name: python3
---

```{code-cell} ipython3
from __future__ import division, print_function
%matplotlib inline
```

# Quantifying spinal cord regeneration in zebrafish

We want to quantify the amount of fluorescent cells in a wounded zebrafish embryo spinal column:

<img src="../images/zebrafish-spinal-cord-color.png" alt="Zebrafish spinal cord" style="width: 300px;"/>

The key steps are:

- estimating the position and width of the cord
- estimating the average fluorescence along the length of the cord

```{code-cell} ipython3
from matplotlib import pyplot as plt, cm
from skimage import io
image = io.imread('../images/zebrafish-spinal-cord.png')
```

# SciPy to estimate coordinates

First, we get just the top and bottom rows of pixels, and use a 1D gaussian filter to smooth the signal.

```{code-cell} ipython3
from scipy import ndimage as nd
top, bottom = image[[0, -1], :]

fig, (ax0, ax1) = plt.subplots(nrows=1, ncols=2, figsize=(8, 3))

top_smooth = nd.gaussian_filter1d(top, sigma=20)
ax0.plot(top, color='blue', lw=2)
ax0.plot(top_smooth, color='orange', lw=2)
ax0.set_title('top')

bottom_smooth = nd.gaussian_filter1d(bottom, sigma=20)
ax1.plot(bottom, color='blue', lw=2)
ax1.plot(bottom_smooth, color='orange', lw=2)
ax1.set_title('bottom')
```

With smooth curves, we can get the mode (the position of the center) and width of the signal.

```{code-cell} ipython3
top_mode = top_smooth.argmax()
top_max = top_smooth[top_mode]
top_width = (top_smooth > float(top_max) / 2).sum()

bottom_mode = bottom_smooth.argmax()
bottom_max = bottom_smooth[bottom_mode]
bottom_width = (bottom_smooth > float(bottom_max) / 2).sum()

width = max(bottom_width, top_width)

print(top_mode, top_width, bottom_mode, bottom_width)
```

# scikit-image to trace the profile

Now, use `measure.profile_line` to trace from (0, `top_mode`) to (-1, `bottom_mode`).

```{code-cell} ipython3
from skimage import measure
trace = measure.profile_line(None) # Replace `None` with correct args
```

Finally, plot the trace.

```{code-cell} ipython3
plt.plot(trace, color='black', lw=2)
plt.xlabel('position along embryo')
plt.ylabel('mean fluorescence intensity')
```

From this trace, we can compute various summary statistics (e.g. min/max, gap width, slope, etc), and plot these over time as the wound recovers.

+++

---

<div style="height: 400px;"></div>

```{code-cell} ipython3
%reload_ext load_style
%load_style ../themes/tutorial.css
```
10 changes: 10 additions & 0 deletions website/content/applications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# scikit-image applications

A collection of tutorials highlighting the use of scikit-image for applications in science.

```{toctree}
---
maxdepth: 1
---
content/adv1-lesion-quantification.md
```
3 changes: 2 additions & 1 deletion website/index.md
Original file line number Diff line number Diff line change
@@ -8,9 +8,10 @@

```{toctree}
---
maxdepth: 1
maxdepth: 2
---
content/00_images_are_arrays.md
applications
```