Data structures and I/O for volumetric brain imaging with a focus on
fMRI. This is the successor to
neuroim with improved S4
classes, sparse/dense 3D–4D representations, and fast
resampling/filtering.
Website: https://bbuchsbaum.github.io/neuroim2/ CRAN: https://cran.r-project.org/package=neuroim2
- NIfTI / AFNI support — read and write
.nii,.nii.gz, and AFNI.BRIK/.HEADfiles - S4 class hierarchy —
NeuroVol(3D volumes) andNeuroVec(4D time-series) with dense, sparse, memory-mapped, and clustered variants - Coordinate systems — full affine-aware transforms between voxel, grid, and world coordinates
- Searchlights & ROIs — spherical, cuboid, and random searchlight iterators plus flexible ROI construction
- Spatial filtering — Gaussian blur, guided filter, bilateral filter, and connected-component labelling
- Resampling — volume-to-volume resampling with configurable interpolation
- Visualization — slice montages, orthographic views, and overlay plotting via ggplot2
install.packages("neuroim2")install.packages("neuroim2",
repos = c("https://bbuchsbaum.r-universe.dev", "https://cloud.r-project.org"))# install.packages("remotes")
remotes::install_github("bbuchsbaum/neuroim2")Read a NIFTI image and perform simple operations:
library(neuroim2)
fname <- system.file("extdata", "global_mask_v4.nii", package="neuroim2")
vol <- read_vol(fname)
v1 <- vol[1,1,1]
vol2 <- vol + vol
all(vol == (vol2 - vol))## [1] TRUE
Create a 4D image from volumes:
vec <- vec_from_vols(list(vol, vol, vol2))
series1 <- vec[1,1,1,]
length(series1)## [1] 3
Browse the full set of articles on the pkgdown site:
| Getting Started | Analysis Workflows | Advanced |
|---|---|---|
| Overview | Analysis Workflows | Image Volumes |
| Choosing Backends | Slice Visualization | NeuroVector |
| Coordinate Systems | Cookbook | Regions of Interest |
| Volumes & Vectors | Smoothing | Clustered NeuroVec |
| Resampling | Pipelines |
This package uses the albersdown theme. Existing vignette theme hooks are replaced so albers.css and local albers.js render consistently on CRAN and GitHub Pages. The defaults are configured via params$family and params$preset (family = 'red', preset = 'homage'). The pkgdown site uses template: { package: albersdown }.