i like this post (click again to cancel)
1
i dont like this post (click again to cancel) remove favorite mark from this question (click again to restore mark)

Hello people,

For my internship I am attempting to fully automate monomer composition analysis on Bruker TOPSPIN 2.0 using visual basic and macro's. It's almost fully functional but I've come across the following problem:

I want to use the integral data of a spectrum in calculations (i.e. export them to an excel template) but so far I've found no way of exporting integral data without using the mouse (I can make visual basic simulate mouse clicks, but it's not a method I like using since it makes the program very prone to failure or outdating).

The "exportfile" command exports data based on what tab of the dataset you are currently viewing, but I haven't found any command to open the Integrals tab.

Does anyone know how I could solve this? Thank you in advance.

asked Nov 22 '10 at 02:38

Nathanael91's gravatar image

Nathanael91
23

updated Nov 23 '10 at 12:00

Evgeny%20Fadeev's gravatar image

Evgeny Fadeev
5471

I think Mo has a good point. NMRPipe is probably easier to automate, since it was written for that purpose anyway. - Evgeny Fadeev (Nov 23 '10 at 09:52)


6 Answers:
i like this answer (click again to cancel)
2
i dont like this answer (click again to cancel) the author of the question has selected this answer as correct

It pains me to see you have to resort to mouse clicks. If that suits you, fine...otherwise read on. The following code is maybe more what you need (you will end up with a csv file called "integrals.csv" in your proc directory:

int i, iIndex;
char path[200];
char h1[100],h2[100],h3[100],h4[100],h5[100];
float fFrom, fTo, fIntegral;
FILE *fin,*fout;

GETCURDATA
//create integral file
LI

//now read its contents 
(void)sprintf(path,"%s/data/%s/nmr/%s/%d/pdata/%d/integrals.txt",disk,user,name,expno,procno);
fin=fopen(path,"r");

if (fin==NULL)
  {
  Proc_err(DEF_ERR_OPT,"integral not found");
  STOP
  }

(void)sprintf(path,"%s/data/%s/nmr/%s/%d/pdata/%d/integrals.csv",disk,user,name,expno,procno);
fout=fopen(path,"w+");

//Get the 5 file header lines (ignoring them in this case)
fgets(h1,120,fin);
fgets(h2,120,fin);
fgets(h3,120,fin);
fgets(h4,120,fin);
fgets(h5,120,fin);

// now read the integrals, reformat them into csv format and write them out to integrals.csv
for (i=0;i<=100;i++)
{
  if(fscanf(fin,"%d %f %f %f",&iIndex,&fFrom,&fTo,&fIntegral)<3)
     {
        break;
     }
  fprintf(fout,"%d,%2.3f,%2.3f,%4.4f\n",iIndex,fFrom,fTo,fIntegral);
}
fclose(fin);
fclose(fout);
QUIT
link

answered Nov 25 '10 at 07:34

John%20Hollerton's gravatar image

John Hollerton
96

i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

If you are using NMRPipe you could export the data in ascii

Have a look at: "pipe2txt.tcl -help" pipe2txt.tcl send the text to the screen.

You use the usual UNIX output redirection, such as: pipe2txt.tcl spectra.DAT > spectra.TXT

Regards, Mo

link

answered Nov 23 '10 at 09:19

Mo's gravatar image

Mo
11

i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

Hi there, You can also use Mnova to create an script in order to export your integrals as ASCII, or just follow the menu 'File/Save As/Mestrenova Integrals (*.txt)'.

Please let me know if you need further information about it.

Regards, Pablo.

link

answered Nov 24 '10 at 03:42

Mestrelab's gravatar image

Mestrelab
56

updated Nov 24 '10 at 03:43

i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

There is no real problem getting the integrals into a file. The following AU program will generate a file called "integrals.txt" in the processed directory:

GETCURDATA
LI
QUIT

No mouse needed!

Hope this helps,

John

link

answered Nov 25 '10 at 02:48

John%20Hollerton's gravatar image

John Hollerton
96

i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

Thanks everyone for your help so far:) Sadly as far as I know I can't import ascii files into excel, but I've found a workaround

I basicly used a simulate mouse click command and made it maximize the window and open the data sheet before the click, preventing any problems from occuring. Most programmers will shun this method, but it gets the job done.

link

answered Nov 25 '10 at 04:41

Nathanael91's gravatar image

Nathanael91
23

i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

It looks like that code does exactly what I want it to do (so exactly what my program does now (up to the file name and path:P), but without additional input from visual basic)

I'll try it out this afternoon, thanks a lot.

PS: Is there also a way to export the spectrum to a specified path? right now it opens the export window and visual basic fills in the path name, but again, that's not optimal, I'd rather not have visual basic do anything with the nmr software after it's transfered the input variables

link

answered Nov 25 '10 at 23:24

Nathanael91's gravatar image

Nathanael91
23

in what format would you like to export the spectrum? - Clemens Anklin (Nov 30 '10 at 09:12)

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a good answer, for discussions, please use comments and please do remember to vote (login to vote)
toggle preview

powered by CNPROG