Skip to content

Problem: Error in the tutorial of "3D reconstruction of mesh model" using matching cube #339

@swjn2017USTC

Description

@swjn2017USTC

Hello, Thank you so much for developing such a useful tool. I have a question. I try to run your "3D Reconstruction" tutorial link using the Drosophila Embryo data ("E7-9h_cellbin_tdr_v2.h5ad"). It raises no errors until I try to make a 3D reconstruction of mesh model using the code below:
embryo_mesh, _, _ = st.tdr.construct_surface(pc=embryo_pc, key_added="tissue", alpha=0.6, cs_method="marching_cube")
Here is the error log:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[10], line 1
----> 1 embryo_mesh, _, _ = st.tdr.construct_surface(pc=embryo_pc, key_added="tissue", alpha=0.6, cs_method="marching_cube")
      2 # st.pl.three_d_plot(model=st.tdr.collect_models([embryo_mesh, embryo_pc]), key="tissue", model_style=["surface", "points"], jupyter="static", cpo=cpo)
      3 # st.tdr.save_model(model=embryo_mesh, filename="embryo_mesh_model.vtk")

File ~/anaconda3/envs/Spateo/lib/python3.9/site-packages/spateo/tdr/models/models_individual/mesh.py:235, in construct_surface(pc, key_added, label, color, alpha, uniform_pc, uniform_pc_alpha, cs_method, cs_args, nsub, nclus, smooth, scale_distance, scale_factor)
    232 uniform_surfs = []
    233 for sub_surf in csurf.split_bodies():
    234     # Repair the surface mesh where it was extracted and subtle holes along complex parts of the mesh
--> 235     sub_fix_surf = fix_mesh(mesh=sub_surf.extract_surface())
    237     # Get a uniformly meshed surface using voronoi clustering.
    238     sub_uniform_surf = uniform_mesh(mesh=sub_fix_surf, nsub=nsub, nclus=nclus)

File ~/anaconda3/envs/Spateo/lib/python3.9/site-packages/spateo/tdr/models/models_individual/mesh_utils.py:137, in fix_mesh(mesh)
    132 except ImportError:
    133     raise ImportError(
    134         "You need to install the package `pymeshfix`. \nInstall pymeshfix via `pip install pymeshfix`"
    135     )
--> 137 meshfix = mf.MeshFix(mesh)
    138 meshfix.repair(verbose=False)
    139 fixed_mesh = meshfix.mesh.triangulate().clean()

File ~/anaconda3/envs/Spateo/lib/python3.9/site-packages/pymeshfix/meshfix.py:81, in MeshFix.__init__(self, *args)
     78             tri_mesh = mesh.triangulate()
     79             faces = tri_mesh.faces
---> 81         self.f = np.ascontiguousarray(faces.reshape(-1, 4)[:, 1:])
     83 else:
     84     raise TypeError("Invalid input. Please load a surface mesh or face and vertex arrays")

ValueError: cannot reshape array of size 15942 into shape (4)

Thank you!
Best,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions