strip_extension {neuroim2} | R Documentation |
Generic function to strip extension from file name, given a FileFormat
instance.
Description
Removes the file extension from a given file name based on the FileFormat specifications.
Usage
strip_extension(x, file_name)
## S4 method for signature 'FileFormat,character'
strip_extension(x, file_name)
Arguments
x |
A FileFormat object specifying the format requirements |
file_name |
A character string specifying the file name to strip the extension from |
Details
The function performs the following steps:
If the file_name matches the header file format, it removes the header extension.
If the file_name matches the data file format, it removes the data extension.
If the file_name doesn't match either format, it throws an error.
Value
A character
string file_name
without its extension.
A character string representing the file name without the extension
See Also
header_file
, data_file
for related file name
manipulation
Examples
# Create a FileFormat for NIFTI files
fmt <- new("FileFormat",
header_extension = "nii",
data_extension = "nii")
# Strip extension from a NIFTI file
strip_extension(fmt, "brain_scan.nii") # Returns "brain_scan"
[Package neuroim2 version 0.8.1 Index]