
grab ’em all — {opusreader2} lets you import OPUS measurement data and parameters from Bruker Optics GmbH & Co. instruments directly in R. Developed in our spare time — if you find it useful, consider buying us a coffee!
The Bruker corporation produces reliable instruments; however, there is no official documentation for the OPUS file format, making it proprietary. Fortunately, over time, our team and colleagues from the open-source spectroscopy community have figured out how the OPUS binary format is structured and how we can parse it (see credits).
{opusreader2} has no hard dependencies beyond base R. Community efforts are there to enhance support for a growing array of instruments, measurement modes, and block types.
The latest version can be installed
if (!require("remotes")) install.packages("remotes")
remotes::install_git("https://codefloe.com/spectral-cockpit/opusreader2")# Install the latest version
install.packages("opusreader2", repos = c(
spectralcockpit = 'https://spectral-cockpit.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))We recommend to start with the vignette “Reading OPUS binary files from Bruker® spectrometers in R”.
library("opusreader2")
# read a single file (one measurement)
file <- opus_test_file()
data <- read_opus(dsn = file)If highspeed at data consuming systems matters, we recommend to use the optional but integrated {mirai} backend functionality. This way you can read a massive amount of OPUS files in parallel, benefitting from the underlying Nanomsg Next Generation bindings. This way you can support cluster computing systems, via inter-process communications, TCP or secure TLS. For this, parallel workers need to be registered.
files_1000 <- rep(file, 10000L)
if (!require("mirai")) install.packages("mirai")
library("mirai")
daemons(n = 2L, dispatcher = TRUE)
data <- read_opus(dsn = files_1000, parallel = TRUE)If parallel = TRUE, progress updates via {progressr} are
optionally available
if (!require("progressr")) install.packages("progressr")
library("progressr")
handlers(global = TRUE)
handlers("progress") # base R progress animation
file <- opus_test_file()
files_1000 <- rep(file, 1000L)
# read with progress bar
data <- read_opus(dsn = files_1000, parallel = TRUE, progress_bar = TRUE)data <- read_opus_single(dsn = file)We strive to have a full-fledged reader of OPUS files that is on par with the commercial reader in the Bruker OPUS software suite. That is an ambitious goal and needs collaborative efforts, from development to in-depth testing with Bruker equipment and measurement software. Therefore, you can help the community in various forms:
We like the spirit of open source development, so any constructive suggestions or questions are always welcome. To trade off the consistency and quality of code with the drive for innovation, we are following some best practices (which can be indeed improved, as many other things in life). These are:
.pre-commit-config.yaml. Generally, we follow the tidyverse
style guide, with slight exceptions. To provide auto-fixing in PRs where
possible, we rely on pre-commit.ci lite.# in terminal
pip3 install pre-commit --user.pre-commit-config.yaml# change to cloned git directory of your fork of the package
pre-commit installOnce you do a
git commit -m "<your-commit-message>", the defined
pre-commit hooks will automatically be applied on new commits.
# in your terminal and package root directory
pre-commit run --all-filesgit clone ssh://git@codefloe.com/spectral-cockpit/opusreader2.git
cd opusreader2
hyperfine --warmup 3 --min-runs 5 ./inst/scripts/benchmark_read_opus_parallel.sh --show-outputAs far as we know, the following organizations and projects use our package. Please make a pull request if you want to be listed here.
This package is a major rework of {opusreader} made by Pierre Roudier and Philipp Baumann. This precessor package relies on an interesting but not optimal reverse engineered logic. Particularly, the assignment of spectral data types (i.e., single channel reflectance vs. final result spectrum), was buggy because the CO2 peak ratio was used as a heuristic. Also, byte offsets from three letter strings were directly used to read specific data and assign block types.
The new package parses the file header for assigning spectral blocks.