smooth-NeuroSurface-method: Smooth Data on a NeuroSurface Object

smooth,NeuroSurface-methodR Documentation

Smooth Data on a NeuroSurface Object

Description

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.

Usage

## S4 method for signature 'NeuroSurface'
smooth(x, sigma = 5, ...)

Arguments

x

A NeuroSurface object containing the brain surface and associated data to be smoothed.

sigma

A numeric value specifying the smoothing radius. This defines the neighborhood around each vertex used to compute the smoothed value. Default is 5.

...

Additional arguments passed to the smoothing function.

Details

The smoothing process involves averaging the data values within a geodesic neighbourhood of each vertex. For every vertex the function uses find_all_neighbors to locate all vertices within the radius specified by sigma. The smoothed value is the mean of the vertex's own value and those of its neighbours. Increasing sigma results in broader smoothing because more neighbours are included in the average.

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.

Value

A new NeuroSurface object with the smoothed data values. The geometry remains unchanged.

See Also

smooth,SurfaceGeometry-method for smoothing the geometry of a surface.

Examples

# Load a surface file from the extdata directory
surf_file <- system.file("extdata", "std.8_lh.inflated.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 with different radii
smoothed_small <- smooth(neuro_surf, sigma = 2)
smoothed_large <- smooth(neuro_surf, sigma = 6)

# 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_large))


bbuchsbaum/neurosurf documentation built on June 10, 2025, 8:22 p.m.