Example #1
0
void setphases()
{
  mod2(ct, v1);  dbl(v1,v1);                  /* 0202 */
  hlv(ct,v2);    mod2(v2,v2); dbl(v2,v2);     /* 0022 */
  add(v1,v2,v3); mod4(v3,oph);                /* 0220 */
  add(one,oph,oph);
}
Example #2
0
pulsesequence()
{
   double	pp;
		

   pp = getval("pp");
   
/* calculate phases */
  mod2(ct,v1);  /* 0101 */
  dbl(v1,v1);   /* 0202 */
  hlv(ct,v2);   /* 0011 2233 */
  mod2(v2,v2);  /* 0011 0011 */
  add(v1,v2,v1);  /* 0213 0213*/
  assign(v1,oph); 


  

   status(A);
      hsdelay(d1);
   status(B);
      pulse(pw, v1);
      delay(d2);
         if (declvlonoff)
            declvlon();         /* sets power to pplvl */
         else
            decpower(pplvl);
      simpulse(p1, pp, v1, v1, rof1, rof1);
         if (declvlonoff)
            declvloff();
         else
            decpower(dpwr);
      delay(d2);
   status(C);
}
Example #3
0
static inline void printing(int total_size, int node) {
    int permission = 0, llimit, ulimit, tab;

    if (node == 0) {
        permission = 1;
    } else if (mod2(node) == 0) {
        permission = (tree[div2(node - 1)] == 1) ? 1 : 0;
    } else {
        permission = (tree[div2(node)] == 1) ? 1 : 0;
    }

    if (permission) {
        llimit = ulimit = tab = 0;

        while (!(llimit <= node && node <= ulimit)) {
            tab++;
            putchar('\t');
            llimit = ulimit + 1;
            ulimit = 2 * ulimit + 2;
        }

        printf(" %d ", total_size / power_2(tab));

        if (1 < tree[node]) {
            printf("---> Allocated %d\n", tree[node]);
        } else if (tree[node] == 1) {
            printf("---> Divided\n");
        } else {
            printf("---> Free\n");
        }

        printing(total_size, 2 * node + 1);
        printing(total_size, 2 * node + 2);
    }
}
Example #4
0
pulsesequence()
{   
  double cycles,
	 bigtau = getval("bigtau"),
	 tau = getval("tau"),
  	  satdly = getval("satdly");
  char  satmode[MAXSTR],
        sspul[MAXSTR];

  getstr("satmode",satmode);
  getstr("sspul",sspul);

  settable(t1,4,phs1);
  settable(t2,8,phs2);
  settable(t3,4,phs3);
  getelem(t1,ct,v1);
  getelem(t2,ct,v2);
  getelem(t3,ct,v4);
  assign(v1,oph);

/* calculate 'big tau' values */
   cycles = bigtau/(2.0*tau);
   cycles = (double)((int)((cycles/2.0) + 0.5)) * 2.0;
   initval(cycles,v3);


/* equilibration period */
   status(A);

   delay(5.0e-5);
   if (sspul[0] == 'y')
        steadystate();

   if (satmode[0] == 'y')
     {
        if ((d1-satdly) > 0.02)
                delay(d1-satdly);
        else
                delay(0.02);
        satpulse(satdly,v2,rof1,rof1);
     }
   else
        delay(d1);

/* calculate exact delay and phases */
   mod2(oph,v5);  
   incr(v5); 

/* spin-echo loop */
   status(B);
   rgpulse(pw,v1,rof1,0.0);
   starthardloop(v3);
      delay(tau - p1/2.0 - rof2);
      rgpulse(p1,v5,rof2,rof2); 
      delay(tau - p1/2.0 - rof2);
   endhardloop();

/* observation period */
   status(C);
} 
Example #5
0
int main(int argc, char const *argv[])
{
    printf("\t%d\n", mod1());
    printf("\t%d\n", mod2());
    printf("\t%d\n", mod3());
    return 0;
}
Example #6
0
int main ()
{
  if (div1 (-(1 << 7)) != 1 << 7)
    abort ();
  if (div2 (-(1 << 15)) != 1 << 15)
    abort ();
  if (div3 (-(1 << 7), -1) != 1 << 7)
    abort ();
  if (div4 (-(1 << 15), -1) != 1 << 15)
    abort ();
  if (mod1 (-(1 << 7)) != 0)
    abort ();
  if (mod2 (-(1 << 15)) != 0)
    abort ();
  if (mod3 (-(1 << 7), -1) != 0)
    abort ();
  if (mod4 (-(1 << 15), -1) != 0)
    abort ();
  if (mod5 (0x50000000, 2) != 0)
    abort ();
  if (mod6 (0x50000000, 2) != 0)
    abort ();
  
  exit (0);
}
Example #7
0
static inline void makefree(int request) {
    int node = 0;

    while (tree[node] != request) {
        node++;
    }

    tree[node] = 0;
    while (node != 0) {
        if ((tree[(mod2(node) == 0) ? node - 1 : node + 1] == 0) && tree[node] == 0) {
            tree[(mod2(node) == 0) ? div2(node - 1) : div2(node)] = 0;
            node = (mod2(node) == 0) ? div2(node - 1) : div2(node);
        } else {
            break;
        }
    }
}
Example #8
0
void pulsesequence()
{
   double pd, seqtime;
   double n,r,bigtau;
   double restol, resto_local;

   init_mri();

   restol=getval("restol");   //local frequency offset
   roff=getval("roff");       //receiver offset

   init_rf(&p1_rf,p1pat,p1,flip1,rof1,rof2);   /* hard pulse */
   calc_rf(&p1_rf,"tpwr1","tpwr1f");
   init_rf(&p2_rf,p2pat,p2,flip2,rof1,rof2);   /* hard pulse */
   calc_rf(&p2_rf,"tpwr2","tpwr2f");

/* calculate 'big tau' values */
   bigtau = getval("bigtau");
   n =  bigtau/(2.0*d2);
   n = (double)((int)((n/2.0) + 0.5)) * 2.0;
   initval(n,v3);

   seqtime = at+p1+rof1+rof2;
   seqtime += 2*d2+p2+rof1+rof2;  /* cpmg pulse and delay */
   
   pd = tr - seqtime;  /* predelay based on tr */
   if (pd <= 0.0) {
      abort_message("%s: Requested tr too short.  Min tr = %f ms",seqfil,seqtime*1e3);
    }

   resto_local=resto-restol; 

   status(A);
   delay(pd);
   xgate(ticks);
   
/* calculate exact delay and phases */

   r = d2-p2/2.0-rof2;   /* correct delay for pulse width */
   mod2(oph,v2);   /* 0,1,0,1 */
   incr(v2);   /* 1,2,1,2 = y,y,-y,-y */

   obsoffset(resto_local); 
   obspower(p1_rf.powerCoarse);
   obspwrf(p1_rf.powerFine);
   rgpulse(p1,oph,rof1,rof2);  /* 90deg */
   obspower(p2_rf.powerCoarse);
   obspwrf(p2_rf.powerFine);
   starthardloop(v3);
      delay(r);
      rgpulse(p2,v2,rof1,rof2);   /* 180deg pulse */
      delay(r);
   endhardloop();
   startacq(alfa);
   acquire(np,1.0/sw);
   endacq();
}
Example #9
0
void setphases()
{
  mod4(ct, oph);            /* 0123 */
  mod2(ct,v1);
  dbl(v1,v1);               /* 0202 */
  add(v1,oph,v3);           /* 0321 */
  add(one,v3,v2);           /* 1032 */
  add(two,oph,oph);
}
Example #10
0
static inline int place(int node) {
    while (node != 0) {
        node = (mod2(node) == 0) ? div2(node - 1) : div2(node);
        if (1 < tree[node]) {
            return 0;
        }
    }

    return 1;
}
Example #11
0
void test_am_sin() {
	Sine vox(220), mod(6);
	MulOp mul(vox, mod);		// AM with MulOp
	logMsg("playing AM sin...");
	run_test(mul);
	logMsg("AM sin done.");
	
	Sine vox2(220), mod2(6);
	vox2.set_scale(mod2);		// AM using set_scale()
	logMsg("playing AM sin...");
	run_test(vox2);
	logMsg("AM sin done.");
}
Example #12
0
/*
 * Eat all of the lines in the input file, attempting to categorize
 * them by their various flavors
 */
void
eaterrors(int *r_errorc, Eptr **r_errorv)
{
	Errorclass errorclass = C_SYNC;
	char *line;
	const char *inbuffer;
	size_t inbuflen;

    for (;;) {
	if ((inbuffer = fgetln(errorfile, &inbuflen)) == NULL)
		break;
	line = Calloc(inbuflen + 1, sizeof(char));
	memcpy(line, inbuffer, inbuflen);
	line[inbuflen] = '\0';
	wordvbuild(line, &cur_wordc, &cur_wordv);

	/*
	 * for convenience, convert cur_wordv to be 1 based, instead
	 * of 0 based.
	 */
	cur_wordv -= 1;
	if (cur_wordc > 0 &&
	   ((( errorclass = onelong() ) != C_UNKNOWN)
	   || (( errorclass = cpp() ) != C_UNKNOWN)
	   || (( errorclass = gcc45ccom() ) != C_UNKNOWN)
	   || (( errorclass = pccccom() ) != C_UNKNOWN)
	   || (( errorclass = richieccom() ) != C_UNKNOWN)
	   || (( errorclass = lint0() ) != C_UNKNOWN)
	   || (( errorclass = lint1() ) != C_UNKNOWN)
	   || (( errorclass = lint2() ) != C_UNKNOWN)
	   || (( errorclass = lint3() ) != C_UNKNOWN)
	   || (( errorclass = make() ) != C_UNKNOWN)
	   || (( errorclass = f77() ) != C_UNKNOWN)
	   || ((errorclass = pi() ) != C_UNKNOWN)
	   || (( errorclass = ri() )!= C_UNKNOWN)
	   || (( errorclass = mod2() )!= C_UNKNOWN)
	   || (( errorclass = troff() )!= C_UNKNOWN))
	) ;
	else
		errorclass = catchall();
	if (cur_wordc)
		erroradd(cur_wordc, cur_wordv+1, errorclass, C_UNKNOWN);
    }
#ifdef FULLDEBUG
    printf("%d errorentrys\n", nerrors);
#endif
    arrayify(r_errorc, r_errorv, er_head);
}
Example #13
0
void
eaterrors(int *r_errorc, Eptr **r_errorv)
{
	Errorclass	errorclass = C_SYNC;

	for (;;) {
		if (fgets(inbuffer, BUFSIZ, errorfile) == NULL)
			break;
		wordvbuild(inbuffer, &wordc, &wordv);
		/*
		 * for convenience, convert wordv to be 1 based, instead
		 * of 0 based.
		 */
		wordv -= 1;
		/*
		 * check for sunf77 errors has to be done before
		 * pccccom to be able to distingush between the two
		 */
		if ((wordc > 0) &&
		    (((errorclass = onelong()) != C_UNKNOWN) ||
		    ((errorclass = cpp()) != C_UNKNOWN) ||
		    ((errorclass = sunf77()) != C_UNKNOWN) ||
		    ((errorclass = pccccom()) != C_UNKNOWN) ||
		    ((errorclass = richieccom()) != C_UNKNOWN) ||
		    ((errorclass = lint0()) != C_UNKNOWN) ||
		    ((errorclass = lint1()) != C_UNKNOWN) ||
		    ((errorclass = lint2()) != C_UNKNOWN) ||
		    ((errorclass = lint3()) != C_UNKNOWN) ||
		    ((errorclass = make()) != C_UNKNOWN) ||
		    ((errorclass = f77()) != C_UNKNOWN) ||
		    ((errorclass = pi()) != C_UNKNOWN) ||
		    ((errorclass = ri()) != C_UNKNOWN) ||
		    ((errorclass = troff()) != C_UNKNOWN) ||
		    ((errorclass = mod2()) != C_UNKNOWN) ||
		    ((errorclass = troff()) != C_UNKNOWN))) {
		    /* EMPTY */
		} else {
			errorclass = catchall();
		}
		if (wordc)
			erroradd(wordc, wordv+1, errorclass, C_UNKNOWN);
	}
#ifdef FULLDEBUG
	printf("%d errorentrys\n", nerrors);
#endif
	arrayify(r_errorc, r_errorv, er_head);
}
Example #14
0
LISTA *module21(LISTA *ris, int num2, int Nrim, MATRICEi *Mdiscr, VETTOREi *h, VETTOREi *h_new, VETTOREi *Sin, VETTOREi *Sout, VETTOREd *STin, VETTOREd *STout, VETTOREd *Freq_in, VETTOREd *Freq_out, int max_con, double Cf_c, VETTOREd *toll)
{
	int controllo = 0, max_g2;
	double Pm2;
	VETTOREi *Ng = NULL, *tmp1_i = NULL;
	MATRICEi *mm = NULL;
	//MATRICEd *Sc = NULL;

	_Intestazione("\n*** module21 ***\n");

	while (controllo == 0) {
		max_g2 = (num2 < Nrim)? num2: Nrim;
		tmp1_i = seq_i(tmp1_i, 2, max_g2, 1);
		Ng = sampleB(Ng, tmp1_i, 1, 0);
		mm = mod2(mm, ACCEDIv_i(Ng, 1), Cf_c, max_con);
		ris = probmod1(ris, mm, h, Sin, Sout, STin, STout, Freq_in, Freq_out, toll);
		CtrlLlst(ris, 1);
		Pm2 = ACCEDIv_d(ACCEDIlst(ris, 1, vd), 1);
		// qui dovrei ricopiarla, in realta` Sc e` passata per riferimento, per cui non serve farlo (anzi, sembra non essere mai usata!!)
		// Sc = aus_p->dati[2].md; // [[2]] ?
		if (!ISNA(Pm2))
			controllo = 1;
		else {
			num2--;
			if (num2 < 2) {
				controllo = 1;
				Pm2 = NA_REAL;
				CtrlLlst(ris, 1);
				ASSEGNAv_d(ACCEDIlst(ris, 1, vd), 1, Pm2);
			}
		}
	}

	CANCELLAv_i(tmp1_i);
	CANCELLAv_i(Ng);
	// non devo cancellare mm, perche´ sarebbe la M di aus_p->dati[1]
	// aus.p[[5]]<-c(1) #hubs
	// il 5' elemento non e` allocato da probmod
	CtrlLlst(ris, 5);
	CREAv_i(ACCEDIlst(ris, 5, vi), 1);
	ASSEGNAv_i(ACCEDIlst(ris, 5, vi), 1, 1);

	StrBilanciam();

	return ris;
}
Example #15
0
void pulsesequence()
{
/* CHECK CONDITIONS */
   if (rof1 < 9.9e-6)
      fprintf(stdout, "Warning:  ROF1 is less than 10 us.\n");
   if (p1 == 0.0)
      p1 = 2*pw;

/* STEADY-STATE PHASECYCLING */
/* This section determines if the phase calculations trigger off of (SS - SSCTR)
   or off of CT */

   ifzero(ssctr);
      dbl(ct, v1);
      hlv(ct, v3);
   elsenz(ssctr);
      sub(ssval, ssctr, v7);	/* v7 = 0,...,ss-1 */
      dbl(v7, v1);
      hlv(v7, v3);
   endif(ssctr);


/* PHASECYCLE CALCULATION */
   hlv(v3, v2);
   mod2(v3, v3);
   add(v3, v1, v1);
   assign(v1, oph);
   dbl(v2, v4);
   add(v4, oph, oph);
   add(v2, v3, v2);


/* BEGIN ACTUAL SEQUENCE */
   status(A);
      hsdelay(d1);
   status(B);
      rgpulse(pw, v1, rof1, rof1);
      delay(d2/2);
      rgpulse(p1, v2, rof1, 2*rof1 + pw/2);
      delay(d2/2);
   status(C);
}
Example #16
0
pulsesequence()
{
double	j1xh,
	d3,
        tpwr180 = getval("tpwr180"),
        pw180 = getval("pw180"),
	tau;
char    pw180ad[MAXSTR];

 j1xh = getval("j1xh");
 d3 = getval("d3");
 getstr("pw180ad",pw180ad);
 tau = 1/j1xh;

/* CALCULATE PHASE CYCLE */
   hlv(oph, v1);
   dbl(v1, v1);
   incr(v1);				/* v1=1133 */
   mod2(oph, v2);
   dbl(v2, v2);
   incr(v2);				/* v2=1313 */
   add(v1, oph, v1);
   sub(v1, one, v3);
   add(v2, oph, v2);
   sub(v2, one, v4);

/* ACTUAL PULSE SEQUENCE */
   status(A);		
      hsdelay(d1);
      obspower(tpwr);
   status(B);	
      rgpulse(pw, oph, rof1, rof1);
      delay(tau - rof1);
      obspower(tpwr180);
      shaped_pulse(pw180ad,pw180,v1,rof1,rof1);
   status(C);	
        delay(tau + d3 - rof1+2*POWER_DELAY);
	shaped_pulse(pw180ad,pw180,v2,rof1,rof2);
	obspower(tpwr);
        delay(d3);
}
Example #17
0
/* Returns UA_TRUE if an entry was found under the nodeid. Otherwise, returns
   false and sets slot to a pointer to the next free slot. */
static UA_Boolean
containsNodeId(const UA_NodeStore *ns, const UA_NodeId *nodeid, UA_NodeStoreEntry **entry) {
    hash_t         h     = hash(nodeid);
    UA_UInt32      size  = ns->size;
    hash_t         index = mod(h, size);
    UA_NodeStoreEntry *e = &ns->entries[index];

    if(!e->taken) {
        *entry = e;
        return UA_FALSE;
    }

    if(UA_NodeId_equal(&e->node.node.nodeId, nodeid)) {
        *entry = e;
        return UA_TRUE;
    }

    hash_t hash2 = mod2(h, size);
    for(;;) {
        index += hash2;
        if(index >= size)
            index -= size;
        e = &ns->entries[index];
        if(!e->taken) {
            *entry = e;
            return UA_FALSE;
        }
        if(UA_NodeId_equal(&e->node.node.nodeId, nodeid)) {
            *entry = e;
            return UA_TRUE;
        }
    }

    /* NOTREACHED */
    return UA_TRUE;
}
Example #18
0
UA_StatusCode UA_NodeStore_insert(UA_NodeStore *ns, UA_Node *node, UA_Node **inserted) {
    if(ns->size * 3 <= ns->count * 4) {
        if(expand(ns) != UA_STATUSCODE_GOOD)
            return UA_STATUSCODE_BADINTERNALERROR;
    }

    UA_NodeStoreEntry *entry;
    UA_NodeId tempNodeid;
    tempNodeid = node->nodeId;
    tempNodeid.namespaceIndex = 0;
    if(UA_NodeId_isNull(&tempNodeid)) {
        /* find a free nodeid */
        if(node->nodeId.namespaceIndex == 0) //original request for ns=0 should yield ns=1
            node->nodeId.namespaceIndex = 1;
        UA_Int32 identifier = ns->count+1; // start value
        UA_Int32 size = ns->size;
        hash_t increase = mod2(identifier, size);
        while(UA_TRUE) {
            node->nodeId.identifier.numeric = identifier;
            if(!containsNodeId(ns, &node->nodeId, &entry))
                break;
            identifier += increase;
            if(identifier >= size)
                identifier -= size;
        }
    } else {
        if(containsNodeId(ns, &node->nodeId, &entry))
            return UA_STATUSCODE_BADNODEIDEXISTS;
    }

    fillEntry(entry, node);
    ns->count++;
    if(inserted)
        *inserted = &entry->node.node;
    return UA_STATUSCODE_GOOD;
}
Example #19
0
/* Returns true if an entry was found under the nodeid. Otherwise, returns
   false and sets slot to a pointer to the next free slot. */
static UA_Boolean
containsNodeId(const UA_NodeStore *ns, const UA_NodeId *nodeid, UA_NodeStoreEntry ***entry) {
    hash_t h = hash(nodeid);
    UA_UInt32 size = ns->size;
    hash_t idx = mod(h, size);
    UA_NodeStoreEntry *e = ns->entries[idx];

    if(!e) {
        *entry = &ns->entries[idx];
        return false;
    }

    if(UA_NodeId_equal(&e->node.nodeId, nodeid)) {
        *entry = &ns->entries[idx];
        return true;
    }

    hash_t hash2 = mod2(h, size);
    for(;;) {
        idx += hash2;
        if(idx >= size)
            idx -= size;
        e = ns->entries[idx];
        if(!e) {
            *entry = &ns->entries[idx];
            return false;
        }
        if(UA_NodeId_equal(&e->node.nodeId, nodeid)) {
            *entry = &ns->entries[idx];
            return true;
        }
    }

    /* NOTREACHED */
    return true;
}
Example #20
0
pulsesequence()
{
int     selectCTP = getval("selectCTP");
double	kappa = getval("kappa"), 
	gzlvl1 = getval("gzlvl1"),
	gzlvl3 = getval("gzlvl3"),
        gzlvl_max = getval("gzlvl_max"),
	gt1 = getval("gt1"),
	gt3 = getval("gt3"),
	del = getval("del"),
        gstab = getval("gstab"),
        gss = getval("gss"),
	tweak = getval("tweak"),
	gzlvl_read=getval("gzlvl_read"),
	num=getval("num"),
        hsgt = getval("hsgt"),
        gzlvlhs =  getval("gzlvlhs"),
	avm,gzlvl4,gt4,Dtau,Ddelta,dosytimecubed,dosyfrq;
char alt_grd[MAXSTR],avflag[MAXSTR],delflag[MAXSTR],STEflag[MAXSTR],sspul[MAXSTR];

gt4 = 2.0*gt1;
getstr("alt_grd",alt_grd);
getstr("delflag",delflag);
getstr("avflag",avflag);
getstr("STEflag",STEflag);
getstr("sspul",sspul);

avm=0.0;
if(avflag[0]=='y')
{
	avm=1.0;
}

/* Decrement gzlvl4 as gzlvl1 is incremented, to ensure constant 
   energy dissipation in the gradient coil 
   Current through the gradient coil is proportional to gzlvl */

gzlvl4=sqrt(2.0*gt1*(1+3.0*kappa*kappa)/gt4)*sqrt(gzlvl_max*gzlvl_max/((1+kappa)*(1+kappa))-gzlvl1*gzlvl1);

/* In pulse sequence, del>4.0*pw+3*rof1+2.0*gt1+5.0*gstab+gt3 */

if ((del-(4*pw+3.0*rof1+2.0*gt1+5.0*gstab+gt3)) < 0.0)
   { del=(4*pw+3.0*rof1+2.0*gt1+5.0*gstab+gt3);
     printf("Warning: del too short; reset to minimum value\n");}

if ((d1 - (gt3+gstab) -2.0*(gt4/2.0+gstab)) < 0.0)
   { d1 = (gt3+gstab) -2.0*(gt4/2.0+gstab);
     printf("Warning: d1 too short;  reset to minimum value\n");}

if ((abs(gzlvl1)*(1+kappa)) > gzlvl_max)
   { abort_message("Max. grad. amplitude exceeded: reduce either gzlvl1 or kappa\n");
     }

if (ni > 1.0)
   { abort_message("This is a 2D, not a 3D dosy sequence: please set ni to 0 or 1\n");
     }

Ddelta=gt1;
Dtau=2.0*pw+gstab+gt1/2.0+rof1;
dosyfrq = getval("sfrq");
dosytimecubed=del+(gt1*((kappa*kappa-2)/6.0))+Dtau*((kappa*kappa-1.0)/2.0);
dosytimecubed=(gt1*gt1)*dosytimecubed;
putCmd("makedosyparams(%e,%e)\n",dosytimecubed,dosyfrq);

/* This section determines the phase calculation for any number of transients   */
 
  initval(num,v14);
  add(v14,ct,v13);

/* phase cycling calculation */

if(delflag[0]=='y')
{
	mod4(v13,v3);	/* 1st 180,  0 1 2 3	*/
	hlv(v13,v9);	
	hlv(v9,v9);		
	mod4(v9,v4);	/* 2nd 90,  (0)4 (1)4 (2)4 (3)4  */
	hlv(v9,v9);
	hlv(v9,v9);
	mod4(v9,v1);	/* 2nd 180, (0)16 (1)16 (2)16 (3)16  */ 
	hlv(v9,v9);
	hlv(v9,v9);
	mod4(v9,v2);	/* 1st 90,  (0)64 (1)64 (2)64 (3)64  */
	hlv(v9,v9);
	hlv(v9,v9);
	mod4(v9,v5);	/* 3rd 90,  (0)256 (1)256 (2)256 (3)256  */

	if(STEflag[0]=='y')
				{
	dbl(v2,v6); assign(v6,oph); sub(oph,v1,oph);
        sub(oph,v3,oph); sub(oph,v4,oph); dbl(v5,v6);
        add(v6,oph,oph); mod4(oph,oph);                /* receiver phase for STE */
				}
	else

				{
 	assign(v1,oph); dbl(v2,v6); sub(oph,v6,oph);
        add(v3,oph,oph); sub(oph,v4,oph); dbl(v5,v6);
        add(v6,oph,oph); mod4(oph,oph);                /* receiver phase for STAE */
				}
	
}
   mod2(ct,v7);		/* change sign of gradients on alternate transients */
   status(A);

   if(delflag[0]=='y')
	{

	if (sspul[0]=='y')
       		{
         	zgradpulse(gzlvlhs,hsgt);
         	rgpulse(pw,zero,rof1,rof1);
         	zgradpulse(gzlvlhs,hsgt);
       	}

	delay(d1 - (gt3+gstab) -2.0*(gt4/2.0+gstab)-gss); /* Move d1 to here */

      	zgradpulse(-1.0*gzlvl4,gt4/2.0); /* 1st dummy heating pulse */
   	delay(gstab);

	zgradpulse(gzlvl4,gt4/2.0); /* 2nd dummy heating pulse */
	delay(gstab);

	delay(gss); /* Short delay to acheive steady state */

        if (alt_grd[0] == 'y')
        {
                ifzero(v7);
                zgradpulse(-1.0*gzlvl3,gt3);
                elsenz(v7);
                zgradpulse(gzlvl3,gt3);
                endif(v7);
        }
	else	zgradpulse(-1.0*gzlvl3,gt3); /* Spoiler gradient balancing pulse */
	delay(gstab); 
        }
	else delay(d1);

   status(B); /* first part of sequence */
   if(delflag[0]=='y')
   {
   	if(gt1>0 && abs(gzlvl1)>0)
   	{
		if(selectCTP==2)
		{
   		rgpulse(0.0, v1, rof1, rof2);		/* first 90, v1 */
		}
	else
   		rgpulse(pw, v1, rof1, rof2);		/* first 90, v1 */

	zgradpulse(gzlvl1*(1.0+kappa),gt1/2.0); /*1st main gradient pulse*/
   	delay(gstab);
		if(selectCTP==2)
		{
		rgpulse(0.0, v2, rof1, rof2);		/* first 180, v2 */
		}
	else
		rgpulse(pw*2.0, v2, rof1, rof2);		/* first 180, v2 */

	zgradpulse(-1.0*gzlvl1*(1.0-kappa),gt1/2.0); /*2nd main grad. pulse*/
   	delay(gstab);
		if((selectCTP==1)||(selectCTP==2))
		{
   		rgpulse(0.0, v3, rof1, rof2);		/* second 90, v3 */
		}
	else
   		rgpulse(pw, v3, rof1, rof2);		/* second 90, v3 */

	zgradpulse(-gzlvl1*2.0*kappa,gt1/2.0); /*Lock refocussing pulse*/
   	delay(gstab);

                if (alt_grd[0] == 'y')
                {
                        ifzero(v7);
                        zgradpulse(gzlvl3,gt3); /* Spoiler gradient */
                        elsenz(v7);
                        zgradpulse(-1.0*gzlvl3,gt3);
                        endif(v7);
                }
	else	zgradpulse(gzlvl3,gt3); /* Spoiler gradient  */

   	delay(gstab);

	delay(del-4.0*pw-3.0*rof1-2.0*gt1-5.0*gstab-gt3); /* diffusion delay */

		if(STEflag[0]=='y')
		{
		zgradpulse(2.0*kappa*gzlvl1,gt1/2.0); /*Lock refocussing pulse*/
   		delay(gstab);
		}
	else
		{
		zgradpulse(-2.0*kappa*gzlvl1,gt1/2.0); /*Lock refocussing pulse*/
   		delay(gstab);
		}
		if(selectCTP==1)
		{
   		rgpulse(0.0, v4, rof1, rof2);		/* third 90, v4 */
		}
	else
   		rgpulse(pw, v4, rof1, rof2);		/* third 90, v4 */

		if(STEflag[0]=='y')
		{
		zgradpulse(-gzlvl1*(1.0+kappa),gt1/2.0); /*3rd main gradient pulse*/
   		delay(gstab);
		}
	else
		{
		zgradpulse(gzlvl1*(1.0+kappa),gt1/2.0); /*3rd main gradient pulse*/
   		delay(gstab);
		}

	rgpulse(pw*2.0, v5, rof1, rof2);	/* second 180, v5 */
rcvron();
		if(STEflag[0]=='y')
		{
		zgradpulse(1.0*(1.0-kappa)*gzlvl1+tweak-avm*at*gzlvl_read/gt1,gt1/2.0); /*4th main grad. pulse*/
   		delay(gstab);
		}
	else
		{
		zgradpulse(-1.0*(1.0-kappa)*gzlvl1-tweak-avm*at*gzlvl_read/gt1,gt1/2.0); /*4th main grad. pulse*/
   		delay(gstab);
		}
	rgradient('z',gzlvl_read);
   	}
   }
   else rgpulse(pw,oph,rof1,rof2);
   status(C);

}
Example #21
0
pulsesequence()
{
   double  gzlvl1 = getval("gzlvl1"),
              gt1 = getval("gt1"),
           zqfpw1 = getval("zqfpw1"),
          zqfpwr1 = getval("zqfpwr1"),
         gzlvlzq1 = getval("gzlvlzq1"),
	    gstab = getval("gstab"),
     h1freq_local = getval("h1freq_local"),
            flip1 = getval("flip1"),
            flip2 = getval("flip2"),
         swfactor = 9.0,    /* do the adiabatic sweep over 9.0*sw  */
         gzlvlzq,invsw;
   int     iphase = (int) (getval("phase") + 0.5),
	 prgcycle = (int)(getval("prgcycle")+0.5);
   char		   satmode[MAXSTR],
		   zqfpat1[MAXSTR],
		   wet[MAXSTR],
		   antiz_flg[MAXSTR],
		   alt_grd[MAXSTR];
           

   getstr("satmode",satmode);
   getstr("wet",wet);
   getstr("zqfpat1",zqfpat1);
   getstr("antiz_flg", antiz_flg);
   getstr("alt_grd",alt_grd);

   invsw = sw*swfactor;
   if (invsw > 60000.0) invsw = 60000.0; /* do not exceed 60 kHz */
   invsw = invsw/0.97;     /* correct for end effects of the cawurst-20 shape */

  assign(ct,v17);
  assign(zero,v18);
  assign(zero,v19);

  if (getflag("prgflg") && (satmode[0] == 'y') && (prgcycle > 1.5))
    {
        hlv(ct,v17);
        mod2(ct,v18); dbl(v18,v18);
        if (prgcycle > 2.5)
           {
                hlv(v17,v17);
                hlv(ct,v19); mod2(v19,v19); dbl(v19,v19);
           }
     }

//   sub(ct,ssctr,v12);
   settable(t1,8,ph1);  getelem(t1,v17,v1);
   settable(t2,8,ph2);  getelem(t2,v17,v2);
   settable(t3,8,ph3);  getelem(t3,v17,v3);
   settable(t4,8,ph4);  getelem(t4,v17,oph);

   add(oph,v18,oph);
   add(oph,v19,oph);

   if (alt_grd[0] == 'y') mod2(ct,v8); /* alternate gradient sign */
   if (getflag("Gzqfilt")) add(oph,two,oph);
   if (iphase == 2) incr(v1);

/* HYPERCOMPLEX MODE USES REDFIELD TRICK TO MOVE AXIAL PEAKS TO EDGE */
   initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v6);
   if ((iphase==1)||(iphase==2))
      {add(v1,v6,v1); add(oph,v6,oph);}

/* BEGIN THE ACTUAL PULSE SEQUENCE */
   status(A);
   delay(5.0e-5);
   if (getflag("sspul"))
        steadystate();

   if (satmode[0] == 'y')
     {
        if ((d1-satdly) > 0.02)
                delay(d1-satdly);
        else
                delay(0.02);
	if (getflag("slpsat"))
	     {
		shaped_satpulse("relaxD",satdly,v6);
               	if (getflag("prgflg"))
                   shaped_purge(v1,v6,v18,v19);
             }

	else
	     {
        	satpulse(satdly,v6,rof1,rof1);
		if (getflag("prgflg"))
		   purge(v1,v6,v18,v19);
	     }
     }
   else
        delay(d1);

   if (wet[0] == 'y')
     wet4(zero,one);

      obsstepsize(45.0);
      initval(7.0,v7);
      xmtrphase(v7);
   status(B);
      if (antiz_flg[0] == 'n') rgpulse(flip1*pw/90.0,v1,rof1,1.0e-6);
                         else rgpulse(flip1*pw/90.0+2.0*pw,v1,rof1,1.0e-6);
      xmtrphase(zero);
      if (d2 > 0.0)
        {
         if (antiz_flg[0] == 'n') 
           delay(d2-1.0e-6-rof1-SAPS_DELAY-(2.0*pw/3.14159)*(flip1+flip2)/90.0);
         else
           delay(d2-1.0e-6-rof1-SAPS_DELAY-(2.0*pw/3.14159)*(flip1+flip2)/90.0+4.0*pw); 
        }
        else delay(0.0);
      if (antiz_flg[0] == 'n') rgpulse(flip2*pw/90.0,v2,rof1,1.0e-6);
                         else rgpulse(flip2*pw/90.0+2.0*pw,v2,rof1,1.0e-6);
   status(C);
        if (getflag("Gzqfilt"))
        {
         obspower(zqfpwr1);
         rgradient('z',gzlvlzq1);
         delay(100.0e-6);
         shaped_pulse(zqfpat1,zqfpw1,zero,rof1,rof1);
         delay(100.0e-6);
         rgradient('z',0.0);
         delay(gstab);
	 obspower(tpwr);
        }
        ifzero(v8); zgradpulse(gzlvl1,gt1);
              elsenz(v8); zgradpulse(-1.0*gzlvl1,gt1); endif(v8);
        delay(gstab);
   status(D);
      rgpulse(flip2*pw/90.0,v3,rof1,rof2);
}
Example #22
0
pulsesequence()
{
   double	   slpwrR = getval("slpwrR"),
		   slpwR = getval("slpwR"),
		   mixR = getval("mixR"),
                   selpwrA = getval("selpwrA"),
                   selpwA = getval("selpwA"),
                   gzlvlA = getval("gzlvlA"),
                   gtA = getval("gtA"),
                   selpwrB = getval("selpwrB"),
                   selpwB = getval("selpwB"),
                   gzlvlB = getval("gzlvlB"),
                   gtB = getval("gtB"),
                   gstab = getval("gstab"),
		   selfrq = getval("selfrq"),
                   gzlvl1 = getval("gzlvl1"),
                   gt1 = getval("gt1"),
                   gzlvl2 = getval("gzlvl2"),
                   gt2 = getval("gt2"),
                   zqfpw1 = getval("zqfpw1"),
                   zqfpwr1 = getval("zqfpwr1"),
                   gzlvlzq1 = getval("gzlvlzq1"),
                   phincr1 = getval("phincr1");
   char            selshapeA[MAXSTR],selshapeB[MAXSTR], slpatR[MAXSTR],
                   zqfpat1[MAXSTR], alt_grd[MAXSTR];

//synchronize gradients to srate for probetype='nano'
//   Preserve gradient "area"
        gtA = syncGradTime("gtA","gzlvlA",1.0);
        gzlvlA = syncGradLvl("gtA","gzlvlA",1.0);
        gtB = syncGradTime("gtB","gzlvlB",1.0);
        gzlvlB = syncGradLvl("gtB","gzlvlB",1.0);

   getstr("slpatR",slpatR);
   getstr("selshapeA",selshapeA);
   getstr("selshapeB",selshapeB);
   getstr("zqfpat1",zqfpat1);
   getstr("alt_grd",alt_grd);

   if (strcmp(slpatR,"cw") &&
        strcmp(slpatR,"troesy") &&
        strcmp(slpatR,"dante"))
        abort_message("SpinLock pattern %s not supported!.\n", slpatR);

/* STEADY-STATE PHASECYCLING */
/* This section determines if the phase calculations trigger off of (SS - SSCTR) or off of CT */

  assign(ct,v17);
   ifzero(ssctr);
      assign(v17,v13);
   elsenz(ssctr);
                /* purge option does not adjust v13 during steady state */
      sub(ssval, ssctr, v13);
   endif(ssctr);

/* Beginning phase cycling */

   dbl(v13,v1);		/* v1 = 0 2 */
   hlv(v13,v13);
   dbl(v13,v20);		/* v20 = 00 22 */
   hlv(v13,v13);
   dbl(v13,v6);		/* v6 = 0000 2222 */
   hlv(v13,v13);
   dbl(v13,v7);		/* v7 = 00000000 22222222 */

   assign(v1,oph);

   if (getflag("Gzqfilt"))
      add(v7,oph,oph);

/* CYCLOPS */

   assign(v13,v14);	/* v14 = 8x0 8x1 8x2 8x3 */
   
   if (getflag("Gzqfilt"))
      hlv(v13,v14);	/* v14 = 16x0 16x1 16x2 16x3 */

   add(v1,v14,v1);      
   add(v20,v14,v20);      
   add(v6,v14,v6);      
   add(v7,v14,v7);      
   add(oph,v14,oph);

/*  add(oph,v18,oph);
  add(oph,v19,oph); */
  assign(zero,v9);

   mod2(ct,v2);    /* 01 01 */
   hlv(ct,v11); hlv(v11,v11); mod2(v11,v11); dbl(v11,v11); /* 0000 2222 */
   add(v11,v2,v11); mod4(v11,v11); /* 0101 2323  first echo in Excitation Sculpting */
   hlv(ct,v4); mod2(v4,v4);    /* 0011 */
   hlv(ct,v12); hlv(v12,v12); hlv(v12,v12); dbl(v12,v12); add(v12,v4,v12);
   mod4(v12,v12);   /* 0011 0011 2233 2233 second echo in Excitation Sculpting */

   dbl(v2,v2);    /* 0202 */
   dbl(v4,v4);    /* 0022 */
   add(v2,v4,v4); /* 0220 correct oph for Excitation Sculpting */
   add(oph,v4,oph); mod4(oph,oph);

   if (!strcmp(slpatR,"troesy")) 
	assign(v20,v21);
   else
	add(v20,one,v21);

   if (alt_grd[0] == 'y') mod2(ct,v8); /* alternate gradient sign on even scans */

/* The following is for flipback pulse */
   if (phincr1 < 0.0) phincr1=360+phincr1;
   initval(phincr1,v5);

/* BEGIN THE ACTUAL PULSE SEQUENCE */
   status(A);

   if (getflag("lkgate_flg"))  lk_sample(); /* turn lock sampling on */

   obspower(tpwr);
   delay(5.0e-5);
   if (getflag("sspul"))
        steadystate();

   delay(d1);

   if (getflag("lkgate_flg"))  lk_hold(); /* turn lock sampling off */

   status(B);
      rgpulse(pw, v1, rof1, rof1);
      if (selfrq != tof)
	obsoffset(selfrq);

        ifzero(v8); zgradpulse(gzlvlA,gtA);
        elsenz(v8); zgradpulse(-gzlvlA,gtA); endif(v8);
        delay(gstab);
        obspower(selpwrA);
        shaped_pulse(selshapeA,selpwA,v14,rof1,rof1);
        obspower(tpwr);
        ifzero(v8); zgradpulse(gzlvlA,gtA);
        elsenz(v8); zgradpulse(-gzlvlA,gtA); endif(v8);
        delay(gstab);

      if (selfrq != tof)
        delay(2*OFFSET_DELAY);

        ifzero(v8); zgradpulse(gzlvlB,gtB);
        elsenz(v8); zgradpulse(-gzlvlB,gtB); endif(v8);
        delay(gstab);
        obspower(selpwrB);
        shaped_pulse(selshapeB,selpwB,v6,rof1,rof1);
        obspower(slpwrR);
        ifzero(v8); zgradpulse(gzlvlB,gtB);
        elsenz(v8); zgradpulse(-gzlvlB,gtB); endif(v8);
        delay(gstab);

      if (selfrq != tof)
        obsoffset(tof);

     if (mixR > 0.0)
      { 
	  if (dps_flag)
		rgpulse(mixR,v21,0.0,0.0);
	  else
		SpinLock(slpatR,mixR,slpwR,v21);
      }

    if (getflag("Gzqfilt"))
    {
     obspower(tpwr);
     rgpulse(pw,v7,rof1,rof1);

     ifzero(v8); zgradpulse(gzlvl1,gt1);
     elsenz(v8); zgradpulse(-gzlvl1,gt1); endif(v8);
     delay(gstab);

     obspower(zqfpwr1);
     ifzero(v8); rgradient('z',gzlvlzq1);
     elsenz(v8); rgradient('z',-gzlvlzq1); endif(v8);
     delay(100.0e-6);
     shaped_pulse(zqfpat1,zqfpw1,zero,rof1,rof1);
     delay(100.0e-6);
     rgradient('z',0.0);
     delay(gstab);
    
     ifzero(v8); zgradpulse(-gzlvl2,gt2);
     elsenz(v8); zgradpulse(gzlvl2,gt2); endif(v8);
     obspower(tpwr);
     delay(gstab);

     if (getflag("flipback"))
           FlipBack(v14,v5);
     rgpulse(pw,v14,rof1,2.0e-6);
    }

    ExcitationSculpting(v11,v12,v8);
    delay(rof2);
   
   status(C);
}
Example #23
0
pulsesequence()
{
   double	   slpwrT = getval("slpwrT"),
		   slpwT = getval("slpwT"),
		   mixT = getval("mixT"),
		   trim = getval("trim"),
		   tauz1 = getval("tauz1"), 
		   tauz2 = getval("tauz2"), 
		   tauz3 = getval("tauz3"), 
		   tauz4 = getval("tauz4"),
                   selpwrA = getval("selpwrA"),
                   selpwA = getval("selpwA"),
                   gzlvlA = getval("gzlvlA"),
                   gtA = getval("gtA"),
                   selpwrB = getval("selpwrB"),
                   selpwB = getval("selpwB"),
                   gzlvlB = getval("gzlvlB"),
                   gtB = getval("gtB"),
                   gstab = getval("gstab"),
		   selfrq = getval("selfrq");
   char            selshapeA[MAXSTR], selshapeB[MAXSTR], slpatT[MAXSTR],
                   alt_grd[MAXSTR];

//synchronize gradients to srate for probetype='nano'
//   Preserve gradient "area"
        gtA = syncGradTime("gtA","gzlvlA",1.0);
        gzlvlA = syncGradLvl("gtA","gzlvlA",1.0);
        gtB = syncGradTime("gtB","gzlvlB",1.0);
        gzlvlB = syncGradLvl("gtB","gzlvlB",1.0);

   getstr("slpatT",slpatT);
   getstr("selshapeA",selshapeA);
   getstr("selshapeB",selshapeB);
   getstr("alt_grd",alt_grd);
                     /* alternate gradient sign on every 2nd transient */

   if (strcmp(slpatT,"mlev17c") &&
        strcmp(slpatT,"dipsi2") &&
        strcmp(slpatT,"dipsi3") &&
        strcmp(slpatT,"mlev17") &&
        strcmp(slpatT,"mlev16"))
        abort_message("SpinLock pattern %s not supported!.\n", slpatT);

  assign(ct,v17);

   assign(v17,v6);
   if (getflag("zqfilt")) 
     {  hlv(v6,v6); hlv(v6,v6); }

   settable(t1,4,ph1);   getelem(t1,v6,v1);
   settable(t3,8,ph3);   getelem(t3,v6,v11);
   settable(t4,8,ph4);  
   settable(t5,4,ph5);   getelem(t5,v6,v5); 
   settable(t2,4,ph2);   getelem(t2,v6,v2);
   settable(t7,8,ph7);   getelem(t7,v6,v7);
   settable(t8,4,ph8);   getelem(t8,v6,v8);
   settable(t11,16,phs8); getelem(t11,v6,v3);   /* 1st echo in ES */
   settable(t12,16,phs9); getelem(t12,v6,v4);   /* 2nd exho in ES */
   
   if (getflag("zqfilt"))
     getelem(t4,v6,oph);
   else
     assign(v1,oph);

   add(oph,v5,oph); mod4(oph,oph);

   sub(v2,one,v21);
   add(v21,two,v23);

   mod4(ct,v10);
   if (alt_grd[0] == 'y') mod2(ct,v12); /* alternate gradient sign on every 2nd transient */

/* BEGIN THE ACTUAL PULSE SEQUENCE */
   status(A);

   if (getflag("lkgate_flg"))  lk_sample(); /* turn lock sampling on */

   obspower(tpwr);
   delay(5.0e-5);
   if (getflag("sspul"))
        steadystate();

   delay(d1);

   if (getflag("lkgate_flg"))  lk_hold(); /* turn lock sampling off */

   status(B);
      rgpulse(pw, v1, rof1, rof1);

      if (selfrq != tof)
	obsoffset(selfrq);

        ifzero(v12); zgradpulse(gzlvlA,gtA);
        elsenz(v12); zgradpulse(-gzlvlA,gtA); endif(v12);
        delay(gstab);
        obspower(selpwrA);
        shaped_pulse(selshapeA,selpwA,v1,rof1,rof1);
        obspower(tpwr);
        ifzero(v12); zgradpulse(gzlvlA,gtA);
        elsenz(v12); zgradpulse(-gzlvlA,gtA); endif(v12);
        delay(gstab);

      if (selfrq != tof)
        delay(2*OFFSET_DELAY);

        ifzero(v12); zgradpulse(gzlvlB,gtB);
        elsenz(v12); zgradpulse(-gzlvlB,gtB); endif(v12);
        delay(gstab);
        obspower(selpwrB);
        shaped_pulse(selshapeB,selpwB,v2,rof1,rof1);
        obspower(slpwrT);
        ifzero(v12); zgradpulse(gzlvlB,gtB);
        elsenz(v12); zgradpulse(-gzlvlB,gtB); endif(v12);
        delay(gstab);

      if (selfrq != tof)
	obsoffset(tof);

     if (mixT > 0.0)
      { 
        rgpulse(trim,v11,0.0,0.0);
        if (dps_flag)
          rgpulse(mixT,v21,0.0,0.0);
        else
          SpinLock(slpatT,mixT,slpwT,v21);
       }

      if (getflag("zqfilt"))
      {
	obspower(tpwr);
	rgpulse(pw,v7,1.0e-6,rof1);
	ifzero(v10); delay(tauz1); endif(v10);
	decr(v10);
	ifzero(v10); delay(tauz2); endif(v10);
	decr(v10);
	ifzero(v10); delay(tauz3); endif(v10);
	decr(v10);
	ifzero(v10); delay(tauz4); endif(v10);
	rgpulse(pw,v8,rof1,2.0e-6);
      }
      ExcitationSculpting(v3,v4,v12);
      delay(rof2);

   status(C);
}
Example #24
0
pulsesequence() {
  /* Internal variable declarations *************************/
  int     shapelist90,shapelist180,shapelistIR;
  double  nseg;
  double  seqtime,tau1,tau2,tau3,
          te1_delay,te2_delay,te3_delay,
	  iti_delay, ti_delay,
	  tr_delay;
  double  kzero;
  double  freq90[MAXNSLICE], freq180[MAXNSLICE], freqIR[MAXNSLICE];

  /* Real-time variables used in this sequence **************/
  int  vpe_ctr    = v2;      // PE loop counter
  int  vpe_mult   = v3;      // PE multiplier, ranges from -PE/2 to PE/2
  int  vms_slices = v4;      // Number of slices
  int  vms_ctr    = v5;      // Slice loop counter
  int  vseg       = v6;      // Number of ETL segments 
  int  vseg_ctr   = v7;      // Segment counter
  int  vetl       = v8;      // Echo train length
  int  vetl_ctr   = v9;      // Echo train loop counter
  int  vssc       = v10;     // Compressed steady-states
  int  vtrimage   = v11;     // Counts down from nt, trimage delay when 0
  int  vacquire   = v12;     // Argument for setacqvar, to skip steady state acquires
  int  vphase180  = v13;     // phase of 180 degree refocusing pulse

  /* Initialize paramaters **********************************/
  init_mri();

  /*  Load external PE table ********************************/
  if (strcmp(petable,"n") && strcmp(petable,"N") && strcmp(petable,"")) {
    loadtable(petable);
  } else {
    abort_message("petable undefined");
  }
    
  seqtime = 0.0;
  espmin = 0.0;
  kzero = getval("kzero");

  /* RF Power & Bandwidth Calculations **********************/
  init_rf(&p1_rf,p1pat,p1,flip1,rof1,rof2);
  init_rf(&p2_rf,p2pat,p2,flip2,rof1,rof2);
  calc_rf(&p1_rf,"tpwr1","tpwr1f");
  calc_rf(&p2_rf,"tpwr2","tpwr2f");
 
  /* Initialize gradient structures *************************/
  init_readout_butterfly(&ro_grad,"ro",lro,np,sw,gcrushro,tcrushro);
  init_readout_refocus(&ror_grad,"ror");
  init_phase(&pe_grad,"pe",lpe,nv);
  init_slice(&ss_grad,"ss",thk);   /* NOTE assume same band widths for p1 and p2 */     
  init_slice_butterfly(&ss2_grad,"ss2",thk,gcrush,tcrush); 
  init_slice_refocus(&ssr_grad,"ssr");

  /* Gradient calculations **********************************/
  calc_readout(&ro_grad,WRITE,"gro","sw","at");
  calc_readout_refocus(&ror_grad,&ro_grad,NOWRITE,"gror");
  calc_phase(&pe_grad,WRITE,"gpe","tpe");
  calc_slice(&ss_grad,&p1_rf,WRITE,"gss");
  calc_slice(&ss2_grad,&p1_rf,WRITE,"");
  calc_slice_refocus(&ssr_grad,&ss_grad,NOWRITE,"gssr");

  /* Equalize refocus and PE gradient durations *************/
  calc_sim_gradient(&ror_grad,&null_grad,&ssr_grad,0.0,WRITE);

  /* Create optional prepulse events ************************/
  if (sat[0] == 'y')  create_satbands();
  if (fsat[0] == 'y') create_fatsat();
  if (mt[0] == 'y')   create_mtc();

  if (ir[0] == 'y') {
    init_rf(&ir_rf,pipat,pi,flipir,rof1,rof2);
    calc_rf(&ir_rf,"tpwri","tpwrif");
    init_slice_butterfly(&ssi_grad,"ssi",thk,gcrushir,tcrushir);
    calc_slice(&ssi_grad,&ir_rf,WRITE,"gssi");
  }

  /* Set up frequency offset pulse shape list ********/
  offsetlist(pss,ss_grad.ssamp, 0,freq90, ns,seqcon[1]);
  offsetlist(pss,ss2_grad.ssamp,0,freq180,ns,seqcon[1]);
  offsetlist(pss,ssi_grad.ssamp,0,freqIR, ns,seqcon[1]);
  shapelist90  = shapelist(p1pat,ss_grad.rfDuration, freq90, ns,0,seqcon[1]);
  shapelist180 = shapelist(p2pat,ss2_grad.rfDuration,freq180,ns,0,seqcon[1]);
  shapelistIR  = shapelist(pipat,ssi_grad.rfDuration,freqIR, ns,0,seqcon[1]);

  /* same slice selection gradient and RF pattern used */
  if (ss_grad.rfFraction != 0.5)
    abort_message("ERROR %s: RF pulse must be symmetric (RF fraction = %.2f)",
      seqfil,ss_grad.rfFraction);
  if (ro_grad.echoFraction != 1)
    abort_message("ERROR %s: Echo Fraction must be 1",seqfil);

  /* Find sum of all events in each half-echo period ********/
  tau1 = ss_grad.rfCenterBack  + ssr_grad.duration + ss2_grad.rfCenterFront;
  tau2 = ss2_grad.rfCenterBack + pe_grad.duration  + ro_grad.timeToEcho; 
  tau3 = ro_grad.timeFromEcho  + pe_grad.duration  + ss2_grad.rfCenterFront;

  espmin = 2*MAX(MAX(tau1,tau2),tau3);   // Minimum echo spacing

  if (minesp[0] == 'y') {
    esp = espmin + 8e-6;  // ensure at least 4us delays in both TE periods
    putvalue("esp",esp);
  }
  else if (((espmin+8e-6)-esp) > 12.5e-9) {
    abort_message("ERROR %s: Echo spacing too small, minimum is %.2fms\n",seqfil,(espmin+8e-6)*1000);
  }
  te1_delay = esp/2.0 - tau1;    // Intra-esp delays
  te2_delay = esp/2.0 - tau2;
  te3_delay = esp/2.0 - tau3;

  te = kzero*esp;                // Return effective TE
  putvalue("te",te);

  /* Minimum TR **************************************/
  /* seqtime is total time per slice */
  seqtime = 2*4e-6 + ss_grad.rfCenterFront + etl*esp + ro_grad.timeFromEcho + pe_grad.duration + te3_delay;

  /* Increase TR if any options are selected****************/
  if (sat[0]  == 'y') seqtime += ns*satTime;
  if (fsat[0] == 'y') seqtime += ns*fsatTime;
  if (mt[0]   == 'y') seqtime += ns*mtTime;


  if (ir[0] == 'y') {

    /* Inter-IR delay */
    if (ns > 1) 
      iti_delay = seqtime - ssi_grad.duration;
      /* it is probably safe to assume that seqtime is always > the pulse widths */
    else 
      iti_delay = 0;

    /* Inversion Recovery */
    timin  = ssi_grad.rfCenterBack + ss_grad.rfCenterFront;
    timin += 8e-6; // from sp1on/off and after 90 pulse power setting 
    timin += seqtime*(ns-1) + iti_delay;

    if (ti < timin + 4e-6)  // ensure at least a 4us delay
      abort_message("%s: ti too short, minimum is %.2fms",seqfil,timin*1000);

    /* Delay after the last IR pulse */
    ti_delay = ti - timin;
    
    /* force all slices to be acquired back-to-back, with a single TR delay at end */
    trtype = 1;  

  }
  else {
    iti_delay = ti_delay = 0;
  }

  trmin = ns*(seqtime + 4e-6);
  
  if (ir[0] == 'y') {
    trmin += (4e-6 + ssi_grad.rfCenterFront + ti);
  }
  if (mintr[0] == 'y'){
    tr = trmin;
    putvalue("tr",tr);
  }


  if ((trmin-tr) > 12.5e-9) {
    abort_message("TR too short.  Minimum TR = %.2fms\n",trmin*1000);
  }
  tr_delay = (tr - trmin)/ns;



  /* Set number of segments for profile or full image **********/
  nseg = prep_profile(profile[0],nv/etl,&pe_grad,&per_grad);

  /* Shift DDR for pro *******************************/
  roff = -poffset(pro,ro_grad.roamp);

  /* Calculate total acquisition time */
  g_setExpTime(tr*(nt*nseg*getval("arraydim") + ssc) + trimage*getval("arraydim"));


  /* Return parameters to VnmrJ */
  putvalue("rgss",ss_grad.tramp);  //90  slice ramp
  if (ss2_grad.enableButterfly) {   //180 slice ramps
    putvalue("rcrush",ss2_grad.crusher1RampToCrusherDuration);
    putvalue("rgss2",ss2_grad.crusher1RampToSsDuration);
  }
  else {
    putvalue("rgss2",ss2_grad.tramp);
  }
  if (ro_grad.enableButterfly) {
    putvalue("rgro",ro_grad.crusher1RampToSsDuration);
  }
  else {   
    putvalue("rgro",ro_grad.tramp);      //RO ramp
  }
  putvalue("tror",ror_grad.duration);  //ROR duration
  putvalue("rgror",ror_grad.tramp);    //ROR ramp
  putvalue("gpe",pe_grad.peamp);         //PE max amp
  putvalue("gss",ss_grad.ssamp);
  putvalue("gro",ro_grad.roamp);



  /* PULSE SEQUENCE *************************************/
  initval(fabs(ssc),vssc);      // Compressed steady-state counter
  assign(one,vacquire);         // real-time acquire flag

  /* Phase cycle: Alternate 180 phase to cancel residual FID */
  mod2(ct,vphase180);           // 0101
  dbl(vphase180,vphase180);     // 0202
  add(vphase180,one,vphase180); // 1313 Phase difference from 90
  add(vphase180,oph,vphase180);

  obsoffset(resto);
  delay(4e-6);
    
  initval(nseg,vseg);
  loop(vseg,vseg_ctr);

    /* TTL scope trigger **********************************/       
    sp1on(); delay(4e-6); sp1off();

    /* Compressed steady-states: 1st array & transient, all arrays if ssc is negative */
    if ((ix > 1) && (ssc > 0))
      assign(zero,vssc);
    sub(vseg_ctr,vssc,vseg_ctr);   // vpe_ctr counts up from -ssc
    assign(zero,vssc);
    ifzero(vseg_ctr);
      assign(zero,vacquire);       // Start acquiring when vseg_ctr reaches zero
    endif(vseg_ctr);
    setacqvar(vacquire);           // Turn on acquire when vacquire is zero

    if (ticks) {
      xgate(ticks);
      grad_advance(gpropdelay);
      delay(4e-6);
    }

    if(ir[0] == 'y') {  /* IR for all slices prior to data acquisition */
      obspower(ir_rf.powerCoarse);
      obspwrf(ir_rf.powerFine);
      delay(4e-6);
      msloop(seqcon[1],ns,vms_slices,vms_ctr);
	obl_shapedgradient(ssi_grad.name,ssi_grad.duration,0,0,ssi_grad.amp,NOWAIT);   
	delay(ssi_grad.rfDelayFront);
	shapedpulselist(shapelistIR,ssi_grad.rfDuration,oph,rof1,rof2,seqcon[1],vms_ctr);
	delay(ssi_grad.rfDelayBack);
	delay(iti_delay);
      endmsloop(seqcon[1],vms_ctr);
      delay(ti_delay);
    }

    msloop(seqcon[1],ns,vms_slices,vms_ctr);

      /* Prepulse options ***********************************/
      if (sat[0]  == 'y') satbands();
      if (fsat[0] == 'y') fatsat();
      if (mt[0]   == 'y') mtc();

      /* 90 degree pulse ************************************/         
      rotate();
      obspower(p1_rf.powerCoarse);
      obspwrf(p1_rf.powerFine);
      delay(4e-6);
      obl_shapedgradient(ss_grad.name,ss_grad.duration,0,0,ss_grad.amp,NOWAIT);   
      delay(ss_grad.rfDelayFront);
      shapedpulselist(shapelist90,ss_grad.rfDuration,oph,rof1,rof2,seqcon[1],vms_ctr);
      delay(ss_grad.rfDelayBack);

      /* Read dephase and Slice refocus *********************/
      obl_shapedgradient(ssr_grad.name,ssr_grad.duration,ror_grad.amp,0.0,-ssr_grad.amp,WAIT);

      /* First half-TE delay ********************************/
      obspower(p2_rf.powerCoarse);
      obspwrf(p2_rf.powerFine);
      delay(te1_delay);
	
      peloop(seqcon[2],etl,vetl,vetl_ctr);
        mult(vseg_ctr,vetl,vpe_ctr);
        add(vpe_ctr,vetl_ctr,vpe_ctr);
        getelem(t1,vpe_ctr,vpe_mult);

        /* 180 degree pulse *******************************/
        /* Note, ss2_grad.amp is max gradient for butterfly shape; flat top = _.ssamp */ 
        obl_shapedgradient(ss2_grad.name,ss2_grad.duration,0,0,ss2_grad.amp,NOWAIT);   
    	delay(ss2_grad.rfDelayFront); 
        shapedpulselist(shapelist180,ss2_grad.rfDuration,vphase180,rof1,rof2,seqcon[1],vms_ctr);
        delay(ss2_grad.rfDelayBack);   

        /* Phase-encode gradient ******************************/
        pe_shapedgradient(pe_grad.name,pe_grad.duration,0,0,0,-pe_grad.increment,vpe_mult,WAIT);

        /* Second half-TE period ******************************/
	delay(te2_delay);
	 
        /* Readout gradient ************************************/
        obl_shapedgradient(ro_grad.name,ro_grad.duration,ro_grad.amp,0,0,NOWAIT);
        delay(ro_grad.atDelayFront);

        /* Acquire data ****************************************/
        startacq(alfa);
        acquire(np,1.0/sw);
        endacq();

        delay(ro_grad.atDelayBack);

        /* Rewinding phase-encode gradient ********************/
        /* Phase encode, refocus, and dephase gradient ******************/
        pe_shapedgradient(pe_grad.name,pe_grad.duration,0,0,0,pe_grad.increment,vpe_mult,WAIT);

        /* Second half-TE delay *******************************/
        delay(te3_delay);
      endpeloop(seqcon[2],vetl_ctr);

      /* Relaxation delay ***********************************/
      if (!trtype)
        delay(tr_delay);
    endmsloop(seqcon[1],vms_ctr);
    if (trtype)
      delay(ns*tr_delay);
  endloop(vseg_ctr);

  /* Inter-image delay **********************************/
  sub(ntrt,ct,vtrimage);
  decr(vtrimage);
  ifzero(vtrimage);
    delay(trimage);
  endif(vtrimage);
}
Example #25
0
pulsesequence()
{
   double          phase = getval("phase"),
                   mix = getval("mix"),
                   wrefpwr = getval("wrefpwr"),
                   wrefpw = getval("wrefpw"),
                   wrefpwrf = getval("wrefpwrf"),
                   gt1 = getval("gt1"),
                   gzlvl1 = getval("gzlvl1"),
                   gt2 = getval("gt2"),
                   gzlvl2 = getval("gzlvl2"),
                   gstab = getval("gstab"),
                   trimpwr = getval("trimpwr"),
                   trim = getval("trim"),
                   compH = getval("compH"),
                   strength = getval("strength"), /* spinlock field strength in Hz */
                   cycles, d2corr, corfact, slpw90, slpwr, slpwra;
   int             iphase;
   char            sspul[MAXSTR],T_flg[MAXSTR], trim_flg[MAXSTR],
                   wrefshape[MAXSTR],alt_grd[MAXSTR];


/* LOAD AND INITIALIZE PARAMETERS */
   iphase = (int) (phase + 0.5);
   satdly = getval("satdly");
   satpwr = getval("satpwr");
   satfrq = getval("satfrq");
   getstr("sspul", sspul);
   getstr("satmode", satmode);
   getstr("T_flg", T_flg);
   getstr("wrefshape", wrefshape);
   getstr("alt_grd",alt_grd);
   getstr("trim_flg", trim_flg);
   rof1 = getval("rof1"); if(rof1 > 2.0e-6) rof1=2.0e-6;

/* CALCULATE PHASES AND INITIALIZE LOOP COUNTER FOR MIXING TIME */
   settable(t1,8,phi1);
   settable(t2,8,phi2);
   settable(t3,8,phi3);
   settable(t4,8,phi4);
   settable(t5,8,phi5);
   settable(t6,8,phi6);
   settable(t7,8,phi7);
   getelem(t1,ct,v1);
   getelem(t7,ct,v7);
   assign(v1,oph);	
   if (iphase == 2)
    {
      incr(v7);
      incr(v1);			/* BC2D hypercomplex method */
    }

/* FOR HYPERCOMPLEX, USE REDFIED TRICK TO MOVE AXIALS TO EDGE */  
   initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v9); /* moves axials */
   if ((iphase==2)||(iphase==1)) {add(v1,v9,v1); add(v7,v9,v7); add(oph,v9,oph);}

   if (alt_grd[0] == 'y') mod2(ct,v6);
               /* alternate gradient sign on every 2nd transient */

    /* CALCULATE SPIN>LOCK POWER AND PULSE WIDTHS        */

    slpw90 = 1/(4.0 * strength) ;     /* spinlock field strength  */
  /*  slpw1 = slpw90/90.0; */
    slpwra = tpwr - 20.0*log10(slpw90/(compH*pw));
    slpwr = (int) (slpwra + 0.5);
    corfact = exp((slpwr-slpwra)*2.302585/20);
    if (corfact < 1.00) { slpwr=slpwr+1; corfact=corfact*1.12202; }

   cycles = mix / (16.0 * (4e-6 + 2.0*slpw90));
   initval(cycles, v10);	/* mixing time cycles */

/* BEGIN ACTUAL PULSE SEQUENCE */
   status(C);
   obspower(tpwr); obspwrf(4095.0);
   if (sspul[A] == 'y')
   {
     zgradpulse(gzlvl1,gt1);
     delay(5.0e-5);
     rgpulse(pw,zero,rof1,rof1);
     zgradpulse(gzlvl1,gt1); 
     delay(5.0e-5);
   }
   status(A);
   if (satmode[A] == 'y') 
    {
    if (d1 > satdly) delay(d1-satdly);
    if (tof != satfrq) obsoffset(satfrq);
    obspower(satpwr);
    rgpulse(satdly,zero,rof1,rof1);
    obspower(tpwr);
    if (tof != satfrq) obsoffset(tof);
    }
    else delay(d1);
   status(B);
   obsstepsize(45.0);
   initval(7.0,v4);  
   xmtrphase(v4);
   rgpulse(pw,v1,rof1,1.0e-6);
   if (trim_flg[0] == 'y')
        { obspower(trimpwr);
          rgpulse(trim,v7,rof1,rof1);
          obspower(tpwr);
        }
   xmtrphase(zero);   
   if (T_flg[0] == 'n')
        d2corr = rof1 + 1.0e-6 + (2*pw/3.1416) + SAPS_DELAY;
   else
        d2corr = rof1 + 1.0e-6 + (4*pw/3.1416) + SAPS_DELAY;
   if (d2 > d2corr) delay(d2 - d2corr); else delay(0.0);
   if ((T_flg[0] == 'y')&&(cycles > 1.5))
    {
      rgpulse(pw,t4,rof1,rof1);
      obspower(slpwr); obspwrf(4095.0/corfact);
      {
         starthardloop(v10);
            rgpulse(2.0*slpw90,t2,4e-6,0.0);
            rgpulse(2.0*slpw90,t3,4e-6,0.0);
            rgpulse(2.0*slpw90,t2,4e-6,0.0);
            rgpulse(2.0*slpw90,t3,4e-6,0.0);
            rgpulse(2.0*slpw90,t2,4e-6,0.0);
            rgpulse(2.0*slpw90,t3,4e-6,0.0);
            rgpulse(2.0*slpw90,t2,4e-6,0.0);
            rgpulse(2.0*slpw90,t3,4e-6,0.0);
            rgpulse(2.0*slpw90,t2,4e-6,0.0);
            rgpulse(2.0*slpw90,t3,4e-6,0.0);
            rgpulse(2.0*slpw90,t2,4e-6,0.0);
            rgpulse(2.0*slpw90,t3,4e-6,0.0);
            rgpulse(2.0*slpw90,t2,4e-6,0.0);
            rgpulse(2.0*slpw90,t3,4e-6,0.0);
            rgpulse(2.0*slpw90,t2,4e-6,0.0);
            rgpulse(2.0*slpw90,t3,4e-6,0.0);
         endhardloop();
      }
      obspower(tpwr); obspwrf(4095.0);
      rgpulse(pw,t5,rof1,rof1); 
    }  
/* The ROESY spin-lock unit is executed sixteen times within the
   hardware loop so that it is of sufficient duration to allow
   the acquisition hardware loop to be loaded in behind it on
   the last pass through the spin-lock loop. */

   else
    {
      obspower(slpwr); obspwrf(4095.0/corfact);
      rgpulse(mix,t2,rof1,rof1);        /* cw spin lock  */
      obspower(tpwr); obspwrf(4095.0);
    }
/* DPFGSE solvent suppression  */
         ifzero(v6); zgradpulse(gzlvl2,gt2);
              elsenz(v6); zgradpulse(-1.0*gzlvl2,gt2); endif(v6);
     obspower(wrefpwr+6); obspwrf(wrefpwrf);
     delay(gstab);
     shaped_pulse(wrefshape,wrefpw,t5,rof1,rof1);
     obspower(tpwr); obspwrf(4095.0);
     rgpulse(2.0*pw,t6,rof1,rof1);
         ifzero(v6); zgradpulse(gzlvl2,gt2);
              elsenz(v6); zgradpulse(-1.0*gzlvl2,gt2); endif(v6);
     obspower(wrefpwr+6); obspwrf(wrefpwrf);
     delay(gstab);
         ifzero(v6); zgradpulse(1.2*gzlvl2,gt2);
              elsenz(v6); zgradpulse(-1.2*gzlvl2,gt2); endif(v6);
     delay(gstab);
     shaped_pulse(wrefshape,wrefpw,t5,rof1,rof1);
     obspower(tpwr); obspwrf(4095.0);
     rgpulse(2.0*pw,t6,rof1,rof2);
         ifzero(v6); zgradpulse(1.2*gzlvl2,gt2);
              elsenz(v6); zgradpulse(-1.2*gzlvl2,gt2); endif(v6);
     delay(gstab);
   status(C);
}
Example #26
0
pulsesequence()
{
   char            sspul[MAXSTR];

   double         pwClvl=getval("pwClvl");
/* LOAD VARIABLES AND CHECK CONDITIONS */
   getstr("sspul", sspul);

/* STEADY-STATE PHASECYCLING */
/* This section determines if the phase calculations trigger off of (SS - SSCTR)
   or off of CT */

   ifzero(ssctr);
      hlv(ct, v4);
      mod4(ct, v3);
   elsenz(ssctr);
      sub(ssval, ssctr, v12);	/* v12 = 0,...,ss-1 */
      hlv(v12, v4);
      mod4(v12, v3);
   endif(ssctr);


/* CALCULATE PHASECYCLE */
/* The phasecycle first performs a 4-step cycle on the third pulse in order
   to select for DQC.  Second, the 2-step QIS cycle is added in.  Third, a
   2-step cycle for axial peak suppression is performed on the second pulse.
   Fourth, a 2-step cycle for axial peak suppression is performed on the
   first pulse.  If P-type peaks only are being selected, the 2-step cycle
   for P-type peak selection is performed on the first pulse immediately
   after the 4-step cycle on the third pulse. */

   hlv(v4, v4);
   if (phase1 == 0)
   {
      assign(v4, v6);
      hlv(v4, v4);
      mod2(v6, v6);		/* v6 = P-type peak selection in w1 */
   }
   hlv(v4, v2);
   mod4(v4, v4);		/* v4 = quadrature image suppression */
   hlv(v2, v1);
   mod2(v1, v1);
   dbl(v1, v1);
   mod2(v2, v2);
   dbl(v2, v2);
   dbl(v3, v5);
   add(v3, v5, v5);
   add(v1, v5, v5);
   add(v2, v5, v5);
   add(v4, v5, v5);
   add(v4, v1, v1);
   add(v4, v2, v2);
   add(v4, v3, v3);
   if (phase1 == 0)
   {
      add(v6, v1, v1);
      add(v6, v5, v5);
   }
   if (phase1 == 2)
      incr(v1);
   if (phase1 == 3)
      add(id2, v1, v1);		/* adds TPPI increment to the phase of the
				 * first pulse */
   assign(v5, oph);

  /* FOR HYPERCOMPLEX, USE STATES-TPPI TO MOVE AXIALS TO EDGE */  
   if ((phase1==2)||(phase1==1))
   {
      initval(2.0*(double)(d2_index%2),v9);  /* moves axials */
      add(v1,v9,v1); add(oph,v9,oph);
   }

/* BEGIN ACTUAL PULSE SEQUENCE CODE */
   status(A);
   if (sspul[0] == 'y')
   {
      obspower(pwClvl-12);
      rgpulse(200*pw, one, 10.0e-6, 0.0e-6);
      rgpulse(200*pw, zero, 0.0e-6, 1.0e-6);
      obspower(pwClvl);
   }
   delay(d1);
   status(B);
   rgpulse(pw, v1, rof1, 1.0e-6);
   if (d2>0.0)
      delay(d2 - rof1 - 1.0e-6 -(4*pw)/3.1416);
   rgpulse(pw, v2, rof1, 0.0);
   rgpulse(pw, v3, 1.0e-6, rof2);
   add(v3,one,v8);
   delay(d3);
   rgpulse(2.0*pw,v8,rof1,rof1);
   delay(d3);
   status(C);
}
Example #27
0
pulsesequence()
{   
   int	phase1 = (int)(getval("phase")+0.5),
  	prgcycle=(int)(getval("prgcycle")+0.5);


  assign(ct,v17);
  assign(zero,v18);
  assign(zero,v19);

  if (getflag("prgflg") && (satmode[0] == 'y') && (prgcycle > 1.5))
    {
        hlv(ct,v17);
        mod2(ct,v18); dbl(v18,v18);
        if (prgcycle > 2.5)
           {
                hlv(v17,v17);
                hlv(ct,v19); mod2(v19,v19); dbl(v19,v19);
           }
     }

/* CONSTANTS FOR PHASE CALCULATIONS */
    initval( 8.0,v13);
    initval( 32.0,v12);
    initval( 20.0,v11);
    initval( 192.0,v10);

/* CALCULATE PHASECYCLE */
   assign(zero,v14);	/* phase of first pulse */
   mod2(v17,v1);
   dbl(v1,v1);		/* 0202 */
			/* even/odd flag */
   hlv(v17,v2);
   hlv(v2,v3);
   dbl(v3,v3);		/* 0000222244446666 */
			/* phase for transients 3 + 4*n */
			/* 1+4*n = 0 */
   mod2(v2,v2);		/* 0011 */
			/* switch for pairs */
   assign(v13,v4);	/* 8 */
   ifzero(v2);
      incr(v4);
   elsenz(v2);
      decr(v4);
   endif(v2);
   modn(v4,v13,v4);	/* 1177 */
			/* standard phases for even transients */
			/*      1 for 2+4*n, 7 for 4*n         */
   hlv(v13,v8);		/* 4 */
   add(v17,v8,v5);	/* (ct+4) */
   divn(v5,v12,v5);	/* (ct+4)/32 */
   divn(v17,v12,v6);	/* ct/32 */
   sub(v5,v6,v5);	/* ((ct+4)/32-ct/32 */
			/* 00000000 00000000 00000000 00001111 */
   add(v17,v11,v6);	/* (ct+20) */
   divn(v6,v10,v6);	/* (ct+20)/192 */
   sub(v11,v7,v7);	/* 16 */
   add(v17,v7,v7);	/* (ct+16) */
   divn(v7,v10,v7);	/* (ct+16)/192 */
   add(v5,v6,v5);
   sub(v5,v7,v5);	/* ((ct+4)/32-ct/32)+((ct+20)/192-(ct+16)/192) */
                        /* flag for exceptions on even transients */
   dbl(v2,v6);		/* 0022 */
   add(v6,three,v6);	/* 3355 */
   ifzero(v1);		/* for odd transients */
      ifzero(v2);       /* 1+4n:                             */
         assign(zero,v3);             /* 0xxx 0xxx 0xxx 0xxx */
      endif(v2);        /* 3+4n:         xx0x xx2x xx4x xx6x */
   elsenz(v1);		/* for even transients */
      ifzero(v5);	/* normal case:        */
         assign(v4,v3); /*                x1x7 */
      elsenz(v5);	/* exceptions:         */
         assign(v6,v3); /*                x3x5 */
      endif(v5);	/* v3 = phase of first and second pulse */
			/*      in 45 degrees steps:            */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470365 01070127 01470365  */
   endif(v1);
   assign(two,v4);	/* v4 = phase of last 90 degrees pulse */
   assign(v1,oph);	/* oph = 0202 */

   assign(zero,v20);
  if (getflag("prgflg") && (satmode[0] == 'y'))
        assign(v14,v20);
  add(oph,v18,oph);
  add(oph,v19,oph);

   if (phase1 == 2) 
	incr(v14); /* States - Habercorn */

/*
      mod2(id2,v9);
      dbl(v9,v9);
*/
	initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v9);

      add(v14,v9,v14);
      add(oph,v9,oph);
 
/* BEGIN ACTUAL PULSE SEQUENCE CODE */
   status(A);

   obsstepsize(45.0);
   delay(5.0e-5);
   if (getflag("sspul"))
        steadystate();

   if (satmode[0] == 'y')
     {
        if ((d1-satdly) > 0.02)
                delay(d1-satdly);
        else
                delay(0.02);
        if (getflag("slpsat"))
           {
		if (getflag("prgflg"))
			xmtrphase(v3);
                shaped_satpulse("relaxD",satdly,v20);
                if (getflag("prgflg"))
		{
                   shaped_purge(v14,v20,v18,v19);
		   xmtrphase(zero);
		}
           }
        else
           {
                if (getflag("prgflg"))
			xmtrphase(v3);
                satpulse(satdly,v20,rof1,rof1);
                if (getflag("prgflg"))
		{
                   purge(v14,v20,v18,v19);
		   xmtrphase(zero);
		}
           }
     }
   else
        delay(d1);

   if (getflag("wet"))
     wet4(zero,one);

   status(B);
      xmtrphase(v3);
      rgpulse(pw, v14, rof1, 2.0e-6);
      if (d2 > 0.0)
         delay(d2 - (4.0*pw/PI) - 4.0e-6);
      else
	delay(d2);
      rgpulse(pw, zero, 2.0e-6, rof1);
      xmtrphase(zero);
      rgpulse(pw, v4, rof1, rof2);
   status(C);
} 
Example #28
0
void pulsesequence()
{
  double   tpwr180r = getval("tpwr180r"),
           pw180r = getval("pw180r"),
	   pwx180 = getval("dnbippw"),
	   pwxlvl180 = getval("dnbippwr"),
           pp = getval("pp"),
           pplvl = getval("pplvl"),
	   tauC = getval("tauC"),
	   tau;
  int      prgcycle=(int)(getval("prgcycle")+0.5);
  char     pw180ref[MAXSTR],
	   dnbipshp[MAXSTR],
	   bipflg[MAXSTR];

  getstr("pw180ref", pw180ref);
  getstr("dnbipshp", dnbipshp);
  getstr("bipflg",bipflg);
  tau    = 1.0 / (2.0 * (getval("j1xh")));

  assign(ct,v17);
  assign(zero,v18);
  assign(zero,v19);

  if (getflag("prgflg") && getflag("satmode") && (prgcycle > 1.5))
    {
        hlv(ct,v17);
        mod2(ct,v18); dbl(v18,v18);
        if (prgcycle > 2.5)
           {
                hlv(v17,v17);
                hlv(ct,v19); mod2(v19,v19); dbl(v19,v19);
           }
     }

  settable(t1,4,phs1);
  settable(t2,8,phs2);
  settable(t3,4,phs3);
  getelem(t1,v17,v1);
  getelem(t2,v17,v2);
  getelem(t3,v17,v3);
  assign(v1,oph);
  add(oph,v18,oph);
  add(oph,v19,oph);

  if (getflag("prgflg") && getflag("satmode"))
        assign(v3,v2);

   /* equilibrium period */
   status(A);

   delay(5.0e-5);
   if (getflag("sspul"))
        steadystate();

   if (getflag("satmode"))
     {
        if ((d1-satdly) > 0.02)
                delay(d1-satdly);
        else
                delay(0.02);
        if (getflag("slpsat"))
           {
                shaped_satpulse("relaxD",satdly,v2);
                if (getflag("prgflg"))
                   shaped_purge(v1,v2,v18,v19);
           }
        else
           {
                satpulse(satdly,v2,rof1,rof1);
                if (getflag("prgflg"))
                   purge(v1,v2,v18,v19);
           }
     }
   else
	delay(d1);

   if (getflag("wet"))
     wet4(zero,one);

   status(B);

	obspower(tpwr);
	if (bipflg[1] == 'y')
	    decpower(pwxlvl180);
	else
	    decpower(pplvl);

        rgpulse(pw,v1,rof1,rof1);
	if (bipflg[1] == 'y')
	    { 
		decshaped_pulse(dnbipshp,pwx180,zero,2.0e-6,2.0e-6);
		delay(tau+tauC);
	    }
	else
	    {
	    	decrgpulse(2*pp,zero,2.0e-6,2.0e-6);
		delay(tau);
	    }
	obspower(tpwr180r);
	shaped_pulse(pw180ref,pw180r,v1,rof1,rof1);
        if (bipflg[1] == 'y')
            { 
                decshaped_pulse(dnbipshp,pwx180,zero,2.0e-6,2.0e-6);
                delay(tau+tauC);
            }
        else
            {
                decrgpulse(2*pp,zero,2.0e-6,2.0e-6);
                delay(tau);
            }

        shaped_pulse(pw180ref,pw180r,v1,rof1,rof2);
	decpower(dpwr);
	obspower(tpwr);

   status(C);
}
Example #29
0
pulsesequence()

{
   double   hsglvl = getval("hsglvl"),
            hsgt = getval("hsgt"),
            tau,
            evolcorr,
	    taug,
	    mult = getval("mult"),
	    null = getval("null");
   int	    phase1 = (int)(getval("phase")+0.5),
            prgcycle = (int)(getval("prgcycle")+0.5),
	    ZZgsign;

   tau  = 1/(4*(getval("j1xh")));
   if (mult > 0.5)
    taug = 2*tau;
   else
    taug = 0.0;
   evolcorr=2*pw+4.0e-6;
   ZZgsign=-1;
   if (mult == 2) ZZgsign=1;

  assign(ct,v17);
  assign(zero,v18);
  assign(zero,v19);

  if (getflag("prgflg") && (satmode[0] == 'y') && (prgcycle > 1.5))
    {
        hlv(ct,v17);
        mod2(ct,v18); dbl(v18,v18);
        if (prgcycle > 2.5)
           {
                hlv(v17,v17);
                hlv(ct,v19); mod2(v19,v19); dbl(v19,v19);
           }
     }

   settable(t1,4,ph1);
   settable(t2,2,ph2);
   settable(t3,8,ph3);
   settable(t4,16,ph4);
   settable(t5,16,ph5);

  getelem(t1, v17, v1);
  getelem(t3, v17, v3);
  getelem(t4, v17, v4);
  getelem(t2, v17, v2);
  getelem(t5, v17, oph);

  assign(zero,v6);
  add(oph,v18,oph);
  add(oph,v19,oph);

/*
   mod2(id2,v14);
   dbl(v14,v14);
*/
  initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v14);

   if (phase1 == 2)
     incr(v2);

   add(v2,v14,v2);
   add(oph,v14,oph);

   if (mult > 0.5) 
	add(oph,two,oph);

   status(A);
   obspower(tpwr);

   delay(5.0e-5);
   if (getflag("sspul"))
        steadystate();

   if (satmode[0] == 'y')
     {
        if ((d1-satdly) > 0.02)
                delay(d1-satdly);
        else
                delay(0.02);
        if (getflag("slpsat"))
           {
                shaped_satpulse("relaxD",satdly,zero);
                if (getflag("prgflg"))
                   shaped_purge(v6,zero,v18,v19);
           }
        else
           {
                satpulse(satdly,zero,rof1,rof1);
                if (getflag("prgflg"))
                   purge(v6,zero,v18,v19);
           }
     }
   else
        delay(d1);

   if (getflag("wet"))
     wet4(zero,one);

   decpower(pwxlvl);

    status(B);

    if ((getflag("PFGflg")) && (getflag("nullflg")))
     {
        rgpulse(0.5*pw,zero,rof1,rof1);
        delay(2*tau);
        simpulse(2.0*pw,2.0*pwx,zero,zero,rof1,rof1);
        delay(2*tau);
        rgpulse(1.5*pw,two,rof1,rof1);
        zgradpulse(hsglvl,hsgt);
        delay(1e-3);
     } 
     else if (null != 0.0)
     {
        rgpulse(pw,zero,rof1,rof1);
        delay(2*tau);
        simpulse(2*pw,2*pwx,zero,zero,rof1,rof1);
        delay(2*tau);
        rgpulse(pw,two,rof1,rof1);
        if (satmode[1] == 'y')
	{
           if (getflag("slpsat"))
                shaped_satpulse("BIRDnull",null,zero);
           else
                satpulse(null,zero,rof1,rof1);
	}
	else
           delay(null);
      }

     rgpulse(pw,v6,rof1,rof1);
     delay(tau);
     simpulse(2*pw,2*pwx,zero,zero,rof1,rof1);
     delay(tau);
     rgpulse(pw,v1,rof1,rof1);
     if (getflag("PFGflg"))
     {
	zgradpulse(hsglvl,2*hsgt);
	delay(1e-3);
     }
     decrgpulse(pwx,v2,rof1,2.0e-6);

     if (mult > 0.5)
     {
	delay(d2/2);
	rgpulse(2*pw,zero,2.0e-6,2.0e-6);
	delay(d2/2);
     delay(taug);
     simpulse(mult*pw,2*pwx,zero,zero,rof1,rof1);
     delay(taug + evolcorr);
     }
     else
     {
     if (d2/2 > 0.0)
      delay(d2/2 - (2*pwx/PI) - pw - 4.0e-6);
     else
      delay(d2/2);
     rgpulse(2*pw,zero,2.0e-6,2.0e-6);
     if (d2/2 > 0.0)
      delay(d2/2 - (2*pwx/PI) - pw - 4.0e-6);
     else
      delay(d2/2);
     }

     decrgpulse(pwx,v4,2.0e-6,rof1);
     if (getflag("PFGflg"))
     {
	zgradpulse(ZZgsign*0.6*hsglvl,1.2*hsgt);
	delay(1e-3);
     }
     rgpulse(pw,v3,rof1,rof1);
     delay(tau - (2*pw/PI) - 2*rof1);
     simpulse(2*pw,2*pwx,zero,zero,rof1, rof2);
     decpower(dpwr);
     delay(tau - POWER_DELAY);
   status(C);
}
Example #30
0
pulsesequence()

{

   double   gzlvlE = getval("gzlvlE"),
            gtE = getval("gtE"),
            EDratio = getval("EDratio"),
            gstab = getval("gstab"),
            mult = getval("mult"),
	    pwx180 = getval("pwx180"),
	    pwxlvl180 = getval("pwxlvl180"),
	    pwx180r = getval("pwx180r"),
	    pwxlvl180r = getval("pwxlvl180r"),
            tpwr180 = getval("tpwr180"),
            pw180 = getval("pw180"),
            hsglvl = getval("hsglvl"),
            hsgt = getval("hsgt"),
            gzlvl5 = getval("gzlvl5"),
            tau,
            taug;
   int      icosel,
	    phase1 = (int)(getval("phase")+0.5),
            prgcycle = (int)(getval("prgcycle")+0.5),
	    ZZgsign;
   char	    pwx180ad[MAXSTR],
	    pwx180ref[MAXSTR],
	    bipflg[MAXSTR],
	    pw180ad[MAXSTR];

//synchronize gradients to srate for probetype='nano'
//   Preserve gradient "area"
        gtE = syncGradTime("gtE","gzlvlE",0.5);
        gzlvlE = syncGradLvl("gtE","gzlvlE",0.5);

  getstr("pwx180ad", pwx180ad);
  getstr("pwx180ref", pwx180ref);
  getstr("pw180ad", pw180ad);
  getstr("bipflg",bipflg);
  if (bipflg[0] == 'y')
  {
        tpwr180=getval("tnbippwr");
        pw180=getval("tnbippw");
        getstr("tnbipshp",pw180ad);
  }
  if (bipflg[1] == 'y')
  {
        pwxlvl180=getval("dnbippwr");
        pwx180=getval("dnbippw");
        getstr("dnbipshp",pwx180ad);
  }

  tau = 1 / (4*(getval("j1xh")));

  if (mult > 0.5)
    taug = 2*tau + getval("tauC");
  else
    taug = gtE + gstab + 2 * GRADIENT_DELAY;
  ZZgsign=-1; 
  if (mult == 2) ZZgsign=1;
  icosel = 1;
 
  assign(ct,v17);
  assign(zero,v18);
  assign(zero,v19);

  if (getflag("prgflg") && (satmode[0] == 'y') && (prgcycle > 1.5))
    {
        hlv(ct,v17);
        mod2(ct,v18); dbl(v18,v18);
        if (prgcycle > 2.5)
           {
                hlv(v17,v17);
                hlv(ct,v19); mod2(v19,v19); dbl(v19,v19);
           }
     }

  settable(t1, 4, ph1);
  settable(t2, 2, ph2);
  settable(t3, 8, ph3);
  settable(t4, 16, ph4);
  settable(t5, 16, ph5);

  getelem(t1, v17, v1);
  getelem(t3, v17, v3);
  getelem(t4, v17, v4);
  getelem(t2, v17, v2);
  getelem(t5, v17, oph);

  assign(zero,v6);
  add(oph,v18,oph);
  add(oph,v19,oph);

  if ((phase1 == 2) || (phase1 == 5))
    icosel = -1;

  initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v14);
/*
  mod2(id2, v14);
  dbl(v14,v14);
*/
  add(v2, v14, v2);
  add(oph, v14, oph);

status(A);
   obspower(tpwr);

   delay(5.0e-5);
   if (getflag("sspul"))
        steadystate();

   if (satmode[0] == 'y')
     {
        if ((d1-satdly) > 0.02)
                delay(d1-satdly);
        else
                delay(0.02);
        if (getflag("slpsat"))
           {
                shaped_satpulse("relaxD",satdly,zero);
                if (getflag("prgflg"))
                   shaped_purge(v6,zero,v18,v19);
           }
        else
           {
                satpulse(satdly,zero,rof1,rof1);
                if (getflag("prgflg"))
                   purge(v6,zero,v18,v19);
           }
     }
   else
        delay(d1);

   if (getflag("wet"))
     wet4(zero,one);

   obspower(tpwr);
   decpower(pwxlvl180);

  status(B);

    if (getflag("nullflg"))
    {
      rgpulse(0.5 * pw, zero, rof1, rof1);
      obspower(tpwr180);
      delay(tau);
      simshaped_pulse(pw180ad,pwx180ad,pw180,pwx180,zero,zero,rof1,rof1);
      delay(tau+POWER_DELAY+rof1);
      delay(tau+POWER_DELAY+rof1);
      simshaped_pulse(pw180ad,pwx180ad,pw180,pwx180,zero,zero,rof1,rof1);
      obspower(tpwr);
      delay(tau);
      rgpulse(0.5 * pw, zero, rof1, rof1);
      zgradpulse(hsglvl, hsgt);
      delay(1e-3);
    }

    rgpulse(pw, v6, rof1, rof1);
    obspower(tpwr180);
    shaped_pulse(pw180ad,pw180,zero,rof1,rof1);
    delay(tau+2.0*POWER_DELAY+2.0*rof1);
    simshaped_pulse(pw180ad,pwx180ad,pw180,pwx180,zero,zero,rof1,rof1);
    delay(tau);
    obspower(tpwr);
    rgpulse(pw, v1, rof1, rof1);
    zgradpulse(hsglvl, 2 * hsgt);
    decpower(pwxlvl);
    obspower(tpwr180);
    delay(1e-3);
    decrgpulse(pwx, v2, rof1, 2.0e-6);

    delay(d2 / 2);
    shaped_pulse(pw180ad,pw180,zero,rof1,rof1);
    delay(d2 / 2);

    delay(taug - POWER_DELAY);
    decpower(pwxlvl180r);
    decshaped_pulse(pwx180ref, pwx180r, zero, rof1, rof1);

    if(mult < 1.5)
      {
       obspower(tpwr);
       if (mult <0.5)
         delay(2*rof1);
       else
         rgpulse(mult*pw,zero,rof1,rof1);
      }
    else
      shaped_pulse(pw180ad,pw180,zero,rof1,rof1);

    if(mult < 1.5)
      delay(4*pwx/PI + 4.0e-6 + taug - gtE - gstab - 2 * GRADIENT_DELAY + WFG_START_DELAY + pw180 + WFG_STOP_DELAY - mult*pw);
    else
      delay(4*pwx/PI + 4.0e-6 + POWER_DELAY + taug  - gtE - gstab - 2 * GRADIENT_DELAY);

    zgradpulse(gzlvlE, gtE);
    delay(gstab);
    decshaped_pulse(pwx180ref, pwx180r, zero, rof1, rof1);
    decpower(pwxlvl);

    decrgpulse(pwx, v4, 2.0e-6, rof1);
    obspower(tpwr);
    decpower(pwxlvl180);
    zgradpulse(ZZgsign*0.6 * hsglvl, 1.2 * hsgt);
    delay(1e-3);

    rgpulse(pw, v3, rof1, rof1);
    obspower(tpwr180);
    shaped_pulse(pw180ad,pw180,zero,rof1,rof1);
    zgradpulse(gzlvl5,gtE/2.0);
    delay(tau-gtE/2.0+2.0*POWER_DELAY);
    simshaped_pulse(pw180ad,pwx180ad,pw180,pwx180,zero,zero,rof1,rof2);
    zgradpulse(gzlvl5+icosel * 2.0*gzlvlE/EDratio, gtE/2.0);
    delay(tau-gtE/2.0);
    decpower(dpwr);

  status(C);
}