CAVEconnectome / MeshParty

Apache License 2.0
34 stars 16 forks source link

swc export error #62

Open zhihaozheng opened 4 years ago

zhihaozheng commented 4 years ago
segid = 720575940621647595
mm = trimesh_io.MeshMeta()
mesh = mm.mesh(filename = "{}.obj".format(segid))
sk=skeletonize.skeletonize_mesh(mesh, invalidation_d=12000)
sk.export_to_swc("{}.swc".format(segid))

.obj file is here

In [16]: sk.export_to_swc("{}.swc".format(segid))                                                                               
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-16-94e86f139667> in <module>
----> 1 sk.export_to_swc("{}.swc".format(segid))

~/scripts/git_clones/MeshParty/meshparty/skeleton.py in export_to_swc(self, filename, node_labels, radius, header, xyz_scaling)
    535 
    536         skeleton_io.export_to_swc(self, filename, node_labels=node_labels,
--> 537                                   radius=radius, header=header, xyz_scaling=xyz_scaling)
    538 
    539 

~/scripts/git_clones/MeshParty/meshparty/skeleton_io.py in export_to_swc(skel, filename, node_labels, radius, header, xyz_scaling)
    199         node_labels = np.full(len(skel.vertices), 3)
    200 
--> 201     swc_dat = _build_swc_array(skel, node_labels, radius, xyz_scaling)
    202 
    203     with open(filename, 'w') as f:

~/scripts/git_clones/MeshParty/meshparty/skeleton_io.py in _build_swc_array(skel, node_labels, radius, xyz_scaling)
    224                          xyz / xyz_scaling,
    225                          radius[:, np.newaxis] / xyz_scaling,
--> 226                          par_ids[:, np.newaxis]))
    227     return swc_dat
    228 

<__array_function__ internals> in hstack(*args, **kwargs)

~/anaconda3/envs/meshparty/lib/python3.7/site-packages/numpy/core/shape_base.py in hstack(tup)
    343         return _nx.concatenate(arrs, 0)
    344     else:
--> 345         return _nx.concatenate(arrs, 1)
    346 
    347 

<__array_function__ internals> in concatenate(*args, **kwargs)

ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 4313 and the array at index 1 has size 1538
ceesem commented 4 years ago

I don't get this with the most recent release version (1.9.0) of MeshParty, and am currently preparing an update with some significant changes to the underlying functions. What version is this from, and does the error still happen when you set collapse_soma=False in the skeletonize_mesh parameters?

zhihaozheng commented 4 years ago

I got this error with 1.9.0 (actually 1.9.1.dev2+ga8ad053), and still has it with collapse_soma=False. Also got this runtime warning, not sure if it was related.

MeshParty/meshparty/skeletonize.py:383: RuntimeWarning: invalid value encountered in multiply
  target = np.nanargmax(root_ds*valid)
ceesem commented 4 years ago

What branch is that from? It's definitely not what you get from a pip install...

ceesem commented 4 years ago

Also, I doubt the runtime error matters, that should just result in an inf or a nan in an intermediate array during skeletonization.

zhihaozheng commented 4 years ago

I tried different versions and got it working with 1.8.0. I didn't have a clue what was going on though...