meta_info: Lightweight metadata for neuroimaging files

meta_infoR Documentation

Lightweight metadata for neuroimaging files

Description

'meta_info()' provides a simple, CRAN-friendly way to retrieve essential image metadata without teaching S4 details up front. It accepts a file path or a 'FileMetaInfo' object and returns a normalized list containing common fields like dimensions, spacing, origin, and transform.

The function does not read image data; it only parses header information.

Usage

meta_info(x)

## S4 method for signature 'FileMetaInfo'
meta_info(x)

## S4 method for signature 'character'
meta_info(x)

Arguments

x

A character file path (e.g., '"image.nii.gz"') or an object of class FileMetaInfo.

Details

Summarize Image Metadata

Value

A named list with the following elements:

  • 'dim' Integer vector of image dimensions.

  • 'spacing' Numeric voxel spacing (mm).

  • 'origin' Numeric coordinate origin.

  • 'trans' 4x4 transformation matrix mapping grid to world (mm).

  • 'path' Data file path.

  • 'filename' Basename of 'path'.

  • 'format' File format label (e.g., "NIFTI", "AFNI").

  • 'dtype' Storage data type label.

  • 'bytes_per_element' Bytes per element.

  • 'nvox' Number of voxels in the spatial volume (prod of first 3 dims).

  • 'nvol' Number of volumes (4th dim if present, else 1).

  • 'size_bytes' Approximate uncompressed size in bytes ('nvox * nvol * bytes_per_element').

  • 'time_step' Time step (TR in seconds) if available for NIfTI, else 'NA_real_'.

See Also

read_header, trans, FileMetaInfo, NIFTIMetaInfo

Examples


f <- system.file("extdata", "global_mask_v4.nii", package = "neuroim2")
mi <- meta_info(f)
mi$dim
mi$spacing
mi$origin
mi$filename
# 4x4 transform
mi$trans



neuroim2 documentation built on April 16, 2026, 5:07 p.m.