maxsich/loadSPE

版本 2.7.0.0 (20.4 KB) 作者: Maksym Sich
Load data from .SPE files (full support v2.x & v3.0) created by PI software (LightField, WinSpec).
312.0 次下载
更新时间 2018/3/28

Load data from .SPE files created by Princeton Instruments software (LightField, WinSpec). Full support for v2.x & v3.0 multi-frame, multi-ROI files and header information.
[data, wavelengths, params] = loadSPE( filename )
*data*
If the file has only one ROI and one frame then data is a simple (2D) array. If the file has one ROI but several frames then data is a 3D array of dimensions ( height, width, number of frames).
If the file has several ROIs then the data variable will look different for v2.x and v3.x spe files due to the difference in how the data is stored.
For v3.x if the file has one frame and several ROIs data is a struct data.ROI{numOfROIs}( height, width). If the file has several frames and several ROIs in each frame then data is an array of structs data (numOfFrames).ROI{numOfROIs}( height, width).
For v2.x the data will be either a 2D or 3D array, depending on the number of frames. Then params.ROI will contain a struct with info on sizes of ROIs and location on the full frame, which then can be individually extracted. This may be added in the future releases
*params*
params.version contains version info of the file. For SPE v3.x the whole XML footer is parsed as a struct in params.SpeFormat.
SPE v3.0 file and XML specification is at ftp://ftp.princetoninstruments.com/public/Manuals/Princeton%20Instruments/SPE%203.0%20File%20Format%20Specification.pdf.
For the SPE v2.x all parameters were stored in file header some of the key parameters are stored directly in the 'root' of the params struct:
params.ROI
params.xdim
params.ydim
params.xlabel
params.ylabel
params.dlabel
params.SpecGrooves
params.ExperimentTimeLocal
params.date
params.exp_sec
Full set of parameters are stored in params.full except for x and y calibrations which are stored separately as params.xcalib and params.ycalib. Full specification of the SPE v2.x header is available at
ftp://ftp.piacton.com/Public/Manuals/Princeton%20Instruments/WinSpec%202.6%20Spectroscopy%20Software%20User%20Manual.pdf.
*wavelengths*
For SPE v2.x is a single 1D array defined by either x-axis or y-axis calibration, whichever is present in the file using the polynomial
method.
For SPE v3.x wavelengths is a 1D array if there is a single ROI or a cell array of 1D arrays corresponding to the different ROIs

Examples:
- 1 frame and 1 ROI per frame
[ d, w, ~] = loadSPE( 'example.spe' );
plot( w, d );

- 1 frame and several ROIs per frame. Some ROIs are 1D spectra, some are
2D images of CCD
[ d, w, ~] = loadSPE( 'example2.spe' );
for i = 1 : length( w )
[ x, y ] = d.ROI{i}';
if y == 1 %1D spectra
plot( w{i}, d.ROI{i} );
else %2D image
imagesc( w{i}, 1:y, d.ROI{i}' );
% or could simply plot pixels imagesc( d.ROI{i}');
end
end

Copyright
XML parsing is implemented using functions based on https://mathworks.com/matlabcentral/fileexchange/28518-xml2struct, written by W. Falkena, modified by A. Wanner, I. Smirnov, X. Mo. xml2struct (C) 2012, W. Falkena

(C) 2018, M. Sich, The University of Sheffield
v2.7 27-03-2018

引用格式

Maksym Sich (2024). maxsich/loadSPE (https://github.com/maxsich/loadSPE), GitHub. 检索来源 .

MATLAB 版本兼容性
创建方式 R2012b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Data Import and Analysis 的更多信息
致谢

参考作品: xml2struct, xml2struct

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

无法下载基于 GitHub 默认分支的版本

版本 已发布 发行说明
2.7.0.0

Added checking for invalid characters in XML footer. Check for known invalid XML characters, such as 0x0 (null), and replace them with spaces (0x32).

2.6.0.0

Fixed an error where in v3.0 files 2D data was not correctly exported.

2.5.0.0

Fixed an error when in some cases XML failed to parse properly

2.4.0.0

Corrected check for 'WavelengthMapping' in v3.0 SPE XML

2.3.0.0

Corrected bug function would crash with v3.0 files without calibration

2.2.0.0

Optimised code

2.1.0.0

Corrected error where sensor's start x=0 resulted in a crush. With no ROI or binning sensor starting, x is set to 0, while in MATLAB has to be 1. Added checking this value. and shifting by 1. Applies to SPE v3.0 files

2.0.0.0

Added complete support for v2.x headers and multiple ROIs and some basic logic extracting wavelengths calibrations (for v2.x).
Updated description

1.0.0.0

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库