Skip to content

Commit 64206a2

Browse files
committed
fixed a bug in README, added argument type check in featurize()
1 parent 3fee823 commit 64206a2

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

README.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,31 @@ or a pair of 3D arrays containing 2D intensity and mask images. There is also tw
7777
from nyxus import Nyxus
7878
import numpy as np
7979

80-
8180
nyx = Nyxus(["*ALL*"])
8281

83-
intens = [
82+
intens = np.array([
8483
[[1, 4, 4, 1, 1],
85-
[1, 4, 6, 1, 1],
86-
[4, 1, 6, 4, 1],
87-
[4, 4, 6, 4, 1]],
84+
[1, 4, 6, 1, 1],
85+
[4, 1, 6, 4, 1],
86+
[4, 4, 6, 4, 1]],
8887

8988
[[1, 4, 4, 1, 1],
90-
[1, 1, 6, 1, 1],
91-
[1, 1, 3, 1, 1],
92-
[4, 4, 6, 1, 1]]
93-
]
89+
[1, 1, 6, 1, 1],
90+
[1, 1, 3, 1, 1],
91+
[4, 4, 6, 1, 1]]
92+
])
9493

95-
seg = [
94+
seg = np.array([
9695
[[1, 1, 1, 1, 1],
97-
[1, 1, 1, 1, 1],
98-
[1, 1, 1, 1, 1],
99-
[1, 1, 1, 1, 1]],
96+
[1, 1, 1, 1, 1],
97+
[1, 1, 1, 1, 1],
98+
[1, 1, 1, 1, 1]],
10099

101100
[[1, 1, 1, 1, 1],
102-
[1, 1, 1, 1, 1],
103-
[0, 1, 1, 1, 1],
104-
[1, 1, 1, 1, 1]]
105-
]
106-
101+
[1, 1, 1, 1, 1],
102+
[0, 1, 1, 1, 1],
103+
[1, 1, 1, 1, 1]]
104+
])
107105

108106
features = nyx.featurize(intens, seg)
109107
```

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)