neurotransform is a lightweight R package for geometric transforms in neuroimaging.
It provides a small, consistent transform kernel for:
The package is designed around a single idea: spatial transforms should be first-class objects with clear composition, inversion, and Jacobian semantics.
neurotransform is under active development.
The current API already covers the main transform types and resampling paths, but the package should still be treated as early-stage software.
From GitHub:
install.packages("remotes")
# remotes::install_github("bbuchsbaum/neurotransform")
install.packages("neurotransform", repos = c('https://bbuchsbaum.r-universe.dev', 'https://cloud.r-project.org'))
Core dependencies are intentionally small.
Some file formats and workflows use suggested packages such as RNifti, hdf5r, Matrix, knitr, and rmarkdown.
IdentityMorphism, Affine3DMorphism, Warp3DMorphism, VolToSurfMorphism, and SurfToSurfMorphism
transform()
compose()
ResamplingPlanslibrary(neurotransform)
# An affine mapping from "native" to "template" space.
# With pullback semantics, it maps template coordinates back into native space.
mat <- diag(4)
mat[1:3, 4] <- c(10, 20, 30)
aff <- Affine3DMorphism(
source = "native",
target = "template",
matrix = mat
)
coords_template <- matrix(c(
0, 0, 0,
5, 5, 5
), ncol = 3, byrow = TRUE)
coords_native <- transform(aff, coords_template)
coords_native
You can compose transforms directly:
aff1 <- Affine3DMorphism("native", "intermediate", diag(4))
aff2 <- Affine3DMorphism("intermediate", "template", diag(4))
path <- compose(aff1, aff2)
transform(path, coords_template)
And resample a volume into a target grid:
vol <- array(runif(27), dim = c(3, 3, 3))
grid <- grid_spec(dims = c(3, 3, 3), affine = diag(4), domain = "template")
out <- resample_volume(
data = vol,
morphism = aff,
target = grid,
method = "linear"
)
The package uses pullback semantics throughout. A morphism from domain A to domain B answers the question:
“Given coordinates in B, where should I sample in A?”
That convention makes composition and resampling consistent, especially for image interpolation.
The package also includes helpers for the common convention mismatches across:
Most neuroimaging projects need correct coordinate transforms, but not an entire processing framework.
neurotransform aims to be the reusable geometry layer: small enough to embed, explicit enough to reason about, and tested closely enough to trust for affine/warp math and resampling.
MIT. See LICENSE.