Giter Club home page Giter Club logo

Comments (17)

rcasero avatar rcasero commented on May 24, 2024 2

Same problem as @plooney.

Conda virtual environment with python 3.6.1, numpy 1.12.1 and scipy 0.19.0.

I install medpy with

$ pip install medpy
Collecting medpy
Requirement already satisfied: numpy>=1.6.1 in /home/rcasero/.conda/envs/cytometer/lib/python3.6/site-packages (from medpy)
Requirement already satisfied: scipy>=0.9.0 in /home/rcasero/.conda/envs/cytometer/lib/python3.6/site-packages (from medpy)
Installing collected packages: medpy
Successfully installed medpy-0.2.2

Then, importing load() fails

$ python -c 'from medpy.io import load'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/rcasero/.conda/envs/cytometer/lib/python3.6/site-packages/medpy/io/__init__.py", line 59, in <module>
    from .load import load
  File "/home/rcasero/.conda/envs/cytometer/lib/python3.6/site-packages/medpy/io/load.py", line 28, in <module>
    from . import header
  File "/home/rcasero/.conda/envs/cytometer/lib/python3.6/site-packages/medpy/io/header.py", line 27, in <module>
    from ..core import Logger
  File "/home/rcasero/.conda/envs/cytometer/lib/python3.6/site-packages/medpy/core/__init__.py", line 55, in <module>
    from .logger import Logger
  File "/home/rcasero/.conda/envs/cytometer/lib/python3.6/site-packages/medpy/core/logger.py", line 94
    raise RuntimeError, 'Only one instance of Logger is allowed!'
                      ^
SyntaxError: invalid syntax

from medpy.

loli avatar loli commented on May 24, 2024

Thanks for the information. Since I can't reproduce the error using Python 2, it seems to be an issue with Python 3 and singleton classes (using the factory method).

Can you reproduce the error using Python 2?

from medpy.

plooney avatar plooney commented on May 24, 2024

I get a little further in Python2 but I get this error when loading

medpy.core.exceptions.ImageLoadingError: Failes to load image 1/1_Prim.mha as Itk/Vtk MetaImage (.mhd, .mha/.raw). Reason signaled by third-party module: 'LazyITKModule' object has no attribute 'AnalyzeImageIO

from medpy.

loli avatar loli commented on May 24, 2024

This problem stems from way ITK has been wrapped, not from MedPy.

When wrapping ITK for Python using WrapITK, each class desired has to be included explicitly. WrapITK does not provide a complete interface to ITK by itself.

Your version does not seem to include the itkAnalyzeImageIO class required by MedPy to load images. This probably means that the optional ITK module "IO" has not been included during compilation. You will have to compile it again.

Could you tell me, how you've acquired the ITK Python wrappings? And what configuration (with cmake) you've used? Best post a copy of your ccmake config.

For now, try to stick to image formats supported by NiBabel (see http://pythonhosted.org//MedPy/information/imageformats.html).

from medpy.

MMRohe avatar MMRohe commented on May 24, 2024

Hello, I have exactly the same problem with medpy :
medpy.core.exceptions.ImageLoadingError: Failes to load image .../image.mha as Itk/Vtk MetaImage (.mhd, .mha/.raw). Reason signaled by third-party module: 'LazyITKModule' object has no attribute 'AnalyzeImageIO'

The problem is that the said module "AnalyzeImageIO" is deprecated under ITKv4 (which has already been running for quite a long time) so I don't really udnerstand how is it that medpy still needs it (http://www.itk.org/Doxygen42/html/classitk_1_1AnalyzeImageIO.html) ? Does it mean that I need to install ITKv3 to get medpy working with python?

Am I missing something here ?

Here is my CMake configuration for ITK v 4.7.2:

CMakeCache.txt

from medpy.

loli avatar loli commented on May 24, 2024

Dear MMRohe,

thank you for reporting this and attaching your CMake config. As far as I can see, everything seems to be in order. MedPy has actually been testen with ITK 4.7 (http://pythonhosted.org/MedPy/installation/itkwrapper4.7.html), so I can't find the error immediately. You even have ITKV3_COMPATIBILITY=ON set, hence the AnalyzeImageIO should be available.

Today I am not a machine with ITK. I will look into the issue tomorrow and come back to you.

To tell the truth, keeping up with the changes in ITK and the very buggy behaviour of its Python Wrapper is very tedious and I often miss recent changes. I tend to use Convert3D (http://sourceforge.net/p/c3d/git/ci/master/tree/doc/c3d.md) to convert all images to NIfTI format and work with them, which improves stability and avoids loading the very large itk python module.

Best,
loli

from medpy.

MMRohe avatar MMRohe commented on May 24, 2024

Hello loli,

thanks for your answer. I also use Nifti format and using it to make it
work with Python could be a solution but with the data I am working on
at the moment it would not be very convenient.

Indeed, the problem is quite weird. One thing I could think of, is that
either the medpy version is outdated or the version of ITK that medPy is
linked to is not the correct one (because I have several ITK versions on
my computer) but I have double checked the link and the other ITK do not
have the python wrapper built in anyway. Do you know if there is command
inside python that could show exactly which version of the module it is
using (I tried print medpy.version or print itk.version but
these attributes dont exist).

Anyway, thanks a lot for your help, if you manage to get a solution or
have any idea don't hesitate to contact me :)

Best,

Marc-Michel

On 01/11/2016 02:21 PM, loli wrote:

Dear MMRohe,

thank you for reporting this and attaching your CMake config. As far
as I can see, everything seems to be in order. MedPy has actually been
testen with ITK 4.7
(http://pythonhosted.org/MedPy/installation/itkwrapper4.7.html), so I
can't find the error immediately. You even have ITKV3_COMPATIBILITY=ON
set, hence the AnalyzeImageIO should be available.

Today I am not a machine with ITK. I will look into the issue tomorrow
and come back to you.

To tell the truth, keeping up with the changes in ITK and the very
buggy behaviour of its Python Wrapper is very tedious and I often miss
recent changes. I tend to use Convert3D
(http://sourceforge.net/p/c3d/git/ci/master/tree/doc/c3d.md) to
convert all images to NIfTI format and work with them, which improves
stability and avoids loading the very large itk python module.

Best,
loli


Reply to this email directly or view it on GitHub
#6 (comment).

from medpy.

loli avatar loli commented on May 24, 2024

The ITK wrappers are fragile things. Trying

import inspect
import itk
inspect.getfile(itk)

tells me that it is an build-in module, which we know to be false. Well, nothing to be done about it. I could simply look at my PYTHONPATH to figure out, which one I am using.

Currently, I am still compiling ITK 4.7, I will come back to you later. It might take till next week, I fear :/

Best,
loli

from medpy.

loli avatar loli commented on May 24, 2024

Fixed with the newest commit to
https://github.com/loli/medpy/

Enjoy!
loli

from medpy.

MMRohe avatar MMRohe commented on May 24, 2024

thx for your answer ! (and sorry I did not reply back earlier, had some
problem with my comp so could not try it)

so it seems the update has fixed the previous issue but not I get the
following message. It seems weird that it calls the load_nibabel
function for a .mha image ?

ImageLoadingError Traceback (most recent call last)
in() 20 pathImage='image.mha'21 ---> 22image_data, image_header =
load(pathImage)23 #print
image_data.shape()/medpy-master/medpy/io/load.py in load(image) 199
logger.debug('Module {} signaled error: {}.'.format(loader, e))200 -->
201raise err202 203 def __load_nibabel(image):ImageLoadingError: Failes
to load image image.mha as Itk/Vtk MetaImage (.mhd, .mha/.raw). Reason
signaled by third-party module: 'module' object has no attribute 'swig'

On 01/13/2016 04:08 PM, loli wrote:

Fixed with the newest commit to
https://github.com/loli/medpy/

Enjoy!
loli


Reply to this email directly or view it on GitHub
#6 (comment).

from medpy.

loli avatar loli commented on May 24, 2024

Mhh... my version is loading MHA images just fine. Could you attached a zipped version of your image for me for testing?

The __load_nibabel error results from the way MedPy loads images: First, it tries to find the best module depending on the image type. If that loader fails, it tries all available ones on a brute-force basis and returns the error of the last one tested.

from medpy.

raghuramdr avatar raghuramdr commented on May 24, 2024

I don't know if this issue is still being tracked, but I am also having similar problems. When I try to load .mha files, I get a bunch of warnings, followed by the error:
*raise err
medpy.core.exceptions.ImageLoadingError: Failes to load image Registered-1808820224_Classification.mha as Itk/Vtk MetaImage (.mhd, .mha/.raw). Reason signaled by third-party module: 'LazyITKModule' object has no attribute 'AnalyzeImageIO'
*

I set the ITK V3_COMPATIBILITY flag = ON during make. I am using ITK 4.9 and I am using Python 2.7

from medpy.

loli avatar loli commented on May 24, 2024

Did you install the PYPI 2.2 or the GitHub develoment version?

from medpy.

sajjo79 avatar sajjo79 commented on May 24, 2024

Hi loli,
I am getting same error as of raghuramdr. How can i correct it .

Best

from medpy.

kiranvaidhya avatar kiranvaidhya commented on May 24, 2024

Same error as @rcasero

from medpy.

rcasero avatar rcasero commented on May 24, 2024

@loli , details on how to reproduce the error

  1. Install conda

    1. Download the Miniconda bash installer (e.g. for linux 64-bit, Miniconda2-latest-Linux-x86_64.sh).

    2. Make the script executable and run it as root

        cd ~/Downloads
        chmod u+x Miniconda2-latest-Linux-x86_64.sh
        sudo ./Miniconda2-latest-Linux-x86_64.sh
      
    3. When it asks for the install destination, select /opt/miniconda2, rather than the default /home/rcasero/miniconda2.

    4. "Do you wish the installer to prepend the Miniconda2 install location to PATH in your /home/rcasero/.bashrc ? [yes|no]". Select yes.

  2. Create a conda environment for the test (python 3.6 at the time of this writing)

     conda create --name test python=3
    
  3. Activate the conda environment

     source activate test
    
  4. Install medpy

     pip install medpy
    
  5. test medpy

     python -c 'from medpy.io import load'
     Traceback (most recent call last):
       File "<string>", line 1, in <module>
       File "/home/rcasero/.conda/envs/test/lib/python3.6/site-packages/medpy/io/__init__.py", line 59, in <module>
         from .load import load
       File "/home/rcasero/.conda/envs/test/lib/python3.6/site-packages/medpy/io/load.py", line 28, in <module>
         from . import header
       File "/home/rcasero/.conda/envs/test/lib/python3.6/site-packages/medpy/io/header.py", line 27, in <module>
         from ..core import Logger
       File "/home/rcasero/.conda/envs/test/lib/python3.6/site-packages/medpy/core/__init__.py", line 55, in <module>
         from .logger import Logger
       File "/home/rcasero/.conda/envs/test/lib/python3.6/site-packages/medpy/core/logger.py", line 94
         raise RuntimeError, 'Only one instance of Logger is allowed!'
                           ^
     SyntaxError: invalid syntax
    

from medpy.

loli avatar loli commented on May 24, 2024

This thread addresses two separate problems which are both solved.

Problem 1 raise RuntimeError, 'Only one instance of Logger is allowed!'
If you are encountering this problem, you are using Python 3. Officially, MedPy only supports Python 2. But, thanks for an effort from @mamrehn, the current master branch might just be Python 3 compatible. I.e., get the newest MedPy version from https://github.com/loli/medpy. (@rcasero and @kvrd18)

Problem 2 Reason signaled by third-party module: 'LazyITKModule' object has no attribute 'AnalyzeImageIO'
See Issue #15. Solved in the master current master branch. I.e., get the newest MedPy version from https://github.com/loli/medpy. (@raghuramdr and @sajjo79)

from medpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.