Nmrtype

From NMR Wiki

Jump to: navigation, search

See demonstration!

nmrtype (will be possibly renamed to NMR Factory) is a software project aimed at generation of NMR pulse sequences for all instrument platforms from plain text markup called PulseScript that is easier to enter and read. (based on the pulse sequence drawing extension created for NMR Wiki).

Now nmrtype generates Varian code, does not yet output shaped pulses and does not create parameter files - only .c sequence file.

Please take a look at the table of contents below.

Contents

PulseScript

PulseScript is an abstract pulse sequence specification language that aims at expressing concept of the pulse sequence using minimal and easily readable plain text input.

PulseScript contains no platform-specific information.

nmrType

nmrType is a program that reads PulseScript code, builds an abstract pulse sequence object model (POM), which can then be interpeted in the hardware-specific format.

Source code is hosted here.

Development documentation

Example (15N HSQC from scratch in 1 hour)

Please see below:

PulseScript source code

anchors:      @a[2]      @b       @c[4]           @d       @e[4]                  @f[3]              @g[3]      @h[2]
time:    rlx  @a1 tau    @b  tau  @c2,c4   t12    @d  t12  @e1,e3       tau       @f2      tau       @g3   aq   @h1
rf H:       90@a1=p0  180@b=p1  90@c2=p3       180@d=p5  90@e3=p8     lp@f1=p7 180@f2   lp@f3=p7  acq@g3---------h1
rf N:                 180@b=p2  90@c4=p4                 90@e1=p6              180@f2             cpd@g2----h2=waltz
rf C:                                       180@d
pfg z:       g1@a2         g1@c1 g2@c3                  g2@e2  g3@e4                       g3@g1
 
rfchan H: nucleus=H label=^1H
rfchan N: nucleus=N label=^{15}N
rfchan C: nucleus=C label=^{13}C
pfgchan z: label=grad\ z
 
dim N: sampling=linear(t12:0.5) quad=STATES_TPPI(p2,p4)
 
delay tau: label=\tau
delay t12: label=\frac{t_1}{2} show_at=N
delay aq: hide=true
 
pulse p0: edge=right
pulse p1: phase=y
pulse p2: phase=phi1
pulse p3: phase=y edge=left
pulse p4: phase=phi1 edge=left comp=after
pulse p5: phase=phi3
pulse p6: phase=phi2 edge=right comp=before
pulse p7: phase=xneg
pulse p8: edge=right
 
acq: phase=rph type=fid
 
cpd waltz: label=waltz16 h1=50 h2=50
 
gradient g1: strength=50 label=g_1
gradient g2: strength=50 label=g_2
gradient g3: strength=50 label=g_3
 
phase y: table=1
phase xneg: label=\overline{x} table=2
phase phi1: label=\phi_1 table=0,2
phase phi2: label=\phi_2 table=0,0,2,2
phase phi3: label=\phi_3 table=1,1,1,1,2,2,2,2
phase rph: table=0,2,2,0

Pulse sequence image

Below is the graphical sketch of the pulse sequence, generated by nmrType, from the PulseScript source code above. Image:Hsqc-pulse-sequence-image.png

Source code in Varian format

The source code below was automatically generated by nmrType.

#include <standard.h>
#define MAX(a,b) (a>b)?a:b
 
static int y[1]={1};
static int phi1[2]={0,2};
static int phi3[8]={1,1,1,1,2,2,2,2};
static int phi2[4]={0,0,2,2};
static int xneg[1]={2};
static int rph[4]={0,2,2,0};
 
 
void pulsesequence(){
double  /* declare variables */
 
        /* pulses */
        pwH90 = getval("pwH90"),
        H90pwr = getval("H90pwr"),
 
        pwN90 = getval("pwN90"),
        N90pwr = getval("N90pwr"),
 
        pwC90 = getval("pwC90"),
        C90pwr = getval("C90pwr"),
 
        pwHp7 = getval("pwHp7"),
        Hp7pwr = getval("Hp7pwr"),
 
        /* user set delays */
        rlx_dly = getval("rlx"),
        tau_dly = getval("tau"),
        t12_dly = getval("t12"),
                                                                                                                                     /* hardware-specific delays */
        gstab = getval("gstab"),
 
        /* gradients */
        gt1 = getval("gt1"),
        gzlvl1 = getval("gzlvl1"),
        gt2 = getval("gt2"),
        gzlvl2 = getval("gzlvl2"),
        gt3 = getval("gt3"),
        gzlvl3 = getval("gzlvl3");
 
        /* set phase tables */
        settable(t3, 1, y);
        settable(t4, 2, phi1);
        settable(t5, 8, phi3);
        settable(t6, 4, phi2);
        settable(t8, 1, xneg);
        settable(t9, 4, rph);
 
        if ((int)(getval("phase") + 0.5) == 2){
                tsadd(t4,1,4);
        }
        {
                double d2_init = 0.0;
                int t1_counter;
                if (ix==1){
                        d2_init = d2;
                }
                t1_counter = (int)((d2-d2_init)*sw1 + 0.5);
                if (t1_counter%2){
                        tsadd(t4,2,4);
                        tsadd(t9,2,4);
                }
        }
 
status(A);
        rcvroff();
        obspower(H90pwr);
        decpower(C90pwr);
        dec2power(N90pwr);
 
        delay(rlx_dly-(pwH90+rof1));
        rgpulse(pwH90,zero,rof1,rof1);
        rgradient('z',gzlvl1);
        delay(gt1);
        rgradient('z',0.0);
        delay(gstab);
 
        delay(tau_dly-(rof1+(gt1)/(2)+(gt1)/(2)+gstab)
              -(MAX((pwH90*2)/(2)+rof1,(pwN90*2)/(2)+rof1)));
 
        sim3pulse(pwH90*2,0.0,pwN90*2,t3,zero,t4,rof1,rof1);
 
        delay(tau_dly-(MAX((pwH90*2)/(2)+rof1,(pwN90*2)/(2)+rof1))
               -((gt1)/(2)+(gt1)/(2)+gstab)-(rof1));
 
        rgradient('z',gzlvl1);
        delay(gt1);
        rgradient('z',0.0);
        delay(gstab);
        rgpulse(pwH90,t3,rof1,rof1);
        rgradient('z',gzlvl2);
        delay(gt2);
        rgradient('z',0.0);
        delay(gstab);
        dec2rgpulse(pwN90,t4,rof1,rof1);
        delay(t12_dly+d2/2-(pwN90+MAX(rof1,(pwN90*2)/(3.14159265)))
               -(MAX((pwH90*2)/(2)+rof1,(pwC90*2)/(2)+rof1)));
 
        simpulse(pwH90*2,pwC90*2,t5,zero,rof1,rof1);
        delay(t12_dly+d2/2-(MAX((pwH90*2)/(2)+rof1,(pwC90*2)/(2)+rof1))
              -(pwN90+MAX(rof1,(pwN90*2)/(3.14159265))));
 
        dec2rgpulse(pwN90,t6,rof1,rof1);
        rgradient('z',gzlvl2);
        delay(gt2);
        rgradient('z',0.0);
        delay(gstab);
        rgpulse(pwH90,zero,rof1,rof1);
        rgradient('z',gzlvl3);
        delay(gt3);
        rgradient('z',0.0);
        delay(gstab);
        delay(tau_dly-(rof1+(gt3)/(2)+(gt3)/(2)+gstab)
              -((pwHp7)/(2)+rof1+(pwHp7)/(2)+rof1)
              -(MAX((pwH90*2)/(2)+rof1,(pwN90*2)/(2)+rof1)));
 
        obspower(Hp7pwr);
        rgpulse(pwHp7,t8,rof1,rof1);
        obspower(H90pwr);
        sim3pulse(pwH90*2,0.0,pwN90*2,zero,zero,zero,rof1,rof1);
        obspower(Hp7pwr);
        rgpulse(pwHp7,t8,rof1,rof1);
        obspower(H90pwr);
 
        delay(tau_dly-(MAX((pwH90*2)/(2)+rof1,
                           (pwN90*2)/(2)+rof1)+(pwHp7)/(2)+rof1
                            +(pwHp7)/(2)+rof1)-((gt3)/(2)
                            +(gt3)/(2)+gstab));
 
        rgradient('z',gzlvl3);
        delay(gt3);
        rgradient('z',0.0);
        delay(gstab);
dec2power(dpwr2); /* limitation: dpwr2 assumed */
status(B);
        rcvron();
        setreceiver(t9);
}

Processed HSQC spectrum

Picture was obtained one hour after starting to type PulseScript code.

Sample - ~1 mM uniformly 13C,15N labeled human ubiquitin.

Personal tools