Create smooth surface from volume mask or data
Usage
volume_to_surface(
volume,
lambda = 0.2,
degree = 2,
threshold_lb = 0.5,
threshold_ub = NA,
smooth_method = c("implicit", "explicit", "none"),
smooth_iterations = 10L,
max_vertices = 5e+05,
...
)Arguments
- volume
volume object or path to the NIfTI volume files, see
as_ieegio_volumefor details- lambda, degree
smooth parameters; see
vcg_smooth_implicitfor details. To disable smoothing, setlambdato negative orNA- threshold_lb, threshold_ub
threshold of volume, see
vcg_isosurface; default is any voxel value above 0.5. Voxels strictly between the two thresholds form the mask; voxels that areNA,NaN, or infinite are invalid and never part of it- smooth_method
"implicit"(default) smooths withvcg_smooth_implicitusinglambdaanddegree;"explicit"smooths withmris_smoothinstead, repeated neighbor averaging whose memory grows only linearly with the surface (with a ravetools version that does not havemris_smooth, the"laplace"type ofvcg_smooth_explicitis used);"none"returns the surface without smoothing- smooth_iterations
number of averaging rounds when
smooth_methodis"explicit"; default is10- max_vertices
used only when
smooth_methodis"implicit", whose memory grows quickly with the surface size: surfaces with more vertices than this are reduced to about this many withravetools::vcg_decimate()before smoothing, which removes vertices from flat regions first and keeps the shape; default is500000. Because the smoothing works in mesh steps, the samelambdaanddegreesmooth a reduced surface more; use a larger value orInfto smooth at full resolution. With a ravetools version that does not havevcg_decimate, surfaces with more than20000vertices are not smoothed, since the implicit smoothing of those versions can crash on large surfaces- ...
passed to
as_ieegio_volume
Value
A as_ieegio_surface object; the surface is
transformed into anatomical space defined by the volume. When no valid
voxel lies within the thresholds, the surface has a single vertex at the
origin and no face.
Examples
# toy example; in practice, use tha path to the volume
volume <- array(0, dim = rep(30, 3))
volume[11:20, 11:20, 3:28] <- 1
volume[3:28, 11:20, 11:20] <- 1
volume[11:20, 3:28, 11:20] <- 1
vox2ras <- diag(1, 4)
surf <- volume_to_surface(volume, vox2ras = vox2ras)
if(interactive()) {
plot(surf)
}