Skip to content

Commit

Permalink
Merge pull request #118 from friskluft/POL3116_bugfix_issue_115
Browse files Browse the repository at this point in the history
POL 3116 bugfix in README.md example and typecheck in featurize()
  • Loading branch information
hsidky authored May 27, 2023
2 parents 9a8df7b + 53a3f21 commit 7dea62d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,23 @@ or a pair of 3D arrays containing 2D intensity and mask images. There is also tw
```python
from nyxus import Nyxus
import numpy as np

nyx = Nyxus(["*ALL*"])
intens = [

intens = np.array([
[[1, 4, 4, 1, 1],
[1, 4, 6, 1, 1],
[4, 1, 6, 4, 1],
[4, 4, 6, 4, 1]],
[[1, 4, 4, 1, 1],
[1, 1, 6, 1, 1],
[1, 1, 3, 1, 1],
[4, 4, 6, 1, 1]]
]
seg = [
[[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1]],
])

seg = np.array([
[[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
[0, 1, 1, 1, 1],
[1, 1, 1, 1, 1]]
]
])

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

Expand Down
15 changes: 11 additions & 4 deletions src/nyx/python/nyxus/nyxus.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def featurize_directory(

def featurize(
self,
intensity_images: np.array,
label_images: np.array,
intensity_images: np.ndarray,
label_images: np.ndarray,
intensity_names: list = [],
label_names: list = []
):
Expand All @@ -218,9 +218,9 @@ def featurize(
Parameters
----------
intensity_dir : np.array
intensity_images : np.ndarray
2D image or 3D collection of intensity images.
label_images : np.array
label_images : np.ndarray
2D image or 3D collection of label images.
intensity_names (optional): list
names for the images in for the DataFrame output.
Expand All @@ -234,6 +234,13 @@ def featurize(
per image.
"""

# verify argument types
if not isinstance(intensity_images, np.ndarray):
raise ValueError("intensity_images parameter must be numpy.ndarray")

if not isinstance(label_images, np.ndarray):
raise ValueError("label_images parameter must be numpy.ndarray")

# verify dimensions of images are the same
if(intensity_images.ndim == 2):
if(label_images.ndim != 2):
Expand Down

0 comments on commit 7dea62d

Please sign in to comment.