pierreroudier / opusreader

Reading OPUS binary files in R
GNU General Public License v3.0
4 stars 5 forks source link

Spectral data read from .0 files is sometimes background not sample #24

Open davidbenncsiro opened 2 years ago

davidbenncsiro commented 2 years ago

The data extracted from Bruker files is sometimes background data, sometimes sample data. In most of our testing, it's sample data, but in a small number of files, we're seeing background data being extracted.

Using the brukeropusreader Python library shows that sample and background data exist in the files in question.

Via the brukeropusreader Python library, sample data exists in the block whose key is "AB" (absorbance presumably) and background data exists in the data block whose key is "ScSm".

One possibility is that the order in which data blocks are stored is non-deterministic and opusreader is always reading the Nth block. Another is that the wrong block is identified.

davidbenncsiro commented 2 years ago

Two zipped examples (DECCW1013_A11.0, DECCW1034_B1.0) are attached that reveal this background data vs sample data problem:

background_vs_sample_examples.zip

davidbenncsiro commented 2 years ago

With DECCW1013_A11.0 we have (via run/debug of opus_read_raw.R)

which_AB
# [1] "idx4"

AB_assigned
# $spc_idx
# [1] "idx4"
#
# $spc_code
# [1] "spec"

I have seen other examples that look exactly like this.

From DECCW1034_B1:

which_AB
# [1] "idx2" "idx4"

AB_assigned
# $spc_idx
# [1] "idx2" "idx4"
#
# $spc_code
# [1] "spec_no_atm_comp" "spec"
davidbenncsiro commented 2 years ago

From a "good" example file (attached) where the sample data is extracted as expected:

which_AB
#"idx3" "idx4" "idx6"

AB_assigned
# $spc_idx
# [1] "idx3" "idx4" "idx6"
#
# $spc_code
# [1] "spec_no_atm_comp" "spec"

example.zip

philipp-baumann commented 2 years ago

If you want you can test this version: https://github.com/spectral-cockpit/opusreader2 It is still work in progress but we can read almost all data now.

davidbenncsiro commented 2 years ago

Thanks @philipp-baumann. Good news. I am starting to look at this and will let you know what I find.

davidbenncsiro commented 1 year ago

I'm doing some more testing but I think opusreader2 fixes this problem @philipp-baumann. Is the plan to switch to opusreader2 long term or will this code be rolled back into opusreader?

davidbenncsiro commented 1 year ago

Is there an equivalent to spec.data$metadata @philipp-baumann ?