I am a German chemistry Bachelor student (beginning my Master studies in October) and as a spare-time hobby I would like to write an NMR processing program. I would like to release it as free open source software (GPL) written in C++ with a Qt frontend, so that it is platform independent.
As a starting point for writing the libraries to read and transform the vendor data (currently only Bruker) I used the SpinWorks libraries released by Dr Marat (many thanks to him):
I ported and modified this code to C++/Qt. Reading and transforming Bruker data works so far, but unfortunately the produced spectra suffer from severe distortions (extreme "noise"). I uploaded a graph of the data output that I plotted using Origin:
Here is a screenshot of the spectrum processed with SpinWorks (how it should look like):
I've been looking through the code for days now but I just can't find my mistake. I also uploaded the code:
All files for compiling the program are included. It runs on the console and is not very user friendly because I first wanted to "prove" that it can produce a useful spectrum before I go on coding any further. The path to the acqus and fid files are hard coded in the main.cpp, but I commented the code as best as I could so it should be easy to make it run. The sample data I used for the above pictures are also included (acqus and fid).
I would be very happy if someone could tell what my mistake is. Maybe the experts already see it by just looking at the spectrum. If you have any question concerning the code or the compilation, feel free to ask.
Since I really don't know how to go on, I'm desperate for any help.
Thank you very much in advance.
Just guessing here - since data looks largely like noise - you might be reading starting incorrect byte or your reading of numbers may be shifted with respect to the data point boundaries or you might have incorrect byte order (little-endian vs. big-endian).
Maybe you can take a step back and look at the FID after reading it from the source and compare it to what you see in spinworks or other software.
edit maybe you can try creating a synthetic fid where all points have the same non-zero value. Then read the data and see what numbers you get. That may give you some hints. You can also compare the real data offset as you read with the expected offset - based on what you know from the data format.
by offset I mean "byte distance" from the beginning of the file up to the point from where you read. basically that you are getting wrong numbers means that either you are reading them from wrong locations within file, or you have reversed byte order or you might be mis-interpreting format of storage of the numerical data (float/double/long, etc.) - I have not worked with programming like that in a long time though. Of course you might have more than one issue at once.
Take a look at previous posts tagged "
I think that Evgeny is right. Bruker FIDs are time shifted, and if you do not proccess them properly you will get spectra like that as you can see in the following link:
I have the impression that you already knew this, because in your source code you are phasing the spectrum taking this into account, but I have not seen the bit to remove the initial points and zero fill the data. This is the simplest procedure to deal with the problem and it is described here:
Many thanks to all answers given. I finally could solve the problem. Something went wrong with reading the binary fid data into the fid array. I only had to change the bruker_read.cpp, the new version can be found here:
To see what is changed, begin reading at line 176. Actually I now just write the inputstream into the 32 bit signed integer variables of the fid array using the ">>" operator.
Now the spectrum looks correct:
Despite the fact that it works now, it is strange nonetheless. I could not find an error in the previous version. It should have worked.
Eventually I will have to find the problem, since the current method will be difficult to use for Varian data because now I don't have access to each byte of the inputstream any more. So selective byte-reversal (as needed for the Varian fid headers) becomes somewhat difficult, but I will have a look at this later.
A (hopefully) final question: Does anybody know why it is necessary to convert the Fourier transformed data (which are floating point numbers) to integer values before doing the post processing stuff? At least that is the way it is done in the libraries by Dr. Marat (using a scaling factor to better fit the whole integer range). I implemented this conversion in my code as well because he is the expert, but I still wonder why the floating point numbers cannot be used for further processing.
answered Aug 04 '10 at 00:16