Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error executing example code #115

Closed
haesleinhuepf opened this issue May 20, 2023 · 4 comments
Closed

Error executing example code #115

haesleinhuepf opened this issue May 20, 2023 · 4 comments

Comments

@haesleinhuepf
Copy link

Hi all,

I'm amazed by the napari-nyxus plugin and thus wanted to try this out using Python. I have some issues executing the example code from the readme. When I execute this (source):

from nyxus import Nyxus
import numpy as np


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

intens = [
    [[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]],
                
    [[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)

I receive this error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[1], line 32
      7 intens = [
      8     [[1, 4, 4, 1, 1],
      9         [1, 4, 6, 1, 1],
   (...)
     16     [4, 4, 6, 1, 1]]
     17 ]
     19 seg = [
     20     [[1, 1, 1, 1, 1],
     21     [1, 1, 1, 1, 1],
   (...)
     28     [1, 1, 1, 1, 1]]
     29 ]
---> 32 features = nyx.featurize(intens, seg)

File ~\mambaforge\envs\bio39\lib\site-packages\nyxus\nyxus.py:183, in Nyxus.featurize(self, intensity_files, mask_files)
    180 if mask_files is None:
    181     raise IOError ("The list of segment file paths is empty")
--> 183 header, string_data, numeric_data = featurize_fname_lists_imp (intensity_files, mask_files)
    185 df = pd.concat(
    186     [
    187         pd.DataFrame(string_data, columns=header[: string_data.shape[1]]),
   (...)
    190     axis=1,
    191 )
    193 # Labels should always be uint.

RuntimeError: Unable to cast Python instance of type <class 'list'> to C++ type 'std::basic_string<char,std::char_traits<char>,std::allocator<char> >'

Let me know if I can help tracing down the issue!

Best,
Robert

@haesleinhuepf
Copy link
Author

I installed nyxus using this command:

mamba install nyxus -c conda-forge

And version 0.4.2 got installed.

@haesleinhuepf
Copy link
Author

When executing it with pip:

pip install nyxus==0.5.0

The error after executing the code above is different:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 32
      7 intens = [
      8     [[1, 4, 4, 1, 1],
      9         [1, 4, 6, 1, 1],
   (...)
     16     [4, 4, 6, 1, 1]]
     17 ]
     19 seg = [
     20     [[1, 1, 1, 1, 1],
     21     [1, 1, 1, 1, 1],
   (...)
     28     [1, 1, 1, 1, 1]]
     29 ]
---> 32 features = nyx.featurize(intens, seg)

File ~\mambaforge\envs\bio39\lib\site-packages\nyxus\nyxus.py:189, in Nyxus.featurize(self, intensity_images, label_images, intensity_names, label_names)
    162 """Extract features from a single image pair in a 2D np.array or for all the images in a 3D np.array.
    163 
    164 Extracts all the requested features _at the image level_ from the images
   (...)
    185     per image.
    186 """
    188 # verify dimensions of images are the same
--> 189 if(intensity_images.ndim == 2):
    190     if(label_images.ndim != 2):
    191         raise ValueError("Both intensity and label arrays must be the same dimension")

AttributeError: 'list' object has no attribute 'ndim'

@friskluft
Copy link
Member

Thanks for the bug report Robert! We will fix it promptly.
Cheers,
= A

@friskluft
Copy link
Member

Hi Robert,
Thanks again for your feedback on Nyxus. The bug is fixed in Nyxus 0.6.0 released today, so please update your Nyxus installation. We look forward to hear feedback from you!
Cheers,
Nyxus team

@hsidky hsidky closed this as completed Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants