GrotjahnLab / surface_morphometrics

Morphometrics for Membrane Surfaces Segmented from Cryo-ET or other volumetric imaging.
GNU General Public License v3.0
18 stars 9 forks source link

Problem with executing python segmentation_to_meshes.py config.yml #22

Closed Kathir-66 closed 2 months ago

Kathir-66 commented 3 months ago

Once I am done with installing the additional dependencies. When I try to execute the python segmentation_to_meshes.py config.yml I get into the following errors.

First, the error is no module IPython

(morphometrics) kaezhila@kraken  ~/Programs/tmp_surface_morphometrics $ > python segmentation_to_meshes.py config.yml
Traceback (most recent call last):
  File "/home/kaezhila/Programs/tmp_surface_morphometrics/segmentation_to_meshes.py", line 25, in <module>
    import ply2vtp
  File "/home/kaezhila/Programs/tmp_surface_morphometrics/ply2vtp.py", line 16, in <module>
    from pycurv import pycurv_io as io
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pycurv/__init__.py", line 8, in <module>
    from .pycurv_io import *
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pycurv/pycurv_io.py", line 4, in <module>
    from pyto.io.image_io import ImageIO
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pyto/__init__.py", line 17, in <module>
    from . import clustering
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pyto/clustering/__init__.py", line 11, in <module>
    from .classification_results import ClassificationResults
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pyto/clustering/classification_results.py", line 19, in <module>
    from IPython.core.display import display, HTML
ModuleNotFoundError: No module named 'IPython'

So, I install ipython using conda install ipython Then when I try to execute again, I get the following error No module named 'statsmodels

(morphometrics) kaezhila@kraken  ~/Programs/tmp_surface_morphometrics $ > python segmentation_to_meshes.py config.yml
Traceback (most recent call last):
  File "/home/kaezhila/Programs/tmp_surface_morphometrics/segmentation_to_meshes.py", line 25, in <module>
    import ply2vtp
  File "/home/kaezhila/Programs/tmp_surface_morphometrics/ply2vtp.py", line 16, in <module>
    from pycurv import pycurv_io as io
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pycurv/__init__.py", line 8, in <module>
    from .pycurv_io import *
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pycurv/pycurv_io.py", line 4, in <module>
    from pyto.io.image_io import ImageIO
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pyto/__init__.py", line 17, in <module>
    from . import clustering
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pyto/clustering/__init__.py", line 12, in <module>
    from .contingency_stats import ContingencyStats
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pyto/clustering/contingency_stats.py", line 23, in <module>
    import statsmodels.api as sm
ModuleNotFoundError: No module named 'statsmodels

Then when I try to execute again, I get the following error ImportError: /lib64/libstdc++.so.6: versionGLIBCXX_3.4.29' not found (required by /home/kaezhila/.conda/envs/morphometrics/lib/python3.9/site-packages/graph_tool/libgraph_tool_core.so)`

so i do a symbolic link (morphometrics) kaezhila@kraken ~/Programs/tmp_surface_morphometrics $ > ln -sf /usr/lib64/libstdc++.so.6 /home/kaezhila/.conda/envs/morphometrics/lib/python3.9/site-packages/graph_tool/libgraph_tool_core.so

I end up with the following error. Can you help me from proceeding here

(morphometrics) kaezhila@kraken  ~/Programs/tmp_surface_morphometrics $ > python segmentation_to_meshes.py config.yml
Info: Module sympy could not be loaded. However, this is not a problem for running Pyto, because sympy is currently used only for development.
Warning: Pyseg could not be loaded. Therefore, calling from_pyseg() method of pyto.spatial.ParticleSets will fail, but everything else should be fine.
Traceback (most recent call last):
  File "/home/kaezhila/Programs/tmp_surface_morphometrics/segmentation_to_meshes.py", line 25, in <module>
    import ply2vtp
  File "/home/kaezhila/Programs/tmp_surface_morphometrics/ply2vtp.py", line 16, in <module>
    from pycurv import pycurv_io as io
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pycurv/__init__.py", line 9, in <module>
    from .graphs import SegmentationGraph
  File "/home/kaezhila/.local/lib/python3.9/site-packages/pycurv/graphs.py", line 5, in <module>
    from graph_tool import Graph
  File "/home/kaezhila/.conda/envs/morphometrics/lib/python3.9/site-packages/graph_tool/__init__.py", line 118, in <module>
    dl_import("from . import libgraph_tool_core as libcore")
  File "/home/kaezhila/.conda/envs/morphometrics/lib/python3.9/site-packages/graph_tool/dl_import.py", line 44, in dl_import
    exec(import_expr, local_dict, global_dict)
  File "<string>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_libgraph_tool_core)
bbarad commented 3 months ago

There are a few things happening here. Pyto seems to have updated its dependencies but not changed its requirements in the install file. I'll flip the installation media for surface morphometrics to use my own fork of pyto.

The Libstd C++ issue is one we've routinely seen with old versions of linux (https://github.com/GrotjahnLab/surface_morphometrics/issues/7). What linux version are you using? Surface Morphometrics is not currently compatible with any version of centos, for example. It also has some issues with the ARM CPUs on macs. These are unfortunately due to the limitations of some of the very useful libraries the software package supports.

bbarad commented 3 months ago

New version (https://github.com/GrotjahnLab/surface_morphometrics/releases/tag/1.1) has fixed the pyto dependencies issues (and also updated to support the new pymeshlab API). I think the other half of the problem is a linux version issue, but I will await further info.

Kathir-66 commented 3 months ago

I initially was working with Centos 7, It did not work as I raised the issue for container implementation last time. So I moved to Centos 8 and it worked there till April. When I tried use the program again this week.

I tried again with the new version, I ended up getting the same error (morphometrics) kaezhila@blue ~/software/surface_morphometrics-1.1 $ > python segmentation_to_meshes.py config.yml Info: Module sympy could not be loaded. However, this is not a problem for running Pyto, because sympy is currently used only for development. Warning: Pyseg could not be loaded. Therefore, calling from_pyseg() method of pyto.spatial.ParticleSets will fail, but everything else should be fine. Traceback (most recent call last): File "/home/kaezhila/software/surface_morphometrics-1.1/segmentation_to_meshes.py", line 25, in <module> import ply2vtp File "/home/kaezhila/software/surface_morphometrics-1.1/ply2vtp.py", line 16, in <module> from pycurv import pycurv_io as io File "/home/kaezhila/.local/lib/python3.9/site-packages/pycurv/__init__.py", line 9, in <module> from .graphs import SegmentationGraph File "/home/kaezhila/.local/lib/python3.9/site-packages/pycurv/graphs.py", line 5, in <module> from graph_tool import Graph File "/home/kaezhila/.conda/envs/morphometrics/lib/python3.9/site-packages/graph_tool/__init__.py", line 118, in <module> dl_import("from . import libgraph_tool_core as libcore") File "/home/kaezhila/.conda/envs/morphometrics/lib/python3.9/site-packages/graph_tool/dl_import.py", line 44, in dl_import exec(import_expr, local_dict, global_dict) File "<string>", line 1, in <module> ImportError: dynamic module does not define module export function (PyInit_libgraph_tool_core) Is it possible to get around this or get a container implementation any time soon?

bbarad commented 3 months ago

This seems to be a problem with graph-tool, so it might be worth looking at their issue tracker or mailing list to see if its a common issue. Given the impending EOL of centos (2 days away for centos 8) I am not going to prioritize getting this working specifically, but I will revisit container support.

Kathir-66 commented 3 months ago

Hi, I sorted the ImportError: dynamic module does not define module export function (PyInit_libgraph_tool_core) ... But, I ran into a new issue

(morphometrics_v2) kaezhila@kraken  ~/software/surface_morphometrics-1.1 $ > python segmentation_to_meshes.py config.yml 
Info: Module sympy could not be loaded. However, this is not a problem for running Pyto, because sympy is currently used only for development.
Warning: Pyseg could not be loaded. Therefore, calling from_pyseg() method of pyto.spatial.ParticleSets will fail, but everything else should be fine.
No input file specified - will run on all MRC files in the data directory
Pattern Matched: /home/kaezhila/software/surface_morphometrics-1.1/example_data/*.mrc
['TF1.mrc', 'TE1.mrc']
Configured segmentation labels:
{'OMM': 1, 'IMM': 2, 'ER': 3}
Processing segmentation TF1.mrc
Generating xyz file: /home/kaezhila/software/surface_morphometrics-1.1/morphometrics/TF1_OMM.xyz
1.3399999618530274 (0.0, 0.0, 0.0)
Generating a ply mesh with Screened Poisson: /home/kaezhila/software/surface_morphometrics-1.1/morphometrics/TF1_OMM.ply
Processing /home/kaezhila/software/surface_morphometrics-1.1/morphometrics/TF1_OMM.xyz into /home/kaezhila/software/surface_morphometrics-1.1/morphometrics/TF1_OMM.ply
Traceback (most recent call last):
  File "/home/kaezhila/software/surface_morphometrics-1.1/segmentation_to_meshes.py", line 80, in <module>
    ret_val = xyz2ply.xyz_to_ply(xyz_file, ply_file,
  File "/home/kaezhila/software/surface_morphometrics-1.1/xyz2ply.py", line 47, in xyz_to_ply
    ms.compute_scalar_by_distance_from_another_mesh_per_vertex(measuremesh = 1, refmesh=0 , maxdist=pm.PercentageValue(20), signeddist=False) # Delete points that are too far from the reference mesh
AttributeError: module 'pymeshlab' has no attribute 'PercentageValue'

This is my version of pymeshlab

(morphometrics_v2) kaezhila@kraken  ~/software/surface_morphometrics-1.1 $ > pip show pymeshlab
Name: pymeshlab
Version: 2022.2.post3
Summary: A Python interface to MeshLab
Home-page: https://github.com/cnr-isti-vclab/PyMeshLab
Author: Alessandro Muntoni, Paolo Cignoni
Author-email: alessandro.muntoni@isti.cnr.it
License: GPL3
Location: /home/kaezhila/.local/lib/python3.9/site-packages
Requires: numpy
Required-by: 

Since, it worked in Cento 08 earlier, I am hopeful this issue AttributeError: module 'pymeshlab' has no attribute 'PercentageValue' is solvable

bbarad commented 3 months ago

This is very strange - pymeshlab underwent a large change in API a year or so back so this may be related to that. They formerly used Percentage() instead of PercentageValue() - but I am not sure why the version you have is so old... https://pymeshlab.readthedocs.io/en/latest/classes/percentage_value.html

bbarad commented 3 months ago

Can you try running pip upgrade pymeshlab? On our ubuntu system that brough an old 2022.2post3 version up to 2023.12. I'll update the requirements accordingly if that works for you.

Kathir-66 commented 3 months ago

Sorry for the delay... We tried the commands you told and some more commands. We still get the same error!

(morphometrics) jucastil@sirocco  ~/test/surface_morphometrics-1.1 $ > pip upgrade pymeshlab
ERROR: unknown command "upgrade"
(morphometrics) jucastil@sirocco  ~/test/surface_morphometrics-1.1 $ > pip show pymeshlab
Name: pymeshlab
Version: 2022.2.post3
Summary: A Python interface to MeshLab
Home-page: https://github.com/cnr-isti-vclab/PyMeshLab
Author: Alessandro Muntoni, Paolo Cignoni
Author-email: [alessandro.muntoni@isti.cnr.it](mailto:alessandro.muntoni@isti.cnr.it)
License: GPL3
Location: /home/jucastil/.conda/envs/morphometrics/lib/python3.9/site-packages
Requires: numpy
Required-by:
(morphometrics) jucastil@sirocco  ~/test/surface_morphometrics-1.1 $ > pip update pymeshlab
ERROR: unknown command "update"
(morphometrics) jucastil@sirocco  ~/test/surface_morphometrics-1.1 $ > pip install --upgrade pymeshlab
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com/
Requirement already satisfied: pymeshlab in /home/jucastil/.conda/envs/morphometrics/lib/python3.9/site-packages (2022.2.post3)
Requirement already satisfied: numpy in /home/jucastil/.conda/envs/morphometrics/lib/python3.9/site-packages (from pymeshlab) (1.26.4)
bbarad commented 3 months ago

whoops thats what I get shooting from the hip. I believe the command should be pip install --upgrade pymeshlab

bbarad commented 3 months ago

Disregard that, I see you already checked that. I am not sure what is wrong, but I will prioritize getting a container built ahead of the 1.5 release in the next couple months.

Kathir-66 commented 3 months ago

Thank you very much! ... I will update you, if I make any progress or if I find any workaround !!

bbarad commented 2 months ago

Closing since the solution is instead to complete and close #10

m-albert commented 2 months ago

Hey, thanks for this great package which I'm happily starting to use :)

Just wanted to post here that this helped me with this issue reported by @Kathir-66.

Namely, adding this to xyz2ply.py helps making the code compatible with this older version of pymeshlab:

    import importlib.metadata
    PML_VER = importlib.metadata.version('pymeshlab')
    if PML_VER == '2022.2.post3':
        pm.PercentageValue = pm.Percentage
bbarad commented 2 months ago

This is very helpful, thank you! If you'd like to get credited I will happily merge a pull request - otherwise I'll add this to the next release (which should happen early next week, as I am doing a major overhaul of the pymeshlab routine to get smoother meshes).

m-albert commented 2 months ago

Cool, created a PR :)

Looking forward to the smoother meshes!