These data input functions are deprecated and they will be removed in the next release of hyperspec package. Now functions in package hySpc.read.ENVI (link) should be used as the alternatives.
This function allows ENVI data import as
read.ENVI.Nicolet() should be a good starting point for writing custom
read.ENVI() that take into account your manufacturer's
special entries in the header file.
read.ENVI( file = stop("read.ENVI: file name needed"), headerfile = NULL, header = list(), keys.hdr2data = FALSE, x = 0:1, y = x, wavelength = NULL, label = list(), block.lines.skip = 0, block.lines.size = NULL, ..., pull.header.lines = TRUE ) read.ENVI.HySpex( file = stop("read.ENVI.HySpex: file name needed"), headerfile = NULL, header = list(), keys.hdr2data = NULL, ... ) read.ENVI.Nicolet( file = stop("read.ENVI: file name needed"), headerfile = NULL, header = list(), ..., x = NA, y = NA, nicolet.correction = FALSE )
complete name of the binary file
name of the ASCII header file. If
NULL, the name
of the header file is guessed by looking for a second file with the same
list with header information, see details. Overwrites information extracted from the header file.
determines which fields of the header file should be put into the extra data. Defaults to none.
To specify certain entries, give character vectors containing the lowercase names of the header file entries.
vectors of form c(offset, step size) for the position vectors, see details.
lists that overwrite the respective information
from the ENVI header file. These data is then handed to
BIL and BIP ENVI files may be read in blocks of lines:
skip the first
block.lines.skip lines, then read a block of
block.lines.NULL, the whole file is read.
Blocks are silently truncated at the end of the file (more precisely: to
currently unused by
read.ENVI.Nicolet hands those arguements over to
(internal) flag whether multi-line header entries grouped by curly braces should be pulled into one line each.
ENVI data usually consists of two files, an ASCII header and a binary data file. The header contains all information necessary for correctly reading the binary file.
I experienced missing header files (or rather: header files without any contents) produced by Bruker Opus' ENVI export.
In this case the necessary information can be given as a list in parameter
|integer||no of columns / spectra in x direction|
|integer||no of lines / spectra in y direction|
|integer||no of wavelengths / data points per spectrum|
|format of the binary file|
|1||1 byte unsigned integer|
|2||2 byte signed integer|
|3||4 byte signed integer|
|4||4 byte float|
|5||8 byte double|
|9||16 (2 x 8) byte complex double|
|12||2 byte unsigned integer|
|integer||number of bytes to skip before binary data starts|
|directions of the data cube|
|"BSQ"||band sequential (indexing: [sample, line, band])|
|"BIL"||band interleave by line (indexing: [sample, line, band])|
|"BIP"||band interleave by pixel (indexing: [band, line, sample])|
|0 or "little"||little endian|
|1 or "big"||big endian|
|"swap"||swap byte order|
Some more information that is not provided by the ENVI files may be given:
Wavelength axis and axis labels in the respective parameters. For more
The spatial information is by default a sequence from 0 to
header$samples - 1 and
header$lines - 1, respectively.
y give offset of the first spectrum and step size.
Thus, the object's
$x colum is:
(0 : header$samples - 1) * x  + x . The
$y colum is calculated analogously.
Nicolet uses some more keywords in their header file. They are interpreted as follows:
|description||giving the position of the first spectrum|
|z plot titles||wavelength and intensity axis units, comma separated|
|pixel size||interpreted as x and y step size
These parameters can be overwritten by giving a list with the respective
elements in parameter
The values in header line description seem to be microns while the pixel
size seems to be in microns. If
nicolet.correction is true, the
pixel size values (i.e. the step sizes) are multiplied by 1000.
This function was adapted from
Jarek Tuszynski (2008). caTools: Tools: moving window statistics, GIF, Base64, ROC AUC, etc.. R package version 1.9.