Learn R Programming

neuroim2 (version 0.8.5)

read_meta_info: Generic function to read image meta info given a file

Description

Reads meta information from image files based on their format (NIFTI or AFNI).

Usage

read_meta_info(x, file_name)

# S4 method for NIFTIFormat read_meta_info(x, file_name)

# S4 method for AFNIFormat read_meta_info(x, file_name)

Value

A list containing the meta information read from the file.

An object of class NIFTIMetaInfo or AFNIMetaInfo, depending on the input format

Arguments

x

A FileFormat object (either NIFTIFormat or AFNIFormat)

file_name

A character string specifying the file name to read meta information from

Details

These methods use format-specific functions to read the header information and create the appropriate meta information object. The `.read_meta_info` helper function is used internally to streamline the process for both formats.

Examples

Run this code
# Create a NIFTI format descriptor
fmt <- new("NIFTIFormat",
           file_format = "NIFTI",
           header_encoding = "raw",
           header_extension = "nii",
           data_encoding = "raw",
           data_extension = "nii")

# Read metadata from a NIFTI file
# \donttest{
fname <- system.file("extdata", "global_mask_v4.nii", package="neuroim2")
meta <- read_meta_info(fmt, fname)

# Access metadata properties
dim(meta)          # Image dimensions
trans(meta)        # Transformation matrix
# }

Run the code above in your browser using DataLab