Thursday, February 20, 2014

Getting (x,y) ASCII Data from TOPSPIN

TOPSPIN is able to export graphical data in a number of formats for import into word processing, presentation or graphics programs.  It is also able to export a spectrum into the ASCII JCAMP format for those programs able to import such data. Often, however, one would like to have simple ASCII data as (x,y) coordinates representing an NMR spectrum for use in other computer programs.  There are two ways to do this.  The simplest way is to process the raw data as usual, producing the real NMR spectrum in the "1r" file then run the au program "convbin2asc" by simply entering "convbin2asc" on the TOPSPIN command line.  An ASCII text file like the one shown below will be created in the same directory as the "1r" file with the name "ascii-spec.txt".

This file contains a one-line header followed by four columns of comma delimited text.  The first through fourth columns contain the point number, the intensity (y values), the frequency in Hz (x values) and the chemical shift in ppm (x values), respectively. These data are very easily imported into other programs.

As described in a previous post, another way to obtain a simple ASCII file is to process the raw data as usual and display the region of the spectrum for which you would like ASCII data.  Right-click within the spectrum window and select "Save Display Region To..." from the pop-up window.  Another window will open from which you should select "text file for use with other programs" and then click "OK".  A third window will open where you can input the name of the file you wish to create, the directory in which you would like to have it stored and whether or not you would like the imaginary data stored as well (usually only the real data are desired).  You must then click "OK".

A shorter way to accomplish this is to simply enter the command "totxt" in the TOPSPIN command line.  This will take you directly to the bottom window of the figure above.  After clicking "OK" a text file like the one shown below is created with the name you have chosen in the directory you have chosen.

The file contains a header with information including the number of data points, the chemical shift of the left-most point and the chemical shift of the right-most point.  The main body of the file consists of a single column of intensities (y values) which are easily imported into other programs.  The x values must be generated separately using the information in the header.


sankeerth said...

Very useful. Thank you.

Jobst said...

How can I account for different intensity scaling factors when exporting different spectra with convbin2asc (which I want to overlay subsequently)? Something like "efp nc_proc=0" doesn't seem to do the job.

Thanks for this nice blogg.

Glenn Facey said...


If you want to scale your data after it has been converted to ASCII format, you will have to do so using whatever software you are using to view your data. The way this is done will depend on what software you are using.


Anonymous said...

First thank you for this blog. I found it quite helpfull many times.
Acually I have a strange problem concerning ASCII files of topspin.Do you know how to seperate the data again(tabulator, etc)? The "normal" import routines in several programs results in such an artefact:

The resulting imported spectrum is full of spikes. The overall summ of data points are correct. I
Best regards,

Glenn Facey said...


Thank you for the comment. I am unable to understand the specific problem you are having based on the information you provided.

How exactly are you obtaining the ascii data from TOPSPIN?

What version of TOPSPIN are you using?

What program are you using to import the ascii data?

Can you import the data in EXCEL?


Zatie said...


Anyone can teach me on how to generate X value separately? I am not very clear with this sentence "The x values must be generated separately using the information in the header".Text file generated using 'totxt'. Can we use EXCEL to generate it, if yes, please assist me. Very much thank you

Zatie said...


my email is
please assist me on how to generate x value separately.
Thank you soooo much

Glenn Facey said...


You can produce the X column from the values of SIZE, LEFT and RIGHT in the header of the file.

1. Generate a column of "SIZE" numbers (0 1 2 3 .... (SIZE))
2. Multiply this column by ((LEFT-RIGHT)/SIZE).
3. Add "LEFT" this column.


nicky said...

Hi Glenn,
Thanks for hosting this excellent forum. It has helped me enormously through the years! I am wondering about the magnitudes of the y-values that are exported (I used convbin2asc). The relative intensities indicated in topspin are on the order of 0-20. The values that are exported are on the order of 10^8! And they seem to be scaled unevenly. My spectra are similar in topspin, but once exported, one is much bigger than the other. Any idea of what happens in the conversion that could explain this?

Glenn Facey said...

Thank you for the kind words and question. As far as I know, the Y data are the absolute intensities. How are you comparing the intensity of your data within TOPSPIN? If you compare your spectra within TOPSPIN using a multiple display with no individual scaling, are the Y values similar?


bubkes said...

Hi Glenn!
Thanks for responding so quickly! The ratios of the intensities of the two spectra that I'm looking at are different in the (unscaled) relative vs. absolute values. In fact, the ratio is inverted-- in one of them A is bigger (greater intensity), and in the other, B is bigger! Very puzzling... Any thoughts?


Glenn Facey said...

Hi Nicky,
Perhaps the y scale of the ASCII data is determined by the scale of the spectrum being displayed at the time the ASCII file is created with the convbin2asc command. Try creating a new ascii file for each spectrum where each spectrum is on the same vertical scale before you issue the convbin2asc command.


Unknown said...

Hi there!

First let me say that I love this blog and have a few of your posts saved for reference!

I'm running TopSpin 3.1 and I've tried performing this command on some of my 1d 1H NMR data sets after they have been processed. Unfortunately, the command stops before generating the file with an error stating that it failed with exit(1) - specs malformed after 13 characters.

I was wondering if you've ever encountered this error before and if it might simply be something I'm doing incorrectly.

If not, that's completely fine as well! I was simply curious.

With best wishes,


Glenn Facey said...

Hi Lisa,

I have not seen the error you described and do not know why you are encountering it. Are you using any special characters in your file names ( $, %, ?, *, &, /, |, \ ...etc)?


Unknown said...

Hi Glenn!

Thanks for your quick response. I'm not using any special characters, just hyphens and underscores)(ex. "MB-II-71_NativeCmpd" as a file name).

I have not yet tried to perform the command on the computer that controls the spectrometer. I use a different computer that operates as a data processor.

Since posing the question, I've had success getting the x/y data through the 'Save Display Regions To' option and generating the x-axis points. So fixing the problem isn't critical, I was merely curious if you'd run into this before. :)

Thanks again for the quick reply! I greatly appreciate it!

Unknown said...

Hi Glenn,

I need the FID file in ASCII format. A 'time' column, then a real column and then an imaginary column. For both 1D and 2D.

Is there a way to convert FID files to text files, just like the processed spectra?

Glenn Facey said...


You can use the "convfid2asc" au program to give you an ascii file for the FID. A file called "ascii-fid.txt is created in the expno folder of your dataset. It is formatted in terms of point number and intensity. You will have to convert your point number column to time based on your knowledge of the dwell time. You can also use the "tojdx" command and fill out the options you need in the pop up window to give you the fid data. The jcampdx files have very large headers containing all of the parameters. The data is at the end of the file.


Unknown said...

Hi Glenn,

I tried the convfid2asc. But gives only real part. I need both real and imaginary parts. I dont care about time. I shall make it.

Glenn Facey said...


Try the "tojdx" command.


Unknown said...

Dear Glenn

Your Input on generating ASCII files from NMR raw data is very helpful. Thank you for that. I am just wondering if it's possible to generate ASCII files simultaneously for more than one NMR measurement. I have more than 300 measurements for which I want to generate the ASCII files and it is a bit time consuming to do so.

Do you have any idea?

Thank you very much

Glenn Facey said...

Such batch conversions would be very useful. The only way I can imagine doing this is to write an 'au' program or macro incorporating the 'totxt' command. I have not done this but you may get some help from the Bruker support people. They may have written such a program or macro.


Jack Bramham said...

In response to Jobst's and Nicole's questions about spectra scaling (and NC_proc) when using convbin2asc (and because I ran into the same problems today):

The exported intensities generated by convbin2asc are values generated with the Topspin NC_proc scaling applied, which can vary between two data sets if the max intensities are >2x different. (NC_proc is stored in/pdata/1/procs if anyone's automating this processing). Setting this value during efp etc does work, but to reset the scaling and get the absolute values:
If NC_proc = positive, then multiply the scaled intensities by 2^(NC_proc)
If NC_proc = negative, then divide the scaled intensities by 2^(-NC_proc) (so the power is positive)

Hope that helps anyone and thanks for the really useful blog Glenn!

Glenn Facey said...

Thank you for the very useful information Jack.

Jack Bramham said...

I should have said:
Setting this value during efp etc does NOT work

Luiz Silvino said...

Dear Glenn,
I found this blog very helpfull. Could you please tell me how to get (x,y) ASCII data from Topspin 3.6.1 of the 1D projection ("decoupled" 1D spectrum after shearing and symmetrization) of a JRES spectrum (JRESQF Bruker pulse sequence)? Thank you in advance.

Glenn Facey said...

I think all you have to do is store the 1D projection from the processed 2D data in a new procno and use the convbin2asc command.

Waqas Rasheed said...

You can also use on Excel the following syntax to generate the y-axis:


=SEQUENCE (rows, [columns], [start], [step])


rows - Number of rows to return. Same as SIZE
columns - Number of columns to return. Use 1 for this as a value.
start - Starting value (defaults to 1). Same as LEFT
step - Increment between each value (defaults to 1). The formula to use for this value is going to be "(LEFT-RIGHT)/SIZE" for the value in step


On the second column of your Excel, paste the y-axis values from the .txt file.

Formula to put in the first row and first column of Excel = SEQUENCE(29700,1,9.03125922135478,((9.03125922135478-0.0439121193907039)/29700))

This should generate the x-axis.

You can use that now for your plotting pleasure.

Matteo said...

Thank you very much for this SO useful resource!!!

I realized a small Python script to simply things, and provided the acknowledgement.