navis-org/skeletor

module 'skeletor' has no attribute 'contract'

piango opened this issue · 11 comments

Hi

I am just getting into segmentation and mesh analysis.

I found your work really cool. And exactly what I need.

however, after I installed and tried to you run the examples posted I ran into:
module 'skeletor' has no attribute 'contract'

I am using spyder. and I followed the installation instructions that is recommended.

I am sorry for such a basic issue here. it is simple problem I believe.
This is the version installed when i check conda list
skeletor 0.2.11 pypi_0 pypi

Thank you

Hi. Could you please post a minimal reproducible example + the full traceback.

Hi

Thanks for your very quick reply.
When you say "Hi. Could you please post a minimal reproducible example + the full traceback."
Do you mean something like below (below the dashed line)?

I literally copy pasted one of the examples that I found in the discussion(issue) forum.


import open3d as o3d
import matplotlib.pyplot as plt
import numpy as np
import skeletor as sk
import trimesh
import os
import glob

objects = sorted(glob.glob('connectednetwork.stl*'))
obj = objects[:]
wdir = os.getcwd()
for obj in objects:
base = os.path.splitext(obj)[0]

mesh = trimesh.load(obj)
mesh_o3d = o3d.io.read_triangle_mesh(obj)

# Contract the mesh
cont = sk.contract(mesh, iter_lim=15)
# Extract the skeleton from the contracted mesh
swc = sk.skeletonize(cont, method='vertex_clusters', sampling_dist=1, output='swc')
# swc = sk.skeletonize(cont, method='edge_collapse', output='swc')
# Clean up the skeleton
swc = sk.clean(swc, mesh)
# Add/update radii
swc['radius'] = sk.radii(swc, mesh, method='knn', n=5, aggregate='mean')
swc.head()

# visualizing scattered points
max_val = max(max(swc.x), max(swc.y), max(swc.z))
fig = plt.figure()
ax = fig.gca(projection='3d')
plt.axis('off')
plt.xlim([-max_val, max_val])
plt.ylim([-max_val, max_val])
ax.set_zlim(-max_val, max_val)
ax.scatter(swc.x, swc.y, swc.z, s=10)
plt.show()

# visualizing using open3d
xyz = np.zeros((swc.x.size, 3))
xyz[:, 0] = swc.x
xyz[:, 1] = swc.y
xyz[:, 2] = swc.z
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(xyz)
mesh_o3d.compute_vertex_normals()
o3d.visualization.draw_geometries([mesh_o3d, pcd])
o3d.visualization.draw_geometries([pcd])

# exporting csv file
export_file_path = mesh_name[:-4] + '.csv'
swc.to_csv(export_file_path, index=False, header=True)

Yes and no. I meant both the code you are trying to execute but also the error message (i.e. the "traceback")

Ah I see
sorry... I still consider myself as a beginner.

Thanks

Traceback (most recent call last):

File "C:\Users\blee\OneDrive\Postdoc\GB_Lab\Analysis\develoopment\orgseg\skeletor.py", line 12, in
import skeletor as sk

File "C:\Users\blee\OneDrive\Postdoc\GB_Lab\Analysis\develoopment\orgseg\skeletor.py", line 30, in
cont = sk.contract(mesh, iter_lim=15)

AttributeError: module 'skeletor' has no attribute 'contract'

Hmm is that the full error message? If so, could you please post the result of this:

import skeletor as sk
print(dir(sk))
print(sk.__version__)

hi here is what I get

import skeletor as sk
print(dir(sk))
['builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec', 'version', 'version_vector', 'clean', 'contract', 'meshcontraction', 'postprocessing', 'preprocessing', 'radii', 'radiusextraction', 'remesh', 'simplify', 'skeletonize', 'skeletonizers', 'utilities']
print(sk.version)
0.2.11

That's rather strange: as you can see there is a contract there.

Your minimal example is still a bit confusing to me. Is this what you are running up to the point where it throws an error?

import open3d as o3d
import matplotlib.pyplot as plt
import numpy as np
import skeletor as sk
import trimesh
import os
import glob

objects = sorted(glob.glob('connectednetwork.stl*'))
obj = objects[:]
wdir = os.getcwd()
for obj in objects:
   base = os.path.splitext(obj)[0]

   mesh = trimesh.load(obj)
   mesh_o3d = o3d.io.read_triangle_mesh(obj)

   # THIS LINE THROWS THE ERROR?
   cont = sk.contract(mesh, iter_lim=15)

Yes

That is where the error comes up.

Probably there is some sort of conflict with the conda environment that I have installed it in.
I will try several things.

Probably it is more of my problem that the skeletor

And I will keep this forum updated.

Thank you for your efforts.

After a while, I had issues with my conda environment. Installed conda and skeletor. Now it works.

Thanks and sorry for taking so long

Hi. Did you re-open this issue on purpose?

Ah sorry it was not on purpose. I will close it...

Thank you