Subject: Re: binary format
From: yohmatsuki
Date: Jun 12, 2008

Previous: 511

Hi Tom,

Nice function. Great help. It worked out!
Thank you very much.

-Yoh

--- In nmr_sparky@yahoogroups.com , Tom Goddard goddard@... wrote:

Hi Yoh,

The easy way to go is use the matrix2ucsf program that comes with
Sparky. Then you just need a raw matrix of binary floating point
values. Heres an example command:

matrix2ucsf -n1 1024 -n2 512 -f1 60.799 -f2 599.929 -sw1 5000 -sw2
10000 -o1 77.8 -o2 -3.55 -a1 15N -a2 1H -o hsqc.ucsf hsqc.matrix

setting number of points, transmitter frequencies, sweepwidths, ppm
origins, and nucleus types. This command is not in the Sparky manual
but if you run it with no arguments it explains the syntax. See below.

I suggest you not try to write the UCSF spectrum file format.
Besides
the complicated header, the data layout is in blocks and is hard to get
right. The strange header values you see in the UCSF data is probably
because the file numbers are saved in big-endian byte order and your
machine is probably little-endian. So the bytes would need to be
swapped.

Tom



$ ~/Desktop/Sparky-3.113.app/Contents/Resources/bin/matrix2ucsf
Usage: matrix2ucsf -n1 # -n2 # [-n3 #] [-n4 #]
[-f1 #] [-f2 #] [-f3 #] [-f4 #]
[-sw1 #] [-sw2 #] [-sw3 #] [-sw4 #]
[-o1 #] [-o2 #] [-o3 #] [-o4 #]
[-a1 name] [-a2 name] [-a3 name] [-a4 name]
-o output-file input-file

Creates a UCSF format NMR file from a matrix of floating point values.
On reading through the matrix file the w1 index should vary slowest.
The floating point numbers must have big-endian byte order.
Header parameters are supplied on the command line.

-nN size
specifies matrix size for axis N
-fN freq
spectrometer frequency in Mhz for axis N
-swN sweepwidth
sweep width in Hz for axis N
-oN origin
position of matrix index 0 in ppm for axis N
-aN axis-nucleus-name
nucleus name (eg 1H, 15N, 13C) for axis N
$