Hi Guys, I noticed that the Varian file format has a bit in the status code (a short value in the 32 byte header) which indicates wether spectra data are Float or Integer . However, I'm concerned this may not always be "set" .... i.e. I'm concerned that in some instances, this bit is ignored. I'm wondering if there is any more reliable way to guess wether the numerical content in a spectrum is floating point or integer....... Please let me know ! Thanks! asked Mar 03 '10 at 12:40 j |
Yes, The code is used.... but there are 16 bits in it. The real question is, which ones are commonly used ? It is known that Varian does not write values for some of their binary meta data flags, i.e. they just write zeros, and assume that you will use the procpar for all, or most, meta data. 1) So is the bit which signifies INT vs FLOAT always used when the varian folks write out spectra ? and 2) Is there a way to find out (from the procpar) wether values are INT or FLOAT ? and 3) What is more common in Varian spectra ? INT or FLOAT ? answered Mar 04 '10 at 09:21 j Hello J, just want to tell you that on this forum is slightly different from the others you might be used to. Here "discussion thread" mode is not supported by design. You can always just edit your original question and clearly mark significant edits. - Evgeny Fadeev (Mar 04 '10 at 10:35) Thanks for the question, btw. Brings up some interesting issues. - Evgeny Fadeev (Mar 04 '10 at 10:36) also, comments may be used for clarifications. Comments everywhere are accessible after you have 50 points, but are always accessible on your own questions and answers. - Evgeny Fadeev (Mar 04 '10 at 10:38) this "reputation system" is another thing that helps keep this site in the better shape. You'll quickly surpass the 50 point barrier, so it's not really a problem. - Evgeny Fadeev (Mar 04 '10 at 10:40) 32 bit int is by far the most common. Do you have the Varian user programming manual? The status word is well described in there. I think the bits specifying int/short/float are quite relieble. - Kirk Marat (Mar 04 '10 at 12:00) |
That value is used, and is most often used to specify 16 bit ints instead of 32 bit ints. I've never actually encountered a 32 bit float data set, although SpinWorks should handle it. I think I will try generating a floating point data set to see if it works :-) Since digitizers are integer devices, there isn't much point in storing the fids as floats. Except: For a very large number of scans where you may overflow the 32 bit word; Real time digital signal processing may be done in floating point and it may make sense to save the result in floating point. All processing of the data should be done in floating point (typically 64 bit). To decode the status word:
You should probably check for float first because Varian states that the 16/32 bit bit (S32) is ignored if the float bit is set. In a modern language (C#, probably Java and others) you could try something like:
answered Mar 04 '10 at 07:48 Kirk Marat Hi Kirk, thanks for the insight. I've tried to format to code snippets. The third one seems to be particularly stubborn. I'll take a look into that. - Evgeny Fadeev (Mar 04 '10 at 10:31) I was just thinking. All possible 32 bit combinations are valid integers. Many (most?) of those possible combinations are also valid 32 bit floating point numbers, so just trying to use a cast or conversion as a test is not likely to be very reliable. - Kirk Marat (Mar 04 '10 at 11:19) The maximum value for an unsigned 32 bit int is 4,294,967,296 which is 11111111 11111111 11111111 11111111. In a 32 bit float, some of those bits are used for the exponent (is that what you ment by decimal?), so for many integers it would not be 0. - Kirk Marat (Mar 04 '10 at 11:50) Floating point and integers are quite different formats. A float is not simply an int with an extra exponent added on. They use some of the 32bit for the exponent, giving fewer bits for the significand (mantissa). - Kirk Marat (Mar 04 '10 at 11:56) yes, but I thought that the observation of decimal/fractional part (anything smaller than 1) being or not being always zero could be used as a hint that data is integer. of course this is subject to testing on the actual data. - Evgeny Fadeev (Mar 04 '10 at 12:27) |
Hello, I didn't know that Varian has that numeric mode bit, thanks for bringing it up. Floating point option offers greater "dynamic range" of storable numbers. edit: Kirk is right - there is probably no way to guess whether a one given number is float or integer, since in the end both are represented by a bunch of bits (here is a Wikipedia page about Floating Point representation), however there may be a way to analyze a pattern within a set of numbers casted as integers and casted as floats. It's kind of like guessing in which language some text is written by looking at a sample. It does seem to be more complicated than I thought, anyway - below is the answer I've given originally: With
Take a look here for more details. So you could run through all the numbers with one of the methods and determine the format of entire set. answered Mar 03 '10 at 13:31 Evgeny Fadeev what I'm thinking is that hopefully with the instrument data you don't have to be guessing if all the metadata is interpreted correctly. - Evgeny Fadeev (Mar 04 '10 at 12:41) As far as I know, the bits in status word in block header thet specify whether the data are float, Int32 or Int16 are always correct. You are right, you should never have to guess. - Kirk Marat (Mar 08 '10 at 12:53) |