smooth | R Documentation |
The smooth
function is a generic function designed to apply smoothing operations to various surface objects. The specific behavior of the function depends on the class of the object passed as the x
argument. It can be used to smooth the geometry of a surface, the data associated with a surface, or other related operations depending on the method implemented for the object's class.
This method applies smoothing to a brain surface geometry object of class SurfaceGeometry
using various algorithms. Smoothing is useful for removing noise and creating a more continuous surface.
This method applies smoothing to the data values associated with a NeuroSurface
object. Unlike the geometric smoothing applied to SurfaceGeometry
, this function smooths the scalar values (e.g., intensity or activation) associated with each vertex on the surface.
smooth(x, ...)
## S4 method for signature 'SurfaceGeometry'
smooth(
x,
type = c("taubin", "laplace", "HClaplace", "fujiLaplace", "angWeight",
"surfPreserveLaplace"),
lambda = 0.7,
mu = -0.53,
delta = 0.1,
iteration = 5
)
## S4 method for signature 'NeuroSurface'
smooth(x, sigma = 5, ...)
x |
A |
... |
Additional arguments passed to the smoothing function. |
type |
A character string specifying the smoothing algorithm to use. Available options are:
|
lambda |
A numeric value that controls the amount of smoothing. Higher values lead to more aggressive smoothing. This parameter is particularly relevant for Taubin and Laplacian smoothing methods. |
mu |
A numeric value used in Taubin smoothing to control shrinkage. A value close to zero reduces shrinkage, while a negative value can help in shape preservation. |
delta |
A numeric value used in certain smoothing algorithms to adjust the influence of smoothing (e.g., in surface-preserving methods). |
iteration |
An integer specifying the number of smoothing iterations to apply. More iterations result in a smoother surface but can also lead to excessive flattening. |
sigma |
A numeric value specifying the smoothing radius. This defines the neighborhood around each vertex used to compute the smoothed value. Default is 5. |
The smooth
function provides a common interface for smoothing operations on different types of surface objects. The actual smoothing process varies based on the class of the object provided:
For SurfaceGeometry
objects, the function smooths the surface geometry, modifying the shape of the mesh to reduce noise.
For NeuroSurface
objects, the function smooths the data values associated with each vertex, preserving the surface geometry but producing a smoother dataset.
Users should refer to the specific method documentation for the class of object they are working with to understand the exact behavior and parameters.
The smoothing process involves averaging the data values within the neighborhood of each vertex. For each vertex on the surface, the function calculates the mean of its own value and the values of its adjacent vertices within the graph structure of the surface. The result is a smoother representation of the data, which can be useful for reducing noise or visualizing broader trends on the surface.
The smoothing is particularly useful when working with noisy data or when a smoother representation of the underlying signal is desired. It is commonly applied in neuroimaging to enhance visualization or prepare data for further analysis.
The function returns the smoothed SurfaceGeometry
object with the updated mesh.
A new NeuroSurface
object with the smoothed data values. The geometry remains unchanged.
smooth,SurfaceGeometry-method
, smooth,NeuroSurface-method
vcgSmooth
for more details on the underlying smoothing algorithms.
smooth,SurfaceGeometry-method
for smoothing the geometry of a surface.
## Not run:
# Smooth a SurfaceGeometry object
smoothed_geom <- smooth(surface_geom_obj, type="taubin", lambda=0.7, iteration=10)
# Smooth a NeuroSurface object's data
smoothed_data_surface <- smooth(neuro_surf_obj, sigma=5)
## End(Not run)
# Load a surface file from the extdata directory
surf_file <- system.file("extdata", "sample_surface.asc", package = "neurosurf")
surface <- readAsc(surf_file)
# Apply Taubin smoothing to the brain surface
smoothed_surface1 <- smooth(surface, type = "taubin", lambda = 0.5, mu = -0.5, iteration = 10)
# Apply surface-preserving Laplacian smoothing
smoothed_surface2 <- smooth(surface, type = "surfPreserveLaplace", iteration = 5)
# Load a surface file from the extdata directory
surf_file <- system.file("extdata", "sample_surface.asc", package = "neurosurf")
surface <- readAsc(surf_file)
# Create some random data for the surface vertices
n_vertices <- nrow(coords(surface))
random_data <- rnorm(n_vertices)
# Create a NeuroSurface object with the surface and data
neuro_surf <- NeuroSurface(geometry = surface,
indices = 1:n_vertices,
data = random_data)
# Apply smoothing to the data
smoothed_data_surface <- smooth(neuro_surf, sigma = 3)
# The original geometry is preserved, but the data is smoothed
# Compare a small section of data before and after smoothing
head(random_data)
head(series(smoothed_data_surface))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.