Skip to content

Commit 07c0d39

Browse files
committed
docs: add example
1 parent 571c6a7 commit 07c0d39

File tree

6 files changed

+62
-1
lines changed

6 files changed

+62
-1
lines changed

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
0.3.0
22
- ref: renamed `meta.DATA_KEYS` to `meta.DATA_KEYS_FL` and removed
33
keys that are not relevant for fluorescence imaging
4-
- docs: initial documentation with code reference
4+
- docs: initial documentation with code reference and example
55
0.2.1
66
- maintenance release
77
0.2.0

docs/sec_examples.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Examples
66
:maxdepth: 2
77

88

9+
.. fancy_include:: simple_fluorescence.py

examples/data/retina_p10.h5

94.8 KB
Binary file not shown.

examples/generate_example_images.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import os
2+
import os.path as op
3+
import sys
4+
5+
import matplotlib.pylab as plt
6+
7+
thisdir = op.dirname(op.abspath(__file__))
8+
sys.path.insert(0, op.dirname(thisdir))
9+
10+
DPI = 80
11+
12+
13+
if __name__ == "__main__":
14+
# Do not display example plots
15+
plt.show = lambda: None
16+
files = os.listdir(thisdir)
17+
files = [f for f in files if f.endswith(".py")]
18+
files = [f for f in files if not f == op.basename(__file__)]
19+
files = sorted([op.join(thisdir, f) for f in files])
20+
21+
for f in files:
22+
fname = f[:-3] + ".jpg"
23+
if not op.exists(fname):
24+
exec_str = open(f).read()
25+
if exec_str.count("plt.show()"):
26+
exec(exec_str)
27+
plt.savefig(fname, dpi=DPI)
28+
print("Image created: '{}'".format(fname))
29+
else:
30+
print("No image: '{}'".format(fname))
31+
else:
32+
print("Image skipped (already exists): '{}'".format(fname))
33+
plt.close()

examples/simple_fluorescence.jpg

19.8 KB
Loading

examples/simple_fluorescence.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Loading and plotting
2+
3+
This example illustrates the simple usage of the
4+
:class:`flimage.FLImage <flimage.core.FLImage>` class for reading and
5+
managing quantitative phase data. The attribute ``FLImage.fluorescence``
6+
yields the image data.
7+
8+
The image shows a young retina cell. The original dataset, available on
9+
`figshare <https://doi.org/10.6084/m9.figshare.8055407.v1>`_
10+
(*retina-young_sinogram_fli.h5*) :cite:`Schuermann2017`, can be opened in
11+
the same manner using the
12+
:class:`flimage.FLSeries <flimage.series.FLSeries>` class.
13+
"""
14+
import matplotlib.pylab as plt
15+
import flimage
16+
17+
# load the experimental data
18+
fli = flimage.FLImage(h5file="./data/retina_p10.h5", h5mode="r")
19+
20+
# plot
21+
plt.figure(figsize=(4, 3))
22+
23+
plt.subplot(title="fluorescence image of a mouse retina cell")
24+
plt.imshow(fli.fl, cmap="YlGnBu_r")
25+
26+
plt.tight_layout()
27+
plt.show()

0 commit comments

Comments
 (0)