projectCoordinates | R Documentation |
This function projects a set of 3D coordinates onto a given surface and creates a NeuroSurface
object with the smoothed values.
The projection is performed by finding the closest points on the surface, and then a kernel density smoother is applied locally to produce the final values.
projectCoordinates(surfgeom, points, sigma = 5, ...)
surfgeom |
A |
points |
A numeric matrix with three columns (x, y, z) representing the 3D coordinates to be projected onto the surface. |
sigma |
A numeric value specifying the smoothing radius for the kernel density smoother. Default is 5. |
... |
Additional arguments passed to the smoothing function. |
The function first projects each 3D coordinate onto the closest point on the surface defined by surfgeom
.
The values at these projected points are then smoothed using a kernel density smoother, where the sigma
parameter controls the extent of the smoothing.
The result is a NeuroSurface
object containing the smoothed values, suitable for further analysis or visualization.
A NeuroSurface
object with the smoothed values mapped onto the surface.
# Load a sample surface from the package
surf_file <- system.file("extdata", "std.8.lh.inflated.asc", package = "neurosurf")
surfgeom <- readAsc(surf_file)
# Get the surface coordinates
surf_coords <- coords(surfgeom)
# Create some sample 3D coordinates to project
# We'll use a subset of the surface vertices with small random offsets
set.seed(123)
sample_indices <- sample(1:nrow(surf_coords), 50)
sample_coords <- surf_coords[sample_indices, ] + matrix(rnorm(150, 0, 0.5), ncol = 3)
# Project these coordinates onto the surface
projected_surface <- projectCoordinates(surfgeom, sample_coords, sigma = 3)
# Check the result
max(series(projected_surface)) # Maximum density value
sum(series(projected_surface) > 0) # Number of vertices with non-zero values
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.