loli / medpy

Medical image processing in Python
http://loli.github.io/medpy/
GNU General Public License v3.0
571 stars 138 forks source link

ValueError on local_histogram #77

Closed pykao closed 5 years ago

pykao commented 5 years ago

Hello,

I am using medpy on python 3.6.5.

I am trying to use the function medpy.features.intensity.local_histogram but it gives me a ValueError: too many values to unpack ( expected 2 )

import numpy
from medpy.features.intensity import local_histogram
a = numpy.arange(125).reshape(5,5,5)
r = local_histogram(a, size=3)

Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pkao/.Envs/py36/lib/python3.6/site-packages/medpy/features/intensity.py", line 452, in local_histogram
    return _extract_feature(_extract_local_histogram, image, mask, bins=bins, rang=rang, cutoffp=cutoffp, size=size, footprint=footprint, output=output, mode=mode, origin=origin)
  File "/home/pkao/.Envs/py36/lib/python3.6/site-packages/medpy/features/intensity.py", line 781, in _extract_feature
    return fun(image, mask, **kwargs)
  File "/home/pkao/.Envs/py36/lib/python3.6/site-packages/medpy/features/intensity.py", line 605, in _extract_local_histogram
    output, _ = _get_output(numpy.float if None == output else output, image, shape = [bins] + list(image.shape))
ValueError: too many values to unpack (expected 2)

Best, Po-Yu Kao

loli commented 5 years ago

This seems to be an error caused by using python3. The 0.3.0 release of MedPy sadly does not support python3 yet.

You can try to use an automatically converted version under branch: https://github.com/loli/medpy/tree/Release_0.3.0p3 or even the development version for release 0.4.0: https://github.com/loli/medpy/tree/Release_0.4.0

These two branches of MedPy might work with Python3... but I cannot yet guarantee it.

Let me know, if this solved your problem.

Best, loli

pykao commented 5 years ago

Thank you for your reply. Finally, I switched to python 2.7 and it works now!

Best, Po-Yu

loli commented 5 years ago

Error seems to appear equally in P3 versions of MedPy.

Release_0.3.0p and Release_0.4.0

Check and fix.

loli commented 5 years ago

Fixed with 5a8fe50 after another report in #78