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
rescale_img(
filename,
pngname = NULL,
write.nii = FALSE,
outfile = NULL,
min.val = -1024,
max.val = 3071,
ROIformat = FALSE,
drop_dim = TRUE,
writer = "dcm2nii",
...
)filename of image to be read into R or nifti object
filename of png of histogram of values of image to be made. For no png - set to NULL (default)
logical - should the image be written.
if write.nii = TRUE, filename of output file
minimum value of image (default -1024 (for CT)). If no thresholding set to -Inf
maximum value of image (default 3071 (for CT)). If no thresholding set to Inf
if TRUE, any values $< 0$ will be set to 0
Should drop_img_dim be applied?
character value to add to description slot of NIfTI header
extra methods to be passed to writenii
Object of class nifti
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)
#> [1] "/tmp/Rtmpl6h6zN/file7c87504341a0.png"
#> NIfTI-1 format
#> Type : nifti
#> Data Type : 2 (UINT8)
#> Bits per Pixel : 8
#> Slice Code : 0 (Unknown)
#> Intent Code : 0 (None)
#> Qform Code : 0 (Unknown)
#> Sform Code : 0 (Unknown)
#> Dimension : 10 x 10 x 10
#> Pixel Dimension : 1 x 1 x 1
#> Voxel Units : Unknown
#> Time Units : Unknown