Skip to content

Commit ff7486f

Browse files
Switch to furo theme + add docs
1 parent 316cf6a commit ff7486f

File tree

6 files changed

+48
-17
lines changed

6 files changed

+48
-17
lines changed

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ python:
1414
install:
1515
- requirements: requirements.txt
1616
- method: pip
17-
path: .
17+
path: .

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
# The theme to use for HTML and HTML Help pages. See the documentation for
4848
# a list of builtin themes.
4949
#
50-
html_theme = 'alabaster'
50+
html_theme = 'furo'
5151

5252
# Add any paths that contain custom static files (such as style sheets) here,
5353
# relative to this directory. They are copied after the builtin static files,

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ types-PyYAML
99
types-setuptools
1010
sphinx
1111
versioneer
12+
furo

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
name="scip",
1010
version=versioneer.get_version(),
1111
cmdclass=versioneer.get_cmdclass(),
12-
package_dir={"scip": "src/scip"},
12+
package_dir={"": "src"},
1313
packages=setuptools.find_packages(where="src"),
1414
install_requires=[
1515
'numpy',

src/scip/features/feature_extraction.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""Functions for extracting features from images.
2+
"""
3+
4+
from typing import Iterable, Mapping, Any
5+
16
import dask
27
import dask.bag
38
import dask.dataframe
@@ -7,7 +12,7 @@
712
from .texture import texture_features, _texture_features_meta
813

914

10-
def _bbox_features_meta(channel_names):
15+
def _bbox_features_meta(channel_names: Iterable[str]) -> Mapping[str, type]:
1116
d = {
1217
"bbox_minr": float,
1318
"bbox_minc": float,
@@ -18,7 +23,19 @@ def _bbox_features_meta(channel_names):
1823
return d
1924

2025

21-
def bbox_features(p, channel_names):
26+
def bbox_features(p: Mapping, channel_names: Iterable[str]) -> Mapping[str, Any]:
27+
"""Extracts bbox features from image.
28+
29+
The bbox consist of four values: bbox_minr, bbox_minc, bbox_maxr, bbox_maxc.
30+
31+
Args:
32+
p (Mapping): Contains a sequence of 4 numbers under key bbox.
33+
channel_names (Iterable[str]): names of channels in the image.
34+
35+
Returns:
36+
Mapping[str, Any]: extracted features.
37+
"""
38+
2239
d = {
2340
"bbox_minr": p["bbox"][0],
2441
"bbox_minc": p["bbox"][1],
@@ -35,16 +52,25 @@ def extract_features( # noqa: C901
3552
channel_names: list,
3653
types: list,
3754
maximum_pixel_value: int,
38-
loader_meta: dict = {}
55+
loader_meta: Mapping[str, type] = {}
3956
) -> dask.dataframe.DataFrame:
40-
"""
41-
Extract features from pixel data
42-
43-
Args:
44-
images (dask.bag): bag containing dictionaries of image data
57+
"""Extracts requested features from pixel values in images.
58+
59+
Keyword Args:
60+
images (dask.bag.Bag): bag of mappings containing image data. Check each feature
61+
extraction method (:func:`bbox_features`, :func:`scip.features.intensity.intensity_features`,
62+
:func:`shape_features` and :func:`texture_features`) to see what keys
63+
must be present in each mapping.
64+
channel_names (list): names of channels in the image.
65+
types (list): feature types to be extracted from the image.
66+
maximum_pixel_value (int): theoretical maximal value in the image.
67+
loader_meta (Mapping[str, type], optional): data type mapping of meta keys extracted
68+
by the loader. Defaults to {}.
4569
4670
Returns:
47-
dask.bag: bag containing dictionaries of image features
71+
dask.dataframe.DataFrame:
72+
dataframe containing all extracted features (columns) for all
73+
images (rows) in the input bag.
4874
"""
4975

5076
def features_partition(part):

src/scip/features/intensity.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Mapping, List, Any
2+
13
import numpy
24
import scipy.stats
35
from scipy.ndimage import convolve
@@ -17,7 +19,7 @@
1719
]
1820

1921

20-
def _intensity_features_meta(channel_names):
22+
def _intensity_features_meta(channel_names: List[str]) -> Mapping[str, type]:
2123
out = {}
2224
for i in channel_names:
2325
out.update({f"{p}_{i}": float for p in props})
@@ -31,7 +33,7 @@ def _intensity_features_meta(channel_names):
3133
return out
3234

3335

34-
def _row(pixels, i):
36+
def _row(pixels: numpy.ndarray, i: int) -> Mapping[str, Any]:
3537
quartiles = numpy.quantile(pixels, q=(0.25, 0.75))
3638

3739
d = {
@@ -51,7 +53,7 @@ def _row(pixels, i):
5153
return d
5254

5355

54-
def intensity_features(sample, channel_names):
56+
def intensity_features(sample: Mapping[str, Any], channel_names: List[str]) -> Mapping[str, Any]:
5557
"""Compute intensity features.
5658
5759
Find following intensity features based on masked pixel values:
@@ -76,10 +78,12 @@ def intensity_features(sample, channel_names):
7678
8. Background substracted edge values of union of masks
7779
7880
Args:
79-
sample (dict): dictionary including image data
81+
sample (Mapping): mapping with pixels, mask, combined_mask, background and
82+
combined background key.
83+
channel_names (List[str]): names of channels in the image.
8084
8185
Returns:
82-
dict: dictionary including computed intensity features
86+
Mapping[str, Any]: extracted features
8387
"""
8488

8589
features_dict = {}

0 commit comments

Comments
 (0)