CAVEconnectome / MeshParty

Apache License 2.0
35 stars 16 forks source link

mask csgraph bug #26

Closed fcollman closed 5 years ago

fcollman commented 5 years ago

I think i found a bug in 1.3 masked mesh implementation... i got this when trying to find the csgraph of a masked mesh..

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-19-5f19b02f5fbd> in <module>
----> 1 le = trimesh_repair.get_link_edges(mesh, seg_id, 'pinky100', verbose=True)

~/anaconda3/envs/celltypes/lib/python3.7/site-packages/meshparty/trimesh_repair.py in get_link_edges(mesh, seg_id, dataset_name, close_map_distance, server_address, verbose)
    242 
    243     for merge_ind in merge_edge_inds:
--> 244         link_edges = find_edges_to_link(mesh, merge_ind[0], merge_ind[1])
    245         total_link_edges.append(link_edges)
    246 

~/anaconda3/envs/celltypes/lib/python3.7/site-packages/meshparty/trimesh_repair.py in find_edges_to_link(mesh, vert_ind_a, vert_ind_b, distance_upper_bound, verbose)
     66     timings['apply_mask']=time.time()-start_time
     67     start_time = time.time()
---> 68     ccs, labels = sparse.csgraph.connected_components(mask_mesh.csgraph, return_labels=True)
     69 
     70     # map the original indices into this masked space

~/anaconda3/envs/celltypes/lib/python3.7/site-packages/trimesh/caching.py in get_cached(*args, **kwargs)
     97         tic = time.time()
     98         # value not in cache so execute the function
---> 99         value = function(*args, **kwargs)
    100         # store the value
    101         self._cache.cache[name] = value

~/anaconda3/envs/celltypes/lib/python3.7/site-packages/meshparty/trimesh_io.py in csgraph(self)
    414     @caching.cache_decorator
    415     def csgraph(self):
--> 416         return self._create_csgraph()
    417 
    418     @caching.cache_decorator

~/anaconda3/envs/celltypes/lib/python3.7/site-packages/meshparty/trimesh_io.py in _create_csgraph(self)
    782         """ Computes csgraph """
    783         return utils.create_csgraph(self.vertices, self.graph_edges, euclidean_weight=True,
--> 784                                     directed=False)
    785     @property
    786     def node_mask(self):

~/anaconda3/envs/celltypes/lib/python3.7/site-packages/meshparty/utils.py in create_csgraph(vertices, edges, euclidean_weight, directed)
    149     '''
    150     if euclidean_weight:
--> 151         xs = vertices[edges[:,0]]
    152         ys = vertices[edges[:,1]]
    153         weights = np.linalg.norm(xs-ys, axis=1)

IndexError: index 80116 is out of bounds for axis 0 with size 4883
fcollman commented 5 years ago

@ceesem I think this is related to versioning of trimesh... upgrading trimesh fixed this for me... added a reqs bump in my latest PR #25