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

TypeError: Invalid type conversion to ArrayImg [32x32x32] requested. #22

Closed
carshadi opened this issue Dec 15, 2022 · 1 comment
Closed

Comments

@carshadi
Copy link

Hi,

It appears I am not able to use the imglyb.to_numpy(rai) method

import imglyb
import scyjava

scyjava.start_jvm()

Views = imglyb.util.Views

ArrayImgs = scyjava.jimport("net.imglib2.img.array.ArrayImgs")

img = ArrayImgs.floats(32,32,32)
print(img.dimensionsAsLongArray())

arr = imglyb.to_numpy(img)

yields

[32, 32, 32]
Traceback (most recent call last):
  File "C:\Users\cameron.arshadi\Desktop\repos\imglyb\examples\wrap_arraylike.py", line 13, in <module>
    arr = imglyb.to_numpy(img)
          ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\cameron.arshadi\Miniconda3\envs\imglyb-test\Lib\site-packages\imglyb\__init__.py", line 25, in to_numpy
    return _ImgLibReferenceGuard(source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\cameron.arshadi\Miniconda3\envs\imglyb-test\Lib\site-packages\imglyb\imglib_ndarray.py", line 67, in __new__
    address = get_address(rai)
              ^^^^^^^^^^^^^^^^
  File "C:\Users\cameron.arshadi\Miniconda3\envs\imglyb-test\Lib\site-packages\imglyb\imglib_ndarray.py", line 50, in get_address
    access = jpype.JObject(class_name_full, rai).update(None)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\cameron.arshadi\Miniconda3\envs\imglyb-test\Lib\site-packages\jpype\_jobject.py", line 59, in __new__
    return _JObjectFactory(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\cameron.arshadi\Miniconda3\envs\imglyb-test\Lib\site-packages\jpype\_jobject.py", line 113, in _JObjectFactory
    raise TypeError("Invalid type conversion to %s requested." % tp)
TypeError: Invalid type conversion to ArrayImg [32x32x32] requested.

I used a fresh conda environment on WIndows 10

conda create -n imglyb-test -c conda-forge python=3.9 imglyb
conda activate imglyb-test

Downgrading jpype to 1.4.0 and 1.3.0 did not help

Output of conda list

# packages in environment at C:\Users\cameron.arshadi\Miniconda3\envs\imglyb-test:
#
# Name                    Version                   Build  Channel
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2022.12.7            h5b45459_0    conda-forge
imglyb                    2.0.1              pyh8a188c0_0    conda-forge
intel-openmp              2022.2.1         h57928b3_19741    conda-forge
jgo                       1.0.4              pyhd8ed1ab_0    conda-forge
jpype1                    1.3.0            py39h2e07f2f_2    conda-forge
libblas                   3.9.0              16_win64_mkl    conda-forge
libcblas                  3.9.0              16_win64_mkl    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libhwloc                  2.8.0                h039e092_1    conda-forge
libiconv                  1.17                 h8ffe710_0    conda-forge
liblapack                 3.9.0              16_win64_mkl    conda-forge
libsqlite                 3.40.0               hcfcfb64_0    conda-forge
libxml2                   2.10.3               hc3477c8_0    conda-forge
libzlib                   1.2.13               hcfcfb64_4    conda-forge
maven                     3.8.6                h57928b3_0    conda-forge
mkl                       2022.1.0           h6a75c08_874    conda-forge
numpy                     1.23.5           py39hbccbffa_0    conda-forge
openjdk                   17.0.3               h57928b3_4    conda-forge
openssl                   3.0.7                hcfcfb64_1    conda-forge
packaging                 22.0               pyhd8ed1ab_0    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
psutil                    5.9.4            py39ha55989b_0    conda-forge
pthreads-win32            2.9.1                hfa6e2cd_3    conda-forge
python                    3.9.15          h4de0772_0_cpython    conda-forge
python_abi                3.9                      3_cp39    conda-forge
scyjava                   1.8.1              pyhd8ed1ab_0    conda-forge
setuptools                65.5.1             pyhd8ed1ab_0    conda-forge
symlink-exe-runtime       1.0                  hcfcfb64_0    conda-forge
tbb                       2021.7.0             h91493d7_1    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
vc                        14.3                 h3d8a991_9    conda-forge
vs2015_runtime            14.32.31332          h1d6e394_9    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h8d14728_0    conda-forge
@carshadi
Copy link
Author

Update: installing from source fixed the issue

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

1 participant