rescale_img: Image Rescaler

Description Usage Arguments Value Examples

View source: R/rescale_img.R

Description

Rescales an image to be in certain value range. This was created as sometimes DICOM scale and slope parameters may be inconsistent across sites and the data need to be value restricted

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
rescale_img(
  filename,
  pngname = NULL,
  write.nii = FALSE,
  outfile = NULL,
  min.val = -1024,
  max.val = 3071,
  ROIformat = FALSE,
  drop_dim = TRUE,
  writer = "dcm2nii",
  ...
)

Arguments

filename

filename of image to be read into R or nifti object

pngname

filename of png of histogram of values of image to be made. For no png - set to NULL (default)

write.nii

logical - should the image be written.

outfile

if write.nii = TRUE, filename of output file

min.val

minimum value of image (default -1024 (for CT)). If no thresholding set to -Inf

max.val

maximum value of image (default 3071 (for CT)). If no thresholding set to Inf

ROIformat

if TRUE, any values $< 0$ will be set to 0

drop_dim

Should drop_img_dim be applied?

writer

character value to add to description slot of NIfTI header

...

extra methods to be passed to writenii

Value

Object of class nifti

Examples

1
2
3
4
5
img = nifti(array(rnorm(10^3, sd = 1000), dim = rep(10, 3)))
outfile = tempfile(fileext = ".nii.gz")
pngname = tempfile(fileext = ".png")
rescale_img(img, write.nii = TRUE, outfile = outfile,
pngname = pngname)

neuroconductor-devel-releases/neurobase documentation built on May 6, 2020, 4:25 p.m.