ChangLabUcsf / img_pipe

Image processing pipeline for ECoG data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

import error on mcubes

bendichter opened this issue · comments

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-50c45111854d> in <module>()
----> 1 import img_pipe

/Users/bendichter/Devel/img_pipe/img_pipe/__init__.py in <module>()
----> 1 from img_pipe import *

/Users/bendichter/Devel/img_pipe/img_pipe/img_pipe.py in <module>()
     23 from matplotlib import cm
     24 from matplotlib.backends.backend_pdf import PdfPages
---> 25 from surface_warping_scripts.make_outer_surf import make_outer_surf # From ielu
     26 from surface_warping_scripts.project_electrodes_anydirection import *
     27 

/Users/bendichter/Devel/img_pipe/img_pipe/surface_warping_scripts/make_outer_surf.py in <module>()
      5 from scipy.ndimage.morphology import grey_closing, generate_binary_structure
      6 from mne import write_surface
----> 7 from mcubes import marching_cubes
      8 
      9 def make_outer_surf(orig_pial, image, radius, outfile):

/Users/bendichter/anaconda/envs/python2/lib/python2.7/site-packages/mcubes/__init__.py in <module>()
      1 
----> 2 from ._mcubes import marching_cubes, marching_cubes_func
      3 from .exporter import export_mesh, export_obj

__init__.pxd in init _mcubes (mcubes/src/_mcubes.cpp:4164)()

ValueError: numpy.dtype has the wrong size, try recompiling

this error occurred when I downloaded via pypi and when I pip installed the master branch

Can you confirm which version of mcubes you have? Had you installed it previously?

I'm using 0.6.6. I just tried reinstalling PyMCubes and got the same import error when I tried import mcubes

Were you installing PyMCubes from git (git clone, then python setup.py install), or were you pip installing pymcubes? It looks like the version on pip is still 0.0.6 and was last updated in 2016, whereas there were some new edits to the git repo (https://github.com/pmneila/PyMCubes) as of two months ago.

I would try posting this issue on the PyMCubes github then, since it's not img_pipe specific. As for a workaround I can have it so it only imports that library if required for the steps you're doing -- this is only used to make the smoothed dural surface for projecting electrodes to... will look at this in the next few days.

Liberty passed the puck to pymcubes, pymcubes passed the puck to cython/backports_abc, and in that library there is a closed issue that resembles my problem that is supposed to be fixed. I've tried making a new conda env and upgrading numpy, cython, pymcubes, and backports_abc. Several of these I also tried installing from the latest git master. Nothin has worked. I have a hunch it has to do with virtual envs using cython, but my default is python 3, so I have to go virtual. Liberty, would you mind changing the imports so you only import mcubes when necessary?

Done. Could you do a git pull and check to see whether it imports for you now?

Also pasting the response from pymcubes for those interested: "This is a known (and fixed) bug in Cython. See cython/cython#1507 and cython/backports_abc#7. It seems you are using an old version of Cython. Can you update your Anaconda packages?"

Wanted to add that we think this was likely a result of having two python installations (2.7 and 3) -- Ben updated numpy in 2.7 and turned off some of the initial imports for matplotlib and numpy that he had in an init file, and now both importing mcubes and import img_pipe work.