Construct BIDS-Compatible Filenames from Extracted Entity Data
Source:R/bids_functions.R
construct_bids_filename.Rd
Given a data frame of BIDS entities (as returned by extract_bids_info()
),
this function reconstructs filenames following the BIDS specification.
It supports standard BIDS entities including subject, session, task, run,
acquisition, space, resolution, and description, along with the suffix and file extension.
Arguments
- bids_df
A
data.frame
containing one or more rows of BIDS entities. Must include at least the columnssuffix
andext
, and optionally:subject
,session
,task
,acquisition
,run
,modality
,echo
,direction
,reconstruction
,hemisphere
,space
,resolution
,description
, andfieldmap
.- full.names
If TRUE, return the full path to the file using the
$directory
field ofbids_df
.
Details
Column names in bids_df
may be provided either as full
BIDS entity names (e.g., reconstruction
, description
) or using
their abbreviated forms (rec
, desc
, etc.); abbreviated names are
normalized internally.
See also
extract_bids_info()
for extracting BIDS fields from filenames.
Examples
df <- data.frame(
subject = "01", task = "rest", space = "MNI152NLin6Asym",
resolution = "2", description = "preproc", suffix = "bold", ext = ".nii.gz",
stringsAsFactors = FALSE
)
construct_bids_filename(df)
#> [1] "sub-01_task-rest_space-MNI152NLin6Asym_res-2_desc-preproc_bold.nii.gz"
# Returns: "sub-01_task-rest_space-MNI152NLin6Asym_res-2_desc-preproc_bold.nii.gz"