extract_mesh_from_mask#
- brainglobe_atlasapi.atlas_generation.mesh_utils.extract_mesh_from_mask(volume, obj_filepath=None, threshold=0.5, smooth: bool = False, mcubes_smooth=False, closing_n_iters=8, decimate_fraction: float = 0.6, use_marching_cubes=False, extract_largest=False)[source]#
Return a vedo mesh actor with just the outer surface of a binary mask volume. It’s faster though less accurate than extract_mesh_from_mask.
- Parameters:
obj_filepath (str or Path object) – path to where the .obj mesh file will be saved
volume (3d np.ndarray)
threshold (float) – min value to threshold the volume for isosurface extraction
smooth (bool) – if True the surface mesh is smoothed
use_marching_cubes (bool:) – if true PyMCubes is used to extract the volume’s surface it’s slower and less accurate than vedo though.
mcubes_smooth (bool,) – if True mcubes.smooth is used before applying marching cubes
closing_n_iters (int) – number of iterations of closing morphological operation. set to None to avoid applying morphological operations
decimate_fraction (float in range [0, 1].) – What fraction of the original number of vertices is to be kept. EG .5 means that 50% of the vertices are kept, the others are removed.
tol (float) – parameter for decimation, with larger values corresponding to more aggressive decimation. EG 0.02 -> points that are closer than 2% of the size of the mesh’s bounding box are identified and removed (only one is kept).
extract_largest (bool) – If True only the largest region are extracted. It can cause issues for bilateral regions as only one will remain