AU program qcpmg-split for splitting QCPMG echo train in topSpin2.1 operating system

Home and Applets > Pulse Program > Topspin 2.1, Avance III > 1D-QCPMG > AU Program qcpmg-split for TopSpin2.1

Code for Avance III spectrometers with topSpin2.1 operating system

Carr-Purcell-Meiboom-Gill echo train

AU program for splitting echo train acquired with qcpmg.fau pulse program:

/*******************************************************************
qcpmg-split (topspin2.1)

AU program for splitting echo train acquired with the pulse program 
qcpmg.fau into a series of 1D files containing each an echo
********************************************************************/

int size, sizeout, si2, tdout, td2, sizeofint, parmod, zeroth;
int pivot, ireal, irealecho, startExpno;
char binfile[255], boutfile[255], pulprog[255];
int *in1, *in2;
int order_a_BIT, first, echopoints, echos, l22, dead;
float del3, del6, pul3, pul4, dwell;
double swh;
char s1[255];

GETCURDATA;

startExpno = expno;

/* ---------------------------------------------*/
/* make sure program works on proper data set */

FETCHPARS("PARMODE",&parmod);
if (parmod != 0) STOPMSG(" Program only works on 1D data");
FETCHPARS("PULPROG",pulprog);
//if (strcmp(pulprog,"qcpmg.fau")!=0) { 
//   Proc_err(0,"Wrong AU program for %s pulse program",pulprog);
//   return(AUERR);
//}

/* ---------------------------------------------*/
/* make sure that pivot point can be entered */

(void) sprintf(s1,"%s %s","au_qcpmg AU program","- Note \n\
- If you don't know the pivot point yet,\n\
  press Cancel and check with\n\
  'calibrate'\n\
- otherwise press OK and continue");
FETCHPARS("FL1",&pivot);
if (pivot>80) {
   AUERR=Proc_err(ERROPT_AK_CAN|ERROPT_BEEP_DEF,"%s",s1);
   if (AUERR == ERR_CANCEL) ABORT
}

/* ---------------------------------------------*/
/* get relevant acquisition parameters */

FETCHPAR("TD",&td2);
FETCHPARS("SI",&si2);
FETCHPARS("SW_h",&swh);
FETCHPARS("D 6",&del6);
FETCHPARS("D 3",&del3);
FETCHPARS("P 3",&pul3);
FETCHPARS("P 4",&pul4);
FETCHPARS("L 22",&l22);
FETCHPARS("DW",&dwell);
FETCHPARS("BYTORDA",&order_a_BIT);

/* ---------------------------------------------*/
/* check for starting point */

if (pivot>80) pivot=(int)((10/dwell));
if (strlen(cmd) == 0) {
   GETINT("Enter pivot point : ",pivot);
}
else {
   if (1 != sscanf(cmd, "%d", &pivot)){
      STOPMSG("illegal input");
   }
}

/* ---------------------------------------------*/
/* calculate required loop parameters */

zeroth=pivot;
zeroth=(zeroth/2)*2;
first=(int)((del6*1000000.0+del3*2000000.0+pul4)/dwell+0.5)+zeroth;
first=(first/2)*2;
echopoints=(int)(del6*2000000.0/dwell+0.5);
echopoints=(echopoints/2)*2;
dead=(int)((del3*2000000.0+pul4)/dwell+0.5)+2;
dead=(dead/2)*2;
echos=l22;
tdout=td2;       /* changed */
sizeout=tdout*sizeof(int);

/* ---------------------------------------------*/
/* open file and allocate array  */

(void)sprintf(binfile,"%s/data/%s/nmr/%s/%d/fid",disk,user,name,expno);

/* ------With TopSpin 3.5, replace by-----------*/
/* (void)sprintf(binfile,"%s/%s/%s/%d/fid",disk,user,name,expno);*/
/* ---------------------------------------------*/

sizeofint=sizeof(int);
size=td2*sizeofint;
in1=calloc(td2,sizeof(int));
in2=calloc(td2,sizeof(int));

if ( (ireal=open(binfile, O_RDWR)) == -1) {
   Perror(DEF_ERR_OPT,binfile);
   ABORT;
}
if ( read(ireal,in1,size) == -1 ) {
   Perror(DEF_ERR_OPT,binfile);
   ABORT;
}

/* ---------------------------------------------*/
/* create final output array   */

i2 = startExpno + 1;

TIMES(echos);
   WRA(i2)                 /* no spectrum saved, FID only */
   i2++;
END;

i1 = first;
i3 = startExpno + 1;

TIMES(echos);

   (void)sprintf(boutfile,"%s/data/%s/nmr/%s/%d/fid",disk,user,name,i3);

/* ------With TopSpin 3.5, replace by-----------*/
/* (void)sprintf(boutfile,"%s/%s/%s/%d/fid",disk,user,name,i3);*/
/* ---------------------------------------------*/

   if ( (irealecho=open(boutfile, O_RDWR)) == -1) {
      Perror(DEF_ERR_OPT,boutfile);
      ABORT;
   }

   i2=0;
   TIMES2(td2);
      in2[i2]=0;           /* clear data */
      i2++;
   END;

   i2=0;
   TIMES2(echopoints);
      in2[i2]=in1[i1];     /* copy an FID or an echo*/
      i2++;
      i1++;
   END;

   if ( lseek(irealecho, 0, SEEK_SET) == -1 ) {
      Perror(DEF_ERR_OPT,boutfile);
      ABORT;
   }
   if ( write(irealecho,in2,sizeout) == -1 ) {
      Perror(DEF_ERR_OPT,boutfile);
      ABORT;
   }

   (void)close(irealecho);

   i1+=dead-2;    /* disregard dead */
   i3++;          /* next file */
END;

/* ---------------------------------------------*/
/* correct relevant acquisition parameters */

STOREPAR("TD",tdout);
STOREPAR("TDeff",echopoints);
STOREPAR("SI",tdout*2);

(void)close(ireal);
free(in2);
free(in1);

(void)sprintf(text,"QCPMG split transformation done");
Show_status(text);
QUIT
  

Solid-state NMR bibliography for:

Aluminum-27
Antimony-121/123
Arsenic-75
Barium-135/137
Beryllium-9
Bismuth-209
Boron-11
Bromine-79/81
Calcium-43
Cesium-133
Chlorine-35/37
Chromium-53
Cobalt-59
Copper-63/65
Deuterium-2
Gallium-69/71
Germanium-73
Gold-197
Hafnium-177/179
Indium-113/115
Iodine-127
Iridium-191/193
Krypton-83
Lanthanum-139
Lithium-7
Magnesium-25
Manganese-55
Mercury-201
Molybdenum-95/97
Neon-21
Nickel-61
Niobium-93
Nitrogen-14
Osmium-189
Oxygen-17
Palladium-105
Potassium-39/41
Rhenium-185/187
Rubidium-85/87
Ruthenium-99/101
Scandium-45
Sodium-23
Strontium-87
Sulfur-33
Tantalum-181
Titanium-47/49
Vanadium-51
Xenon-131
Zinc-67
Zirconium-91
[Contact me] - Last updated February 24, 2020
Copyright © 2002-2024 pascal-man.com. All rights reserved.