I found an error in GSSpcWrite.m . It outputs the xtype, ytype, and ztype to the header as a string instead of the correct single byte binary format. This is especially bad if the string has more than one byte since the rest of the header will get messed up.
The fix is to change lines 578 through 592 to the following code which simply converts the string to a single binary byte.
Thanks to Kris for making this very helpful set of routines available to us.
if isfield (spectra, 'xtype')
ThisSpcHdr.fxtype = uint8(str2double(LocateItem (spectra.xtype, Types.X, 2))); %%std%%%BYTE: Type of X units
else
ThisSpcHdr.fxtype = 13; %%std%%%BYTE: Type of X units
end
if isfield (spectra, 'ytype')
ThisSpcHdr.fytype = uint8(str2double(LocateItem (spectra.ytype, Types.Y, 2))); %%std%%%BYTE: Type of Y units
else
ThisSpcHdr.fytype = 0; %%std%%%BYTE: Type of Y units
end
if isfield (spectra, 'ztype')
ThisSpcHdr.fztype = uint8(str2double(LocateItem (spectra.ztype, Types.X, 2))); %%std%%%BYTE: Type of z units
else
ThisSpcHdr.fztype = 0; %%std%%%BYTE: Type of Z units
end
15 Dec 2010
GSTools
A set of matlab functions to read, write and deal with .spc spectra and spectral descriptions
Author: Kris De Gussem
This is exactly what I was looking for! Unfortunately, when I try to import multiple files, I get the following error:
EDU>> GSImportspec()
Warning: Multifile flag is set. But SPC-file does not contain multiple spectra.
> In GSSpcRead at 236
In GSImportspec at 245
??? Subscripted assignment between dissimilar structures.
Error in ==> GSImportspec at 245
spectra(i) = GSSpcRead (spcfiles(i).name, -1, 0);
26 Oct 2009
GSTools
A set of matlab functions to read, write and deal with .spc spectra and spectral descriptions
Author: Kris De Gussem
I ran into one last problem, the exponent values in the headers/subheaders are in char form, meaning that if they are between 129 - 255, then they are actually between -127 to -1, or at least they are in the files I am reading in.
this causes the Y-axis to be incorrectly scaled, the fix I put in for this is in GSSpcRead; line 689, I inserted the following check loop at 689;
if YScalingExp > 128
YScalingExp = YScalingExp-256;
end
then the file should continue
CurrSpec = ........
I assume the process would be the same for the 16 bit input integers, in which case you would have to also put that check into line 675.