Skip to content

Commit ebfe7ef

Browse files
authored
Merge pull request #2 from espdev/refactoring-and-docs
Refactoring and docs
2 parents 6173870 + 6604fd1 commit ebfe7ef

19 files changed

+1168
-334
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ matrix:
99
env: TOXENV=py37-pytest-coverage
1010
- python: "3.8"
1111
env: TOXENV=py38-pytest
12-
12+
- python: "3.7"
13+
env: TOXENV=docs
1314
- python: "3.7"
1415
env: TOXENV=flake8
1516

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v0.2.0 (27.05.2020)
4+
5+
- Refactoring the package with changing some low-level API
6+
- Add documentation
7+
38
## v0.1.1
49

510
- Fix links

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ plt.show()
6161

6262
The full documentation can be found at [scikit-mpe.readthedocs.io](https://scikit-mpe.readthedocs.io/en/latest)
6363

64-
(The documentation is being written)
65-
6664
## References
6765

6866
- [Fast Marching Methods: A boundary value formulation](https://math.berkeley.edu/~sethian/2006/Explanations/fast_marching_explain.html)

docs/api.rst

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.. _api:
2+
3+
*************
4+
API Reference
5+
*************
6+
7+
.. currentmodule:: skmpe
8+
9+
API Summary
10+
===========
11+
12+
.. autosummary::
13+
:nosignatures:
14+
15+
InitialInfo
16+
PathInfo
17+
PathInfoResult
18+
19+
TravelTimeOrder
20+
OdeSolverMethod
21+
Parameters
22+
parameters
23+
default_parameters
24+
25+
MPEError
26+
ComputeTravelTimeError
27+
PathExtractionError
28+
EndPointNotReachedError
29+
30+
PathExtractionResult
31+
MinimalPathExtractor
32+
mpe
33+
34+
|
35+
36+
Data and Models
37+
===============
38+
39+
.. autoclass:: InitialInfo
40+
:members:
41+
42+
.. autoclass:: PathInfo
43+
:show-inheritance:
44+
45+
.. autoclass:: PathInfoResult
46+
:show-inheritance:
47+
48+
Parameters
49+
==========
50+
51+
.. autoclass:: TravelTimeOrder
52+
:members:
53+
:undoc-members:
54+
:show-inheritance:
55+
56+
.. autoclass:: OdeSolverMethod
57+
:members:
58+
:undoc-members:
59+
:show-inheritance:
60+
61+
.. autoclass:: Parameters
62+
:members:
63+
:undoc-members:
64+
65+
.. autofunction:: parameters
66+
.. autofunction:: default_parameters
67+
68+
Exceptions
69+
==========
70+
71+
.. autoclass:: MPEError
72+
:show-inheritance:
73+
74+
.. autoclass:: ComputeTravelTimeError
75+
:show-inheritance:
76+
77+
.. autoclass:: PathExtractionError
78+
:members:
79+
:show-inheritance:
80+
81+
.. autoclass:: EndPointNotReachedError
82+
:members:
83+
:inherited-members: PathExtractionError
84+
:exclude-members: with_traceback
85+
:show-inheritance:
86+
87+
Path Extraction
88+
===============
89+
90+
.. autoclass:: PathExtractionResult
91+
:show-inheritance:
92+
93+
.. autoclass:: MinimalPathExtractor
94+
:members:
95+
:special-members: __call__
96+
97+
.. autofunction:: mpe

docs/conf.py

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def get_author():
6565
plot_apply_rcparams = True
6666
plot_rcparams = {
6767
'figure.autolayout': 'True',
68-
'figure.figsize': '5, 3.5',
6968
'savefig.bbox': 'tight',
7069
'savefig.facecolor': "None",
7170
}

docs/examples.rst

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.. _examples:
2+
3+
********
4+
Examples
5+
********
6+
7+
Retina Vessels
8+
==============
9+
10+
Extracting the minimal path through the retina vessels with additional way points.
11+
12+
.. plot::
13+
14+
from skimage.data import retina
15+
from skimage.color import rgb2gray
16+
from skimage.transform import rescale
17+
from skimage.filters import sato
18+
19+
from skmpe import mpe
20+
21+
image = rescale(rgb2gray(retina()), 0.5)
22+
speed_image = sato(image)
23+
24+
start_point = (76, 388)
25+
end_point = (611, 442)
26+
way_points = [(330, 98), (554, 203)]
27+
28+
path_info = mpe(speed_image, start_point, end_point, way_points)
29+
30+
px, py = path_info.path[:, 1], path_info.path[:, 0]
31+
32+
plt.imshow(image, cmap='gray')
33+
plt.plot(px, py, '-r')
34+
plt.plot(*start_point[::-1], 'oy')
35+
plt.plot(*end_point[::-1], 'og')
36+
for p in way_points:
37+
plt.plot(*p[::-1], 'ob')
38+
plt.axis('off')
39+
40+
41+
Bricks
42+
======
43+
44+
Extracting the shortest paths through "bricks" image.
45+
46+
.. plot::
47+
48+
from skimage.data import brick
49+
from skimage.transform import rescale
50+
from skimage.exposure import rescale_intensity, adjust_sigmoid
51+
52+
from skmpe import parameters, mpe
53+
54+
image = rescale(brick(), 0.5)
55+
speed_image = rescale_intensity(
56+
adjust_sigmoid(image, cutoff=0.5, gain=10).astype(np.float_), out_range=(0., 1.))
57+
58+
start_point = (44, 13)
59+
end_point = (233, 230)
60+
way_points = [(211, 59), (17, 164)]
61+
62+
with parameters(integrate_max_step=1.0):
63+
path_info1 = mpe(speed_image, start_point, end_point)
64+
path_info2 = mpe(speed_image, start_point, end_point, way_points)
65+
66+
px1, py1 = path_info1.path[:, 1], path_info1.path[:, 0]
67+
px2, py2 = path_info2.path[:, 1], path_info2.path[:, 0]
68+
69+
plt.imshow(image, cmap='gray')
70+
plt.plot(px1, py1, '-r', linewidth=2)
71+
plt.plot(px2, py2, '--r', linewidth=2)
72+
73+
plt.plot(*start_point[::-1], 'oy')
74+
plt.plot(*end_point[::-1], 'og')
75+
for p in way_points:
76+
plt.plot(*p[::-1], 'ob')
77+
plt.axis('off')

docs/index.rst

+37-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,47 @@ scikit-mpe
66
**scikit-mpe** is a package for extracting a minimal path in n-dimensional Euclidean space (on regular Cartesian grids)
77
using `the fast marching method <https://math.berkeley.edu/~sethian/2006/Explanations/fast_marching_explain.html>`_.
88

9+
The package can be used in various engineering and image processing tasks.
10+
For example, it can be used for extracting paths through tubular structures on 2-d and 3-d images,
11+
or shortest paths on terrain maps.
12+
13+
Installing
14+
----------
15+
16+
Python 3.6 or above is supported. You can install the package using pip::
17+
18+
pip install -U scikit-mpe
19+
20+
21+
A Simple Example
22+
----------------
23+
24+
Here is the simple example: how to extract 2-d minimal path using some speed data.
25+
26+
.. code-block:: python
27+
:linenos:
28+
29+
from skmpe import mpe
30+
31+
# Somehow speed data is calculating
32+
speed_data = get_speed_data()
33+
34+
# Extracting minimal path from the starting point to the ending point
35+
path_info = mpe(speed_data, start_point=(10, 20), end_point=(120, 45))
36+
37+
# Getting the path data in numpy ndarray
38+
path = path_info.path
39+
40+
41+
Contents
42+
--------
943

1044
.. toctree::
1145
:maxdepth: 2
12-
:caption: Contents:
1346

47+
tutorial
48+
examples
49+
api
1450
changelog
1551

1652

0 commit comments

Comments
 (0)