loli / medpy

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

Module has no attribute swig #68

Closed ysumath1 closed 6 years ago

ysumath1 commented 6 years ago

I want to save numpy array as a .mha or .mhd file.

Here is dummy code I tried: data, header = medpy.io.load('/home/sumathipalaya/Desktop/ERCNoERCNoBG/T2WI/39812763482/0.dcm') medpy.io.save(data, 'xxx.mhd', header)

Gives this error: ` medpy.io.save(data, 'xxx.mhd') Traceback (most recent call last):

File "", line 1, in medpy.io.save(data, 'xxx.mhd')

File "/home/sumathipalaya/anaconda2/lib/python2.7/site-packages/medpy/io/save.py", line 192, in save raise ImageSavingError('Failed to save image {} as type {}. Reason signaled by third-party module: {}'.format(filename, type_to_string[image_type], e))

ImageSavingError: Failed to save image xxx.mhd as type Itk/Vtk MetaImage (.mhd, .mha/.raw). Reason signaled by third-party module: 'module' object has no attribute 'swig'`

I am using medpy version 0.3.0 installed via pip on Python2; no errors or warnings during installation. The dependencies were install using Anaconda2, as I use this package manager. What am I doing wrong?

As an aside, is the header argument to medpy.io.save truly optional? If so, what does medpy impute for the spacing, origin, etc.?

loli commented 6 years ago

Regarding your second question: it's optional, but should be avoided. MedPy simply assumes unit spacing of 1 and zero origin.

loli commented 6 years ago

You error is a problem with ITK python wrappers, not MedPy. You can find suggestions on what might be wrong all over the net, e.g., https://public.kitware.com/pipermail/insight-users/2007-March/021213.html .