This function allows ENVI data import as `hyperSpec` object.

`read_ENVI_Nicolet()` should be a good starting point for writing custom wrappers for `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
)

Arguments

file

Complete name of the binary file.

headerfile

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 basename as `file` but `hdr` or `HDR` suffix.

header

list with header information, see details. Overwrites information extracted from the header file.

keys.hdr2data

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.

x, y

vectors of form c(offset, step size) for the position vectors, see details.

wavelength, label

lists that overwrite the respective information from the ENVI header file. These data is then handed to [hyperSpec::initialize()]

block.lines.skip, block.lines.size

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.size` lines. If `block.lines.NULL`, the whole file is read. Blocks are silently truncated at the end of the file (more precisely: to `header$lines`).

...

currently unused by `read_ENVI()`, `read_ENVI_Nicolet()` hands those arguments over to `read_ENVI()`.

pull.header.lines

(internal) flag whether multi-line header entries grouped by curly braces should be pulled into one line each.

nicolet.correction

see details

Value

`hyperSpec` object.

Details

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 `header` instead:

`header$`valuesmeaning
`samples`integerno of columns / spectra in x direction
`lines`integerno of lines / spectra in y direction
`bands`integerno of wavelengths / data points per spectrum
``data type``format of the binary file
11 byte unsigned integer
22 byte signed integer
34 byte signed integer
44 byte float
58 byte double
916 (2 x 8) byte complex double
122 byte unsigned integer
``header offset``integernumber of bytes to skip before binary data starts
`interleave`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\])
``byte order``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 information, see [hyperSpec::initialize()].

The spatial information is by default a sequence from 0 to `header$samples - 1` and `header$lines - 1`, respectively. `x` and `y` give offset of the first spectrum and step size.

Thus, the object's `$x` column is: `(0 : header$samples - 1) * x [2] + x [1]`. The `$y` column is calculated analogously.

Nicolet uses some more keywords in their header file. They are interpreted as follows:

descriptiongiving the position of the first spectrum
z plot titleswavelength and intensity axis units, comma separated
pixel sizeinterpreted as x and y step size (specify `x = NA` and `y = NA`)

These parameters can be overwritten by giving a list with the respective elements in parameter `header`.

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.

Functions

  • read_ENVI_HySpex():

  • read_ENVI_Nicolet():

References

This function was adapted from [caTools::read.ENVI()]:

Jarek Tuszynski (2008). caTools: Tools: moving window statistics, GIF, Base64, ROC AUC, etc.. R package version 1.9.

See also

[caTools::read.ENVI()]

Author

C. Beleites, testing for the Nicolet files C. Dicko