CAVEconnectome / MeshParty

Apache License 2.0
34 stars 16 forks source link

Resolution adjustment #57

Closed ceesem closed 4 years ago

ceesem commented 4 years ago

This branch adds a voxel_scaling parameter to meshes and skeletons that allows a dynamic and reversible rescaling of mesh vertex locations. This should only be used for analysis to avoid multiple sources of truth for the same data. This initial version only handles multiplicative scaling, although the framework should permit other types of transformations without much trouble.

Basic use:

1) From a MeshMeta with a default voxel scaling to apply to all meshes it loads:


mm = trimesh_io.MeshMeta( ... , voxel_scaling=[0.895, 0.895, 1])
mesh = mm.mesh(seg_id=seg_id)
# This mesh comes in with a voxel scaling as given to the MeshMeta

2) From an existing mesh:

new_voxel_scaling = [0.5, 0.5, 1]
mesh.voxel_scaling = new_voxel_scaling

3) To reset to the original dimensions:

mesh.voxel_scaling = None

4) For skeletons:

new_voxel_scaling = [0.5, 0.5, 1]
sk.voxel_scaling = new_voxel_scaling

Note that for some actions, one does not want scaled vertex values. These include saving the mesh to disk and adding link edges. There are internal controls that handle this, but they are only invoked if the action is called from the mesh itself. Thus:

This approach does NOT know to rescale vertices:

trimesh_repair.get_link_edges(mesh, ... )


* For saving:
```python
# This approach handles rescaled vertices:
mesh.write_to_file( ... )

# This approach does NOT know to rescale vertices:
trimesh_io.write_mesh_h5(mesh.vertices, mesh.faces, ... )
codecov-io commented 4 years ago

Codecov Report

Merging #57 into master will decrease coverage by 0.11%. The diff coverage is 73.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #57      +/-   ##
==========================================
- Coverage   76.35%   76.24%   -0.12%     
==========================================
  Files          12       12              
  Lines        1844     1928      +84     
==========================================
+ Hits         1408     1470      +62     
- Misses        436      458      +22
Impacted Files Coverage Δ
meshparty/trimesh_repair.py 83.84% <0%> (ø) :arrow_up:
meshparty/trimesh_io.py 71.81% <74.24%> (+0.13%) :arrow_up:
meshparty/skeleton.py 92.43% <76%> (-1.93%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 99af30b...0064537. Read the comment docs.