Normalizes each row of a matrix by dividing its elements by the row mean, ignoring NA values.
This step is commonly used to adjust for global intensity differences across subjects before
applying statistical comparisons or functional data analysis.
Usage
meanNormalization(
matrixData,
handleInvalidRows = c("warn", "error", "omit"),
returnDetails = FALSE,
quiet = FALSE
)Arguments
- matrixData
A
matrixwhere each row represents one subject’s PET data, typically generated bymatrixCreator.- handleInvalidRows
character. Specifies how to handle rows with invalid means (either zero orNA). Options include"warn"(default),"error", or"omit".- returnDetails
logical. IfTRUE, returns a list with the normalized matrix and additional diagnostics. IfFALSE(default), returns only the normalized matrix.- quiet
logical. IfTRUE, suppresses console messages. Default isFALSE.
Value
A normalized matrix, or a list if returnDetails = TRUE.
normalizedMatrix– The normalized matrix.problemRows– Indices of rows that had zero orNAmeans.
Details
The function performs the following steps
Computes the row means of the input matrix, ignoring
NAs.Divides each row by its corresponding mean.
Replaces
NaNvalues (from division by 0) with0if applicable.Handles problematic rows according to the selected
handleInvalidRowsoption:"warn"(default) issues a warning,"error"stops execution, and"omit"removes the affected rows from the result.
This step is often used prior to applying SCC methods to ensure comparability across subjects.
See also
matrixCreator for building the matrix input to normalize.
Examples
# Generate a minimal database and create a matrix (1 control subject)
dataDir <- system.file("extdata", package = "neuroSCC")
controlPattern <- "^syntheticControl1\\.nii\\.gz$"
databaseControls <- databaseCreator(pattern = controlPattern,
control = TRUE,
quiet = TRUE)
matrixControls <- matrixCreator(databaseControls, paramZ = 35, quiet = TRUE)
# Normalize the matrix (with diagnostics)
normalizationResult <- meanNormalization(matrixControls,
returnDetails = TRUE,
quiet = FALSE)
#>
#> Mean before normalization: 4.349632
#>
#> Normalization completed.
