An open API service indexing awesome lists of open source software.

https://github.com/bbuchsbaum/neuroim2

R data structures and function for fMRI-focused neuroimaging analysis
https://github.com/bbuchsbaum/neuroim2

fmri neuroimaging r

Last synced: about 2 months ago
JSON representation

R data structures and function for fMRI-focused neuroimaging analysis

Awesome Lists containing this project

README

          

---
title: "neuroim2"
output:
md_document:
variant: markdown_github
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# neuroim2

[![CRAN status](https://www.r-pkg.org/badges/version/neuroim2)](https://cran.r-project.org/package=neuroim2)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/neuroim2)](https://cran.r-project.org/package=neuroim2)
[![R-CMD-check](https://github.com/bbuchsbaum/neuroim2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/bbuchsbaum/neuroim2/actions/workflows/R-CMD-check.yaml)
[![pkgdown](https://github.com/bbuchsbaum/neuroim2/actions/workflows/pkgdown.yaml/badge.svg)](https://bbuchsbaum.github.io/neuroim2/)
[![codecov](https://codecov.io/gh/bbuchsbaum/neuroim2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/bbuchsbaum/neuroim2)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.md)

Data structures and I/O for volumetric brain imaging with a focus on fMRI. This is the successor to [`neuroim`](https://github.com/bbuchsbaum/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
**Cheatsheet:** [neuroim2_cheatsheet.md](neuroim2_cheatsheet.md)

## Installation

### CRAN

```r
install.packages("neuroim2")
```

### R-universe (daily builds)

```r
install.packages("neuroim2",
repos = c("https://bbuchsbaum.r-universe.dev", "https://cloud.r-project.org"))
```

### Development version (GitHub)

```r
# install.packages("remotes")
remotes::install_github("bbuchsbaum/neuroim2")
```

## Usage

Read a NIFTI image and perform simple operations:

```{r}
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))
```

Create a 4D image from volumes:

```{r}
vec <- vec_from_vols(list(vol, vol, vol2))
series1 <- vec[1,1,1,]
length(series1)
```

## Vignettes

See examples of use of `neuroim2` in the [vignettes](https://bbuchsbaum.github.io/neuroim2/articles/index.html).

### Visualization

- Slice visualization vignette: https://bbuchsbaum.github.io/neuroim2/articles/slice-visualization.html

Quick montage example (robust scaling and shared colorbar):

```r
# Not run in README
# library(neuroim2)
# vol <- read_vol(system.file("extdata","global_mask_v4.nii", package="neuroim2"))
# z <- unique(round(seq(round(dim(vol)[3]*.25), round(dim(vol)[3]*.85), length.out = 12)))
# plot_montage(vol, zlevels = z, along = 3, cmap = "grays", range = "robust", ncol = 6)
```