Skip to contents

Convenience helper to discover NIfTI map files on disk using a flexible regular-expression pattern. This is intended for quick "scooping up" of first-level maps spread across a directory tree (e.g. .*/maps/AUC.nii).

Usage

find_maps(
  root,
  pattern = "\\.nii(\\.gz)?$",
  recursive = TRUE,
  subject_fun = NULL,
  contrast_fun = NULL
)

Arguments

root

Root directory to search.

pattern

Regular expression passed to base::list.files() to match candidate NIfTI files (e.g. "AUC\\\\.nii(\\\\.gz)?$").

recursive

Logical; whether to search subdirectories (default TRUE).

subject_fun

Optional function applied to the character vector of file paths, expected to return a character vector of subject identifiers.

contrast_fun

Optional function applied to the character vector of file paths, expected to return a character vector of contrast labels.

Value

A data.frame with columns file, subject, and contrast.

Details

The function does not impose any file naming convention. Instead, callers can provide optional subject_fun and contrast_fun hooks to derive subject and contrast labels from file paths.