data_file-methods: Generic function to get the name of the data file, given a...

data_fileR Documentation

Generic function to get the name of the data file, given a file name and a FileFormat instance.

Description

Derives the data file name from a given file name based on the FileFormat specifications.

Usage

data_file(x, file_name)

## S4 method for signature 'FileFormat,character'
data_file(x, file_name)

Arguments

x

A FileFormat object specifying the format requirements

file_name

A character string specifying the file name to derive the data file name from

Details

The function performs the following steps:

  1. If the input file_name already matches the data file format, it returns the file_name as is.

  2. If the file_name matches the header file format, it constructs and returns the corresponding data file name.

  3. If the file_name doesn't match either format, it throws an error.

Value

the correct header name

A character string representing the data file name

See Also

header_file, strip_extension for related file name manipulation

Examples

## Not run: 
fmt <- new("FileFormat", header_extension = "hdr", data_extension = "img")
data_file(fmt, "brain_scan.img")  # Returns "brain_scan.img"
data_file(fmt, "brain_scan.hdr")  # Returns "brain_scan.img"

## End(Not run)


bbuchsbaum/neuroim2 documentation built on Jan. 2, 2025, 3:38 p.m.