Skip to content

Bruker M4 Tornado bcf-files spectrum_image does not match pixel spectra #516

Description

@paprika113

testBCF_M4_Tornado.zip

Hello,
I am new to this community. Firstly, I would like to thank the community and especially @sem-geologist for creating the bruker library and making it available in rsciio!!
I am working with M4 Tornado µXRF from Bruker and I know that the library is initially designed for Bruker EDX which I do not have access to.
I observed inconsistencies comparing the spectrum maps from bruker.file_reader of the bcf files and the single pixel spectra .spx files, which I can generate using the M4 Tornado Software.

I used
bcf = bruker.file_reader(bcf_file, select_type='spectrum_image')[0]
to get a spectrum image of the bcf file "minBcf.bcf" (a 3x3-pixel bcf added in the attachment).
I used the M4 Tornado software to generate the "P1.spx" file of the first pixel (added in attachment)
spx = bruker.file_reader(spx_file)[0]['data'] gives me the spectrum of the P1.spx-file
I compared the spectra that I got within the file_reader
bcf['data'][0][0]
I plotted the spectra (channels 80 to 120) in 'P1_compare_spx_bcf.png' for quick visualization.
Obviously they don`t match, although they should.

I observed this kind of behaviour in all bcf files I looked at.

I had a closer look at the py_parse_hypermap function and tried to investigate the bitstream of the first pixel.
(BTW: again big respect to @sem-geologist for figuring out all that!)
In the attached file 'p1_bitstream.pkl' I dumped the bitstream of the first Pixel as a binary file (although I am not 100% sure that it is only the first pixel). But it does start with the pixel header (x_pix, chan1, chan2, ...) encoded in <IHHIHHHI. Then comes the instructively packed data (flag == 2). The first 88 channels of the example file have counts = 0. So size_p, channels (the first two bytes) encoded in <BB give me (0, 88). Fine so far! Up to channel 88 everything matches with P1.spx.
Then things get messy. Next two bites give me size_p, channels = (2, 6) meaning the next seven bytes must be gain = 0 in <B and then six bytes actually giving me the counts for channels 89 to 94 encoded in <BBBBBB.
These six number are (2, 5, 11, 22, 24, 47). In the P1-spx file the counts of channel 89 to 94 are (2, 8, 15, 34, 60, 90).

So for now I am rather sure that M4 Tornado uses a slightly different encoding than Bruker EDX Software.
The question is which one?

I hope the explanation and the example files can help to fix that issue.

Python environment:

  • RosettaSciIO version: 0.13.0
  • Python version: 3.12.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions