Skip to content

Commit

Permalink
change surface mesh decimation to vtk based algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
harmening committed Mar 20, 2024
1 parent 4d7f63e commit 50cb3e5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion environment_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ dependencies:
- setuptools-scm==7.1.0
- snirf==0.7.4
- pmcx
- open3d==0.16
12 changes: 6 additions & 6 deletions src/cedalion/dataclasses/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pint
import trimesh
import vtk
import mne
import xarray as xr
from scipy.spatial import KDTree
from vtk.util.numpy_support import vtk_to_numpy
Expand Down Expand Up @@ -129,12 +130,11 @@ def decimate(self, face_count: int) -> "TrimeshSurface":
The surface with a decimated mesh
"""

try:
decimated = self.mesh.simplify_quadric_decimation(face_count)
except:
# deprecated trimesh function, please update trimesh!
decimated = self.mesh.simplify_quadratic_decimation(face_count)

vertices, faces = mne.decimate_surface(self.mesh.vertices,
self.mesh.faces, face_count,
method="quadric")
decimated = trimesh.Trimesh(vertices, faces)

return TrimeshSurface(decimated, self.crs, self.units)

def smooth(self, lamb: float) -> "TrimeshSurface":
Expand Down
2 changes: 1 addition & 1 deletion src/cedalion/imagereco/forward_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TwoSurfaceHeadModel:
segmentation_masks: xr.DataArray
brain: cdc.Surface
scalp: cdc.Surface
landmarks: Optional[cdt.LabledPointCloud]
landmarks: Optional[cdt.LabeledPointCloud]
t_ijk2ras: cdt.AffineTransform
t_ras2ijk: cdt.AffineTransform
voxel_to_vertex_brain: scipy.sparse.spmatrix
Expand Down

0 comments on commit 50cb3e5

Please sign in to comment.