neuroCleaner: Clean and Load Data from NIfTI Neuroimaging Files

View source: R/neuroCleaner.R

neuroCleanerR Documentation

Clean and Load Data from NIfTI Neuroimaging Files

Description

Loads a NIfTI-format neuroimaging file and transforms it into a structured data frame, organizing voxel-level information for downstream analysis. This function is the first step in the neuroimaging processing pipeline in neuroSCC, converting raw PET data into a format suitable for functional data analysis. SCCs are later computed using functions from the ImageSCC package, such as ImageSCC::scc.image().

Usage

neuroCleaner(name, demo = NULL, demoRow = 1)

Arguments

name

character. The full path to the NIfTI file to process.

demo

Optional data.frame containing demographic information. If provided, it should include columns (case-insensitive): PPT, Group, Sex, and Age. If automatic matching via the PPT column fails, the row specified by demoRow is used. Default is NULL.

demoRow

integer. Row to use from the demographic table if automatic matching fails. Default is 1.

Details

The function performs the following steps

  1. Loads the NIfTI file using oro.nifti::readNIfTI().

  2. Converts the 3D image into a tidy data frame.

  3. Adds z, x, and y voxel coordinates.

  4. If demographic data is provided, attempts to match based on PPT (case-insensitive). If no match is found, demoRow is used.

The resulting data frame serves as input for databaseCreator, matrixCreator, and other core functions in the neuroSCC pipeline.

Value

A data frame where each row represents a voxel (3D pixel).

  • If demographics are provided: the columns include PPT, Group, Sex, Age, z, x, y, and pet.

  • If demographics are not provided: the columns include z, x, y, and pet.

The pet column contains the PET intensity value at each voxel location.

See Also

databaseCreator for batch image processing.
readNIfTI for reading NIfTI-format files.

Examples

# Load a sample Control NIfTI file
niftiFile <- system.file("extdata", "syntheticControl1.nii.gz", package = "neuroSCC")

# Example Without demographic data
petData <- neuroCleaner(niftiFile)
petData[sample(nrow(petData), 10), ]  # Show 10 random voxels


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