neuroContour: Obtain and save neuroimaging contours from a NIFTI file

View source: R/neuroContour.R

neuroContourR Documentation

Obtain and save neuroimaging contours from a NIFTI file

Description

This function extracts contours from a neuroimaging NIFTI file where values change according to specified levels. It processes the NIFTI file with neuroCleaner to extract structured neuroimaging data, then extracts contours using contoureR::getContourLines. These contours serve as input for Triangulation::TriMesh, which is used in Simultaneous Confidence Corridors (SCCs) calculations.

While not mandatory, it is highly recommended that the input NIFTI file be pre-processed such that zero values represent the background and non-zero values represent regions of interest. The function's default behavior extracts contours at level 0, which is ideal for well-masked data.

Usage

neuroContour(niftiFile, paramZ = 35, levels = c(0), plotResult = FALSE)

Arguments

niftiFile

character, the path to the NIFTI file containing neuroimaging data. Ideally, the file should be masked so that zero values represent the background.

paramZ

integer, the specific z-slice to extract contours from. Default is 35.

levels

numeric, a vector of levels at which to draw the contours. Default is c(0).

plotResult

logical, if TRUE, plots the extracted contours. Default is FALSE.

Details

This function extracts contours from a NIFTI file, typically a masked image where background values are set to zero, and regions of interest contain non-zero values. While users can specify a different boundary level, the recommended approach is to use levels = 0 for masked data.

The extracted contours are typically used as input to Triangulation::TriMesh to create a triangular mesh of the region, which is then used for Simultaneous Confidence Corridors calculations.

Value

A list of data frames, where each data frame contains the x and y coordinates of a contour. The first element typically represents the external boundary, while subsequent elements (if present) represent internal contours or holes. Each data frame has two columns:

  • x – x-coordinates of the contour points.

  • y – y-coordinates of the contour points.

See Also

getContourLines for the underlying contour extraction.
Triangulation::TriMesh for the next step in the SCC calculation process.

Examples

# Get the file path for a sample NIfTI file
niftiFile <- system.file("extdata", "syntheticControl1.nii.gz", package = "neuroSCC")

# Extract contours at level 0
contours <- neuroContour(niftiFile, paramZ = 35, levels = 0, plotResult = TRUE)

# Display the first few points of the main contour
head(contours[[1]])


neuroSCC documentation built on April 4, 2025, 3:50 a.m.