a <- array(rnorm(20 * 30 * 40 * 3), dim = c(20, 30, 40, 3))
file <- "temp.hdr"
b <- f.basic.hdr.nifti.list.create(dim(a), file)
tmpdir <- tempdir()
f.write.list.to.hdr.nifti(b, file, path.out = tmpdir)
unlink(tmpdir) # tidy up
Run the code above in your browser using DataLab