| Title: | Read Spectroscopic Data from Bruker OPUS Binary Files |
| Version: | 0.6.8 |
| Description: | Reads data from Bruker OPUS binary files of Fourier-Transform infrared spectrometers of the company Bruker Optics GmbH & Co. This package is released independently from Bruker, and Bruker and OPUS are registered trademarks of Bruker Optics GmbH & Co. KG. https://www.bruker.com/en/products-and-solutions/infrared-and-raman/opus-spectroscopy-software/latest-release.html. It lets you import both measurement data and parameters from OPUS files. The main method is 'read_opus()', which reads one or multiple OPUS files into a standardized list class. Behind the scenes, the reader parses the file header for assigning spectral blocks and reading binary data from the respective byte positions, using a reverse engineering approach. Infrared spectroscopy combined with chemometrics and machine learning is an established method to scale up chemical diagnostics in various industries and scientific fields. |
| License: | MIT + file LICENSE |
| URL: | https://opusreader2.spectral-cockpit.codefloe.page/, https://codefloe.com/spectral-cockpit/opusreader2/ |
| BugReports: | https://codefloe.com/spectral-cockpit/opusreader2/issues/ |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0), progressr, mirai (≥ 2.5.0) |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Language: | en-US |
| Packaged: | 2026-01-29 05:14:13 UTC; philipp |
| Author: | Philipp Baumann |
| Maintainer: | Philipp Baumann <baumann-philipp@protonmail.ch> |
| Repository: | CRAN |
| Date/Publication: | 2026-02-03 10:30:08 UTC |
calculate the full chunk size
Description
calculate the full chunk size
Usage
calc_chunk_size(ds)
Arguments
ds |
dataset |
Calculate the parameter chunk size in bytes
Description
Calculate the parameter chunk size in bytes
Usage
calc_parameter_chunk_size(ds)
Arguments
ds |
data set with one of classes |
Value
Number of bytes as length 1 numeric vector
assign the classes to the dataset list
Description
assign the classes to the dataset list
Usage
create_dataset(header_data)
Arguments
header_data |
list of the header information for each block |
Construct new class list_opusreader2
Description
Construct new class list_opusreader2
Usage
new_list_opusreader2(dataset_list)
Arguments
dataset_list |
dataset list, where each list element is a measured spectrum |
List wrapper that reads a list of files (dsn) via read_opus_single()
and returns spectra in a list
Description
List wrapper that reads a list of files (dsn) via read_opus_single()
and returns spectra in a list
Usage
opus_lapply(dsn, data_only)
Arguments
dsn |
data source name. Can be a path to a specific file or a path to a directory. The listing of the files in a directory is recursive. |
data_only |
read data and parameters with |
Value
nested list where first-level elements are individual spectral
measurements parsed from individual OPUS binary files; the output is
identical to its user exposed reading interface, see ?read_opus
spectra list containing the elements described in ?read_opus
See Also
read_opus() read_opus_single()
Get File Paths of Sample OPUS Files Included in the Package
Description
Utility function that retrieves the location of the sample OPUS binary file on disk.
Usage
opus_test_dsn()
Value
a character vector with the paths OPUS files included in the package
Examples
(dsn <- opus_test_dsn())
Get path of a Selected Sample OPUS File Included in the Package
Description
Utility function that retrieves the location of the sample OPUS binary file on disk.
Usage
opus_test_file()
Value
a character vector with the path to a selected single sample OPUS file
Examples
(fn <- opus_test_file())
read chunk method
Description
read chunk method
Usage
parse_chunk(ds, raw)
Arguments
ds |
chunk dataset |
raw |
raw vector |
See Also
Parsing helper
parse_header()
read chunk method for data
Description
read chunk method for data
Usage
## S3 method for class 'data'
parse_chunk(ds, raw)
Arguments
ds |
chunk dataset |
raw |
raw vector |
read chunk method for default
Description
read chunk method for default
Usage
## Default S3 method:
parse_chunk(ds, raw)
Arguments
ds |
chunk dataset |
raw |
raw vector |
read chunk method for parameter
Description
read chunk method for parameter
Usage
## S3 method for class 'parameter'
parse_chunk(ds, raw)
Arguments
ds |
chunk dataset |
raw |
raw vector |
read chunk method for text
Description
read chunk method for text
Usage
## S3 method for class 'text'
parse_chunk(ds, raw)
Arguments
ds |
chunk dataset |
raw |
raw vector |
parse the header of the opus file
Description
parse the header of the opus file
Usage
parse_header(raw)
Arguments
raw |
raw vector of the opus binary file |
See Also
Parsing helper
parse_chunk()
Parse data, parameters and text from raw vector of OPUS file saved after one spectral measurement of a Bruker FT-IR device.
Description
This function is internally used to parse the raw vector of the OPUS file
after reading it with read_opus_raw().
Usage
parse_opus(raw, data_only)
Arguments
raw |
a vector containing bytes (class "raw"). |
data_only |
logical (default |
Value
Nested list (S3 object) containing the parsed contents of the binary
encoded blocks of an OPUS file. The first level names of the list correspond
to the display names as shown in the Bruker OPUS viewer software. However, in
snake_case and more standardized naming to allow for better output handling.
Each parsed block element is a sublist containing a) the binary read
instructions decoded/derived from the header ($block_type, $channel_type,
$text_type and $additional_type, $offset (bytes), $next_offset
(bytes), $chunk_size (bytes)); b) if parameter block, nested list of
specific parameters under $parameters, which has elements named according
to capitalized Bruker-internal "three-letter-string" definitions (e.g.,
"DPF := Data Point Format"). Possible first-level block names and
information provided include:
-
refl_no_atm_comp_data_param: class "parameter" (viewer: "Data Parameters Refl". Parameter list with metadata forrefldata block (refl). -
refl_no_atm_comp: class "data" (spectrum; viewer: "Refl"). Unprocessed (raw; i.e, not atmospherically compensated) reflectance spectra (:= sc_sample / sc_ref). Note that this element is the untreated spectra before an eventual "atmospheric compensation" routine is applied. -
refl_data_param: class "parameter" (viewer: "Data Parameters Refl"). Parameter list with metadata forrefldata block (metadata of reflectance spectrum; seerefloutput). Note that this element only results if "atmospheric compensation" was activated in the OPUS measurement settings. -
refl: class "data" (spectrum; viewer: "Refl"). Atmospherically compensated reflectance spectra (:= sc_sample_corr / sc_ref_corr). This result spectrum only exists if either correction of CO2 and/or water vapour bands is set in OPUS setting (proprietary algorithm; could possibly be reverse engineered). Ifreflexists, it has always a corresponding untreatedrefl_no_atm_compspectrum (the latter present in file but not shown in the OPUS viewer, where only (final)abis displayed) -
quant_report_refl: class "parameter" (viewer: "Quant Report Refl"). Quantification report for tools of multivariate calibration onrefldata (i.e., PLS regression) offered in the QUANT2 OPUS package. Nested list with Bruker-internal "three-letter-string" definitions. "TIT" is the title of a nested quantification table,"E<digit>[2]"stands probably for entry,"F<digit>[2]"for field, and"Z<digit>[2]"we do not yet know what it maps to. There seems more information needed, which we can get by expanding the header parsing algorithm. -
ab_no_atm_comp_data_param: class "parameter" (viewer: "Data Parameters AB"). Parameter list with metadata forabdata block (spectrum; seeaboutput). -
ab_no_atm_comp: class "data" (spectrum; viewer: "Refl"). Unprocessed (raw; i.e, not atmospherically compensated) reflectance spectra (:= sc_sample/ sc_ref). -
ab_data_param: class "parameter" (viewer: "Data Parameters Refl"). Parameter list with metadata forabdata block (spectrum; seeab). Note that this element only results if "atmospheric compensation" was activated in the OPUS measurement settings. -
ab: class "data" (spectrum; viewer: "AB"). Atmospherically compensated (apparent) absorbance spectra (:= log(1 / (sc_sample_corr / sc_ref_corr)). Only exists if either correction of CO2 and/or water vapour bands is set in OPUS setting (proprietary algorithm; could possibly be reverse engineered). IfABexists, it has always a corresponding untreatedab_no_atm_compspectrum (the latter present in file but not shown in the OPUS viewer, where only finalabis displayed). -
quant_report_ab: class "parameter" (viewer: "Quant Report AB"). Quantification report for tools of multivariate calibration onabdata (i.e., PLS regression) offered in the QUANT2 OPUS package. Nested list with Bruker-internal "three-letter-string" definitions. "TIT" is the title of a nested quantification table,"E<digit>[2]"stands probably for entry,"F<digit>[2]"for field, and"Z<digit>[2]"we do not yet know what it maps to. There seems more information needed, which we can get by expanding the header parsing algorithm. -
sc_sample_data_param: class "parameter" (metadata; viewer: "Data Parameters ScSm"). Describes thesc_sampledata block (seesc_sample). -
sc_sample: class "data" (spectrum). Single channel (sc) spectrum of the sample (y-axis: intensity). -
ig_sample_data_param: class "parameter" (metadata; viewer: "Data Parameters IgSm"). -
ig_sample: class "data" (signal, viewer: "IgSm"). Interferogram of the sample measurement. Oscillatory signal (x-axis: optical path difference (OPD); y-axis: amplitude of the signal). -
sc_ref_data_param: class "parameter" (metadata; viewer: "Data Parameters ScRf"). Describes thesc_sampledata block (seesc_ref). -
sc_ref: class "data" (spectrum; viewer: "Data Parameters IgSm"). Single channel (sc) spectrum of the reference (background material: e.g., gold; y-axis: intensity). -
ig_ref_data_param: class "parameter" (metadata; viewer: "Data Parameters IgRf"). -
ig_ref: class "data" (spectrum; viewer: "IgRf"). Interferogram of the reference measurement. (background material: e.g., gold). Oscillatory signal (x-axis: optical path difference (OPD); y-axis: amplitude of the signal) -
optics: class "parameter (metadata; viewer: "Optic Parameters"). Optic setup and settings such as "Accessory", "Detector Setting" or "Source Setting". -
optics_ref: class "parameter (metadata; viewer: "Optic Parameters Rf"). Optic setup and settings specific to reference measurement such as "Accessory", "Detector Setting" or "Source Setting". -
acquisition_ref: class "parameter" (metadata; viewer: "Acquisition parameters Rf". Settings such as ""Additional Data Treatment", (number) of "Background Scans" or "Result Spectrum" (e.g. value "Absorbance"). -
fourier_transformation_ref: -
fourier_transformation: class "parameter" -
sample: -
acquisition: -
instrument_ref: -
instrument: -
lab_and_process_param_1: -
lab_and_process_param_2: -
info_block: -
history:
See Also
Print method for collection of OPUS spectra with class list_opusreader2
Description
Print method for collection of OPUS spectra with class list_opusreader2
Usage
## S3 method for class 'list_opusreader2'
print(x, ...)
Arguments
x |
List with OPUS spectra collection of class |
... |
Additional arguments passed to print method |
Value
Returns x invisibly.
read character from binary
Description
read character from binary
Usage
read_character(raw, cursor, n = 1L, n_char, encoding = "latin1")
Arguments
raw |
raw vector |
cursor |
offset |
n |
number of elements |
n_char |
integer with number of desired characters to read from raw |
encoding |
encoding to assign character strings that are read. Default
is |
read double from binary (double-precision, 64 bits)
Description
read double from binary (double-precision, 64 bits)
Usage
read_double(raw, cursor, n = 1L)
Arguments
raw |
raw vector |
cursor |
offset |
n |
number of elements |
read float from binary (single-precision, 32 bits)
Description
read float from binary (single-precision, 32 bits)
Usage
read_float(raw, cursor, n = 1L)
Arguments
raw |
raw vector |
cursor |
offset |
n |
number of elements |
Read OPUS binary files from Bruker spectrometers
Description
Read and parse OPUS files with spectral data from individual measurements
Usage
read_opus(dsn, data_only = FALSE, parallel = FALSE, progress_bar = FALSE)
Arguments
dsn |
data source name. Can be a path to a specific file or a path to a directory. The listing of the files in a directory is recursive. |
data_only |
read data and parameters with |
parallel |
read files in parallel via |
progress_bar |
print a progress bar. Default is |
Value
List with OPUS spectra collection of class list_opusreader2. The
individual elements are individual sample measurement data extracted from the
corresponding OPUS binary files, as parsed from the encoded data blocks.
Each element in list_opusreader2 contains metadata and measurement data
equivalent to their names displayed in the Bruker OPUS viewer software.
However, we used snake_case and standardized the naming for better output
handling.
Each parsed block element is a sublist that contains
1. the binary read instructions decoded/derived from the header
($block_type, $channel_type, $text_type and $additional_type,
$offset (bytes), $next_offset (bytes), $chunk_size (bytes)).
2. if parameter block, nested list of specific parameters under
$parameters, which has elements named according to capitalized
Bruker-internal "three-letter-string" definitions (e.g., "DPF := Data Point
Format").
Possible first-level block names and information provided include:
-
refl_no_atm_comp_data_param: classparameter(viewer: "Data Parameters Refl". Parameter list with metadata forrefldata block (refl). -
refl_no_atm_comp: classdata(spectrum; viewer: "Refl"). Unprocessed (raw; i.e, not atmospherically compensated) reflectance spectra (:= sc_sample / sc_ref). Note that this element is the untreated spectra before an eventual "atmospheric compensation" routine is applied. -
refl_data_param: classparameter(viewer: "Data Parameters Refl"). Parameter list with metadata forrefldata block (metadata of reflectance spectrum; seerefloutput). Note that this element only results if "atmospheric compensation" was activated in the OPUS measurement settings. -
refl: classdata(spectrum; viewer: "Refl"). Atmospherically compensated reflectance spectra (:= sc_sample_corr / sc_ref_corr). This result spectrum only exists if either correction of CO2 and/or water vapour bands is set in OPUS setting (proprietary algorithm; could possibly be reverse engineered). Ifreflexists, it has always a corresponding untreatedrefl_no_atm_compspectrum (the latter present in file but not shown in the OPUS viewer, where only (final)abis displayed) -
quant_report_refl: classparameter(viewer: "Quant Report Refl"). Quantification report for tools of multivariate calibration onrefldata (i.e., PLS regression) offered in the QUANT2 OPUS package. Nested list with Bruker-internal "three-letter-string" definitions. "TIT" is the title of a nested quantification table,"E<digit>[2]"stands probably for entry,"F<digit>[2]"for field, and"Z<digit>[2]"we do not yet know what it maps to. There seems more information needed, which we can get by expanding the header parsing algorithm. -
ab_no_atm_comp_data_param: classparameter(viewer: "Data Parameters AB"). Parameter list with metadata forabdata block (spectrum; seeaboutput). -
ab_no_atm_comp: classdata(spectrum; viewer: "Refl"). Unprocessed (raw; i.e, not atmospherically compensated) reflectance spectra (:= sc_sample/ sc_ref). -
ab_data_param: classparameter(viewer: "Data Parameters Refl"). Parameter list with metadata forabdata block (spectrum; seeab). Note that this element only results if "atmospheric compensation" was activated in the OPUS measurement settings. -
ab: classdata(spectrum; viewer: "AB"). Atmospherically compensated (apparent) absorbance spectra (:= log10(1 / (sc_sample_corr / sc_ref_corr)). Only exists if either correction of CO2 and/or water vapour bands is set in OPUS setting (proprietary algorithm; could possibly be reverse engineered). IfABexists, it has always a corresponding untreatedab_no_atm_compspectrum (the latter present in file but not shown in the OPUS viewer, where only finalabis displayed). -
quant_report_ab: classparameter(viewer: "Quant Report AB"). Quantification report for tools of multivariate calibration onabdata (i.e., PLS regression) offered in the QUANT2 OPUS package. Nested list with Bruker-internal "three-letter-string" definitions. "TIT" is the title of a nested quantification table,"E<digit>[2]"stands probably for entry,"F<digit>[2]"for field, and"Z<digit>[2]"we do not yet know what it maps to. There seems more information needed, which we can get by expanding the header parsing algorithm. -
sc_sample_data_param: classparameter(metadata; viewer: "Data Parameters ScSm"). Describes thesc_sampledata block (seesc_sample). -
sc_sample: classdata(spectrum). Single channel (sc) spectrum of the sample (y-axis: intensity). -
ig_sample_data_param: classparameter(metadata; viewer: "Data Parameters IgSm"). -
ig_sample: classdata(signal, viewer: "IgSm"). Interferogram of the sample measurement. Oscillatory signal (x-axis: optical path difference (OPD); y-axis: amplitude of the signal). -
sc_ref_data_param: classparameter(metadata; viewer: "Data Parameters ScRf"). Describes thesc_sampledata block (seesc_ref). -
sc_ref: classdata(spectrum; viewer: "Data Parameters IgSm"). Single channel (sc) spectrum of the reference (background material: e.g., gold; y-axis: intensity). -
ig_ref_data_param: classparameter(metadata; viewer: "Data Parameters IgRf"). -
ig_ref: classdata(spectrum; viewer: "IgRf"). Interferogram of the reference measurement. (background material: e.g., gold). Oscillatory signal (x-axis: optical path difference (OPD); y-axis: amplitude of the signal) -
optics: class "parameter (metadata; viewer: "Optic Parameters"). Optic setup and settings such as "Accessory", "Detector Setting" or "Source Setting". -
optics_ref: class "parameter (metadata; viewer: "Optic Parameters Rf"). Optic setup and settings specific to reference measurement such as "Accessory", "Detector Setting" or "Source Setting". -
acquisition_ref: classparameter(metadata; viewer: "Acquisition parameters Rf". Settings such as ""Additional Data Treatment", (number) of "Background Scans" or "Result Spectrum" (e.g. value "Absorbance"). -
fourier_transformation_ref: classparameter(metadata; viewer: "FT - Parameters Rf"). Fourier transform parameters of the reference sample like Apodization function ("APF"), end frequency limit ("HFQ"), start frequency limit ("LFQ"), nonlinearity correction ("NLI"), phase resolution ("PHR"), phase correction mode ("PHZ"), zero filling factor ("ZFF"). -
fourier_transformation: classparameter(metadata; viewer: "FT - Parameters"). Fourier transform parameters of the sample measurement. Seefourier_transformation_reffor possible elements contained. -
sample: classparameter(metadata; viewer: "Sample Parameters"). Extra information such as the "Operator Name", "Experiment", or "Location". -
acquisition: classparameter(metadata; viewer. "Acquisition Parameters"). Settings of sample measurement, such as "Additional Data Treatment", (number) of "Background Scans" or "Result Spectrum" (e.g. value "Absorbance"). -
instrument_ref: classparameter(metadata; viewer: "Instrument Parameters Rf"). Detailed instrument properties for the reference measurement, such as "High Folding Limit", "Number of Sample Scans", or "Actual Signal Gain 2nd Channel". -
instrument: classparameter(metadata; viewer: "Instrument Parameters"). Detailed instrument properties for the sample measurement. Seeinstrument_ref. -
lab_and_process_param_raw: classparameter(metadata). Laboratory sample annotations such as "Product Group", "Product", "Label Product Info 1" (e.g., forsample_id), "Value Product Info 1" (e.g., thesample_idvalue), or the "Measurement Position Microplate" (e.g., for HTS-XT extension) -
lab_and_process_param_processed: classparameter(metadata). Laboratory sample annotations for measurements done with additional OPUS data processing methods. Seelab_and_process_param_raw -
info_block: classparameter(metadata). Infos such as "Operator", measurement "Group", "Sample ID". These can e.g. be set though the OPUS/LAB sofware interface. -
history: classparameter(metadata). Character vector with OPUS command history. -
unknown: if a block-type can not be matched, no parsing is done and an empty list entry is returned. This gives you a hint that there is a block that can not yet be parsed. You can take further steps by opening an issue.
Details
read_opus() is the high-level interface to read multiple
OPUS files at once from a data source name (dsn).
It optionally supports parallel reads via the {mirai} backend. {mirai}
provides a highly efficient asynchronous parallel evaluation framework via
the Nanomsg Next Gen (NNG), high-performance, lightweight messaging library
for distributed and concurrent applications.
When reading in parallel, a progress bar can be enabled.
Read chunks of OPUS files in parallel using {mirai} backend via
mirai::mirai_map()
Description
Relies on background processes (daemons) set up via mirai::daemon()
Usage
read_opus_parallel_mirai(dsn, data_only, progress_bar)
Arguments
dsn |
data source name. Can be a path to a specific file or a path to a directory. The listing of the files in a directory is recursive. |
data_only |
read data and parameters with |
progress_bar |
print a progress bar. Default is |
Read the raw vector of an opus data source
Description
Read the raw vector of an opus data source
Usage
read_opus_raw(dsn)
Arguments
dsn |
source path of an opus file |
Value
list of raw vectors
Read a single OPUS file
Description
Read a single OPUS file
Usage
read_opus_single(dsn, data_only = FALSE)
Arguments
dsn |
source path of an opus file |
data_only |
read data and parameters with |
Value
list with parsed OPUS measurement and data blocks of the spectrum
measurement contained in the OPUS file. See read_opus() for details on the
list elements returned (first-level block names and information provided).
Dispatch method for the open_connection
Description
Dispatch method for the open_connection
Usage
read_raw(dsn)
Arguments
dsn |
source path of an opus file |
method to open the connection for an opus file
Description
method to open the connection for an opus file
Usage
## S3 method for class 'file'
read_raw(dsn)
Arguments
dsn |
source path of an opus file |
read signed integer from binary
Description
read signed integer from binary
Usage
read_signed_int(raw, cursor, n = 1L)
Arguments
raw |
raw vector |
cursor |
offset |
n |
number of elements |
read unsigned integer from binary
Description
read unsigned integer from binary
Usage
read_unsigned_int(raw, cursor, n = 1L)
Arguments
raw |
raw vector |
cursor |
offset |
n |
number of elements |
define class of dsn
Description
define class of dsn
Usage
set_connection_class(dsn)
Arguments
dsn |
source path of an opus file |