Postprocess a single fMRI BOLD image using a configured pipeline
Source:R/postprocess_subject.R
postprocess_subject.RdApplies a sequence of postprocessing operations to a single subject-level BOLD NIfTI file, as specified by the user-defined configuration object. Operations may include brain masking, spatial smoothing, ICA-AROMA denoising, temporal filtering, confound regression, and intensity normalization. The function also optionally computes and saves a filtered confounds file for downstream analyses.
Arguments
- in_file
Path to a subject-level BOLD NIfTI file output by fMRIPrep.
- cfg
A list containing configuration options, including TR (
cfg$tr), enabled processing steps (cfg$<step>$enable), logging (cfg$log_file), and paths to resources such as singularity images (cfg$fsl_img). A whole-brain mask is automatically generated usingautomask()and used for relevant processing steps.
Value
The path to the final postprocessed BOLD NIfTI file. Side effects include writing a confounds TSV file (if enabled), and logging to a subject-level log file.
Details
The processing sequence can be enforced by the user (force_processing_order = TRUE) or determined dynamically based
on the enable flags in the configuration. Intermediate NIfTI and confound files are staged inside a scratch workspace
(located under cfg$scratch_directory) and final outputs are written or moved into the postprocessing output directory.
Logging is handled via the lgr package and is directed to subject-specific log files inferred from BIDS metadata.
Required cfg entries:
tr: Repetition time in seconds.bids_desc: A BIDS-compliantdesclabel for the output filename.processing_steps: Optional character vector specifying processing order (ifforce_processing_order = TRUE).scratch_directory: Optional directory for staging intermediate files (defaults totempdir()if unset).project_name: Optional project label used to organize scratch workspaces.
Optional steps controlled by cfg$<step>$enable:
apply_maskspatial_smoothapply_aromatemporal_filterconfound_regressionintensity_normalize