image thumbnail

maxsich/loadSPE

version 2.7.0.0 (20.4 KB) by Maksym Sich
Load data from .SPE files (full support v2.x & v3.0) created by PI software (LightField, WinSpec).

149 Downloads

Updated 28 Mar 2018

From GitHub

View license on GitHub

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

Cite As

Maksym Sich (2021). maxsich/loadSPE (https://github.com/maxsich/loadSPE), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: xml2struct, xml2struct

Community Treasure Hunt

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

Start Hunting!
To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.