如何从扩展名为 *.spa 的 Nicolet FTIR 光谱文件中读取数据

发布于 2024-09-02 04:14:41 字数 98 浏览 2 评论 0原文

  1. *.spa 二进制文件格式是商业秘密吗?但Perkin Elmer 向公众公开了*.sp 格式;

  2. 如何阅读?

  1. Is the *.spa binary file format trade secret? But Perkin Elmer released *.sp format to public;

  2. how to read?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦罢 2024-09-09 04:14:41

我知道这个线程现在有点旧了,但我最近需要阅读 SPA 文件,并且想分享我如何设法应对它们。
正如 cooooldog 所说,0x41c 偏移量不是标准的。但是,此偏移量是在 spa 文件本身中编码的。
编辑 spa 文件时,开头有一个短标头,然后是许多零。从 0x11e 开始是非零值。
以下是我如何设法找到光谱文件的正确偏移量的方法:
从 0x11e 开始,我开始读取 int32 值。数据偏移量似乎是在该值之前编码的:54 18 00 00(十进制为 6228)。
编辑:我收到了一组新的 spa 文件,其中搜索的模式不再是 54 18 00 00 而是 40 61 00 00 (24896),因此这可能也不是标准的。事实上,spa 文件中的起始地址似乎编码为 172h 或 182h。我仍然需要一种方法来找到它。
因此,通过查找 6228,稍后在文件中查找数据所需的偏移量就是在该值 6228 之前找到的整数。
如果继续编辑 spa 文件,您应该会找到 32 位编码的浮点值,放置在一堆文本之后。
从现在开始,只需将 0x41c 替换为找到的地址即可读取这些值。
如果这可以帮助任何人......

function address = getStart(filename)  
    try  
        % Open the file  
        fid=fopen(filename,'r');  
        % Jump where the values become interesting  
        fseek(fid,hex2dec('11e'),'bof');  
        % Pattern we're looking for  
        pattern = 6228;  
        suspect = 0;  
        while suspect~=pattern  
            oldSuspect = suspect;  
            suspect    = fread(fid,1,'int32');  
        end  
        % The correct address is just before our current suspect  
        address = oldSuspect;  
        % Close the file  
        fclose(fid);  
    catch ex  
        address = 0;  
        disp(ex)  
end  

I know this thread is a bit old now, but I needed to read SPA files recently, and would like to share how I managed to cope with them.
As stated by cooooldog, 0x41c offset is not standard. However, this offset is coded in the spa file itself.
When editing a spa file, there is a short header at the beginning, then many zeros. From 0x11e are non-zero values.
Here is how I managed to find the correct offset for my spectral files:
Starting from 0x11e, I start reading int32 values. It appears that the data offset is coded just before this value : 54 18 00 00 (which is 6228 in decimal).
Edit : I've received new set of spa files where the searched pattern is no longer 54 18 00 00 but 40 61 00 00 (24896), so this might not be standard as well. In fact it appears that starting address is either coded at 172h or 182h in the spa file. I do still need a way to find it out.
So by looking for 6228, the offset needed to find data later in the file is the integer found just before this value of 6228.
If you continue editing your spa file, you should find floating point values, 32-bit coded, placed just after a bunch of text.
From now, reading those values is possible, by just replacing 0x41c by the address found.
If this may help anyone...

function address = getStart(filename)  
    try  
        % Open the file  
        fid=fopen(filename,'r');  
        % Jump where the values become interesting  
        fseek(fid,hex2dec('11e'),'bof');  
        % Pattern we're looking for  
        pattern = 6228;  
        suspect = 0;  
        while suspect~=pattern  
            oldSuspect = suspect;  
            suspect    = fread(fid,1,'int32');  
        end  
        % The correct address is just before our current suspect  
        address = oldSuspect;  
        % Close the file  
        fclose(fid);  
    catch ex  
        address = 0;  
        disp(ex)  
end  
平生欢 2024-09-09 04:14:41

我发现光谱偏移的设置位置是在位置 386:

fseek(fid,386,'bof'); 
spectral_offset = fread(fid,1,'int32')

fseek(fid,spectral_offset,'bof'); 
spectrum=fread(fid,Number_of_DataPoints,'single');

I found where the spectral offset is set, it is on position 386:

fseek(fid,386,'bof'); 
spectral_offset = fread(fid,1,'int32')

fseek(fid,spectral_offset,'bof'); 
spectrum=fread(fid,Number_of_DataPoints,'single');
你曾走过我的故事 2024-09-09 04:14:41

Matlab 实现

https://cn.mathworks.com/matlabcentral/fileexchange/57904 -加载光谱

您需要导入光谱文件才能分析 FTIR 和 NIR 吸光度数据。此函数将 .SPA 格式文件中的数据加载到矩阵中,并将光谱组织成列。

C/C++实现:

Github上有一个小型开源项目:

https:// github.com/aitap/spa2txt

程序读取 Nicolet FTIR 光谱文件(*.spa 扩展名)并生成
文本文件,第一行对应于标题,每隔一行
格式为:波数、制表符、吸光度、换行符。

用法:将 *.spa 文件作为命令行参数。名称为 *.spa.txt 的文件将
被创建。

Matlab implementation

https://cn.mathworks.com/matlabcentral/fileexchange/57904-loadspectra

You need to import the spectrum files in order to analyze FTIR and NIR absorbance data. This function loads data from .SPA format files into matrices with the spectra organized into columns.

C/C++ implemetation:

There is a small open source project on Github:

https://github.com/aitap/spa2txt

The program reads Nicolet FTIR spectral files (*.spa extension) and produces
text files with the first line corresponding to the title, and every other line
being in the format: wavenumber, tab, absorbance, newline.

Usage: feed *.spa files as command line arguments. Files with names *.spa.txt will
be created.

寄离 2024-09-09 04:14:41

'如何处理.spa(频谱分析仪输出文件)usnig matlab'
好吧,我认为处理读取 .spa 文件的最佳方法是首先使用“记事本”文件将其转换为 txt,然后使用导入工具将其导入到 matlab,该工具为您提供了大量从制表符分隔到以制表符分隔的函数自定义分隔
之后,您选择需要从 .spa 文件中提取的频率和接收功率
有关更多详细信息,您可以查看

https:// nl.mathworks.com/videos/importing-data-from-text-files-interactively-71076.html

这对我处理 .spa 频谱分析仪输出文件有很大帮助

:)

'how to deal with.spa (spectrum analyzer output files ) usnig matlab'
well i think the best way to deal with reading .spa files is first to convert it to txt using 'notepad' file and then import it to matlab using the importing tool which gives you a huge amount of functions starting from tab delimited and ending with custom delimited
after that you select the frequencies and the received power you need to extrat from .spa file
for more details you can check

https://nl.mathworks.com/videos/importing-data-from-text-files-interactively-71076.html

it was a great help for me dealing with .spa spectrum analyzer output files

:)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文