MyNixOS website logo
Description

Read Spectrometric Data and Metadata.

Parse various reflectance/transmittance/absorbance spectra file formats to extract spectral data and metadata, as described in Gruson, White & Maia (2019) <doi:10.21105/joss.01857>. Among other formats, it can import files from 'Avantes' <https://www.avantes.com/>, 'CRAIC' <https://www.microspectra.com/>, and 'OceanInsight' (formerly 'OceanOptics') <https://www.oceaninsight.com/> brands.

lightr: import spectral data in R

Lifecycle: stable CRAN version R build status Coverage status Reviewed by rOpenSci JOSS paper

There is no standard file format for spectrometry data and different scientific instrumentation companies use wildly different formats to store spectral data. Vendor proprietary software sometimes has an option but convert those formats instead human readable files such as csv but in the process, most metadata are lost. However, those metadata are critical to ensure reproducibility (White et al, 2015).

This package aims at offering a unified user-friendly interface for users to read UV-VIS reflectance/transmittance/absorbance spectra files from various formats in a single line of code.

Additionally, it provides for the first time a fully free and open source solution to read proprietary spectra file formats on all systems.

🗟 Citation

To cite this package in publications, please use:

Gruson H., White T.E., Maia R., (2019). lightr: import spectral data and metadata in R. Journal of Open Source Software, 4(43), 1857, https://doi.org/10.21105/joss.01857

🔧 Installation

install.packages("lightr")

You can also install the development version from rOpenSci's CRAN-like repository:

install.packages("lightr", repos = "https://dev.ropensci.org")

💻 Usage

A thorough documentation is available with the package, using R usual syntax ?function or help(function). However, users will probably mainly use two functions:

# Get a data.frame containing all useful metadata from spectra in a folder
lr_get_metadata(where = system.file("testdata/procspec_files", 
                                    package = "lightr"), 
                ext = "ProcSpec")

and

# Get a single dataframe where the first column contains the wavelengths and 
# the next columns contain a spectra each (pavo's rspec class)
lr_get_spec(where = system.file("testdata/procspec_files", package = "lightr"),
            ext = "ProcSpec")

lr_get_spec() returns a dataframe that is compatible with pavo custom S3 class (rspec) and can be used for further analyses using colour vision models.

All supported file formats can also be parsed using the lr_parse_$extension() function where $extension is the lowercase extension of your file. This family of functions return a list where the first element is the data dataframe and the second element is a vector with relevant metadata.

Only exceptions are .txt and .Transmission files because those extensions are too generic. Users will need to figure out which parser is appropriate in this case. lr_get_metadata() and lr_get_spec() automatically try generic parsers in this case.

Alternatively, you may simply want to convert your spectra in a readable standard format and carry on with your analysis with another software.

In this case, you can run:

# Convert every single ProcSpec file to a csv file with the same name and 
# location
lr_convert_tocsv(where = system.file("testdata/procspec_files", 
                                      package = "lightr"),
                 ext = "ProcSpec")

✔ Supported file formats

This package is still under development but currently supports (you can click on the extension in the tables to see an example of this file format):

OceanInsight (formerly OceanOptics)

ExtensionParser
jdxlr_parse_jdx()
ProcSpeclr_parse_procspec()
spclr_parse_spc()
jazlr_parse_jaz()
JazIrradlr_parse_jazirrad()
Transmissionlr_parse_jaz()
txtlr_parse_jaz()

Avantes

ExtensionParser
ABSlr_parse_abs()
ROHlr_parse_roh()
TRMlr_parse_trm()
trtlr_parse_trt()
tttlr_parse_ttt()
txtlr_parse_generic()
DRKlr_parse_trm()
REFlr_parse_trm()
IRR8lr_parse_irr8()
RFL8lr_parse_rfl8()
Raw8lr_parse_raw8()

CRAIC

ExtensionParser
txtlr_parse_generic()
spclr_parse_spc()

Others

ExtensionParser
csvlr_parse_generic(sep = ",")
dptlr_parse_generic(sep = ",")

As a fallback, you should always try lr_parse_generic() which offers a flexible and general algorithm that manages to extract data from most files.

If you can't find the best parser for your specific file or if you believe you are using an unsupported format, please open an issue or send me an email.

🌐 Similar projects

  • lightr itself contains some code that has been initially forked from pavo, namely the lr_get_spec() function. The code has since then been refactored and optimised for speed. pavo differs from lightr in its focus and core functionalities. The main strength of pavo is the comprehensive and user-friendly set of functions to analyse spectral data using colour vision models, while lightr focuses on the data import step.
  • photobiologyInOut also provides functions to import spectral data. The goal of the author is to provide a complete pipeline of spectral data import and analysis using a set of tightly integrated R packages. This however makes it more difficult to use a different tool for a given step of the process. On the contrary, lightr aims at proposing a light package with limited dependencies that focuses on the data import step of the process and let the user pick their favourite tool for the analysis step (pavo, colourvision, Avicol, etc.).
  • spectrolab

To our knowledge, lightr is the only gratis tool to import some complex file formats such as Avantes (ABS, ROH, TRM, RFL8) or CRAIC (spc) binary files, or OceanOptics .ProcSpec. Because of its user-friendly high-levels functions and low dependency philosophy, lightr may also hopefully prove useful for people working with other languages than R.

Contributing

There are plenty of ways you can contribute to lightr. Please visit our contributing guide.

Please note that this package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Metadata

Version

1.7.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows