Code covered by the BSD License  

Highlights from
GSTools

4.88889

4.9 | 10 ratings Rate this file 27 Downloads (last 30 days) File Size: 222.88 KB File ID: #9938

GSTools

by Kris De Gussem

 

09 Feb 2006 (Updated 19 Aug 2009)

A set of matlab functions to read, write and deal with .spc spectra and spectral descriptions

| Watch this File

File Information
Description

GSTools v0.4.3

This toolbox is an implementation to open and save SPC-spectra in matlab.

Additional routines are supplied as well: e.g.:
- GSImportspec: loads all SPC-files in a map
- GSDendrogram: this is to be used as a supplement to the matlab's toolbox function Dendrogram. GSDendrogram allows the user to put coloured labels with the samples names under the dendrogram. properly are added.
- BTree class: a binary tree implementation, which offers the user to easily inspect the different items in a list, as well as the positions of these different items. This combined approach makes it easy to work with numeric arrays and stringlists, such as spectral descriptions.

A PDF with detailed information on the usage (including some sample code) is supplied in the zip-archive.

GSTools is also included in the Biodata toolbox (doi: 10.1016/j.chemolab.2008.08.003).

Required Products Statistics Toolbox
MATLAB release MATLAB 6.5 (R13)
Other requirements Statistics toolbox is only required in order to make dendrograms.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
12 Apr 2006 Rachel Rohde

I have only used this for reading in an .spc file. It worked great. It even plots the spectra so you know it was loaded properly.

06 Sep 2006 Rich Williams

Haven't used it for .spc files, but it includes an easy to use BTree class. Note that the @BTree\private\DoCompare.m method will fail upon unsigned types unless you replace the line

     tmp = item - value;

with

     tmp = (item > value) - (item < value);

13 Nov 2006 Dominique Bertrand

I needed to import SPC files and it works immediately.

05 Sep 2007 Gerbe van Dreumel

Use it for importing multi-dimensional spectra: and it works perfect!

03 Feb 2008 Pall Thordarson

Just downloaded it to convert SPC Raman data and it works perfectly! Noted a small error in the manual on page 2: plot (SData.xaxis, data);
doesn't work, just change to:
plot (SData.xaxis, Sdata.data); and it works fine.

20 Jun 2008 matt o'brien

fantastic bit of code, works better than the old GRAMS converter ive been using until now!

26 Oct 2009 Cameron Bowles

fixed-point signed fractions,

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.

26 Oct 2009 Cameron Bowles

I found an error for opening multifiles using GSSpcRead.m.

line 437 is;
data = zeros (l,Specdata.spectra(1).data);

and it should be;
data = zeros (l,length(Specdata.spectra(1).data));

Other then that I have had no problems, a great piece of code, good work Kris

15 Dec 2010 Joseph

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);

15 Dec 2010 Joseph

Oops, I'm sorry. I was inputting the wrong compatibility. Never mind.

28 Apr 2011 Larry Weber

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

Please login to add a comment or rating.
Updates
13 Feb 2006

license added in zip-file

15 May 2006

Important bugs in GSSpcRead and GSSpcWrite are fixed. Functions now correctly interprete flags in the headers of the SPC-files.

20 Jun 2006

bug fixes, code optimisation and support for old SPC-file format

10 Jul 2006

User can now set the axis types in GSSpcWrite

19 Sep 2006

fixed a small bug in BTree when using unsigned data types (thanks to Richard Williams)

11 Oct 2006

code cleaning

30 Jul 2007

Support for multi-dimensional spectra

06 Aug 2007

minor update / code improvement

19 Aug 2009

dual licensed: added BSD license

Contact us at files@mathworks.com