Skip to content

Commit 7dea62d

Browse files
authored
Merge pull request #118 from friskluft/POL3116_bugfix_issue_115
POL 3116 bugfix in README.md example and typecheck in featurize()
2 parents 9a8df7b + 53a3f21 commit 7dea62d

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,23 @@ or a pair of 3D arrays containing 2D intensity and mask images. There is also tw
7676
```python
7777
from nyxus import Nyxus
7878
import numpy as np
79+
7980
nyx = Nyxus(["*ALL*"])
80-
intens = [
81+
82+
intens = np.array([
8183
[[1, 4, 4, 1, 1],
8284
[1, 4, 6, 1, 1],
8385
[4, 1, 6, 4, 1],
8486
[4, 4, 6, 4, 1]],
85-
[[1, 4, 4, 1, 1],
86-
[1, 1, 6, 1, 1],
87-
[1, 1, 3, 1, 1],
88-
[4, 4, 6, 1, 1]]
89-
]
90-
seg = [
91-
[[1, 1, 1, 1, 1],
92-
[1, 1, 1, 1, 1],
93-
[1, 1, 1, 1, 1],
94-
[1, 1, 1, 1, 1]],
87+
])
88+
89+
seg = np.array([
9590
[[1, 1, 1, 1, 1],
9691
[1, 1, 1, 1, 1],
9792
[0, 1, 1, 1, 1],
9893
[1, 1, 1, 1, 1]]
99-
]
94+
])
95+
10096
features = nyx.featurize(intens, seg)
10197
```
10298

src/nyx/python/nyxus/nyxus.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ def featurize_directory(
203203

204204
def featurize(
205205
self,
206-
intensity_images: np.array,
207-
label_images: np.array,
206+
intensity_images: np.ndarray,
207+
label_images: np.ndarray,
208208
intensity_names: list = [],
209209
label_names: list = []
210210
):
@@ -218,9 +218,9 @@ def featurize(
218218
219219
Parameters
220220
----------
221-
intensity_dir : np.array
221+
intensity_images : np.ndarray
222222
2D image or 3D collection of intensity images.
223-
label_images : np.array
223+
label_images : np.ndarray
224224
2D image or 3D collection of label images.
225225
intensity_names (optional): list
226226
names for the images in for the DataFrame output.
@@ -234,6 +234,13 @@ def featurize(
234234
per image.
235235
"""
236236

237+
# verify argument types
238+
if not isinstance(intensity_images, np.ndarray):
239+
raise ValueError("intensity_images parameter must be numpy.ndarray")
240+
241+
if not isinstance(label_images, np.ndarray):
242+
raise ValueError("label_images parameter must be numpy.ndarray")
243+
237244
# verify dimensions of images are the same
238245
if(intensity_images.ndim == 2):
239246
if(label_images.ndim != 2):

0 commit comments

Comments
 (0)