Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

datatype

Change Data type for img


Description

Tries to figure out the correct datatype for image. Useful for image masks - makes them binary if

Usage

datatyper(
  img,
  type_string = NULL,
  datatype = NULL,
  bitpix = NULL,
  trybyte = TRUE,
  warn = TRUE
)

Arguments

img

nifti object (or character of filename)

type_string

(NULL) character of datatype and bitpix. Supercedes both datatype and bitpix. If specified convert.datatype[[type_string]] and convert.bitpix[[type_string]] will be used.

datatype

(NULL) character of datatype see convert.datatype

bitpix

(NULL) character of bitpix see convert.bitpix

trybyte

(logical) Should you try to make a byte (UINT8) if image in c(0, 1)?

warn

Should a warning be issued if defaulting to FLOAT32?

Value

object of type nifti

Examples

img = nifti(array(rnorm(10^3, sd = 1000), dim = rep(10, 3)))
rimg = round(img)
newnii(datatyper(rimg))
rimg = datatyper(rimg, type_string= "FLOAT32")

neurobase

'Neuroconductor' Base Package with Helper Functions for 'nifti' Objects

v1.32.1
GPL-2
Authors
John Muschelli [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.