minmax_img-methods: Normalize Image using Range

Description Usage Arguments Value Examples

Description

Calculates the range of values in an image, then scales the image minimum to 0 and maximum to 1

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
minmax_img(img)

## S4 method for signature 'nifti'
minmax_img(img)

## S4 method for signature 'array'
minmax_img(img)

## S4 method for signature 'ANY'
minmax_img(img)

## S4 method for signature 'character'
minmax_img(img)

## S4 method for signature 'factor'
minmax_img(img)

## S4 method for signature 'list'
minmax_img(img)

Arguments

img

character path of image or an object of class nifti, or list of images

Value

A nifti object (or list of them) or class of object passed in if not specified

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
set.seed(5)
dims = rep(10, 4)
arr = array(rpois(prod(dims), lambda = 2), dim = dims)
nim = oro.nifti::nifti(arr)
mimg = minmax_img(nim)
marr = minmax_img(arr)
testthat::expect_equal(array(mimg, dim = dim(mimg)), marr)

set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
arr[,,10] = 0
nim = oro.nifti::nifti(arr)
rnifti = RNifti::asNifti(nim)
timg = tempimg(nim)
limg = list(factor(timg), factor(timg))
func = minmax_img
func(arr)
func(nim)
func(rnifti)
func(timg)
func(limg)

neuroconductor-devel/neurobase documentation built on May 6, 2021, 1:48 p.m.