void rgradient(char axis, double value)
{
   if (value == 0.0)
      rgradientCodes(axis, value);
   else if (gradalt == 1.0)
      rgradientCodes(axis, value);
   else
   {
      ifmod2zero(ct);
         rgradientCodes(axis, value);
      elsenz(ct);
         rgradientCodes(axis, gradalt * value);
      endif(ct);
   }
}
Example #2
0
pulsesequence()
{
   initval(nt,v1);
   sub(v1,ct,v2);
    sub(v2,one,v2);
   /* equilibrium period */
   status(A);
   ifzero(ssctr);
      aux1on();
   endif(ssctr);
   hsdelay(d1);

   /* --- tau delay --- */
   status(B);
   pulse(p1, zero);
   hsdelay(d2);

   /* --- observe period --- */
   status(C);
   ifzero(v2);
      aux12off();
   endif(v2);
   pulse(pw,oph);
}
Example #3
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 #4
0
static void
directive()
{
	Tok  *t;
	char *dir;

	t = ppnoexpand();
	dir = t->v;
	if(strcmp(dir, "include") == 0)
		include();
	else if(strcmp(dir, "define")  == 0)
		define();
	else if(strcmp(dir, "if")  == 0)
		pif();
	else if(strcmp(dir, "elseif")  == 0)
		elseif();
	else if(strcmp(dir, "else")  == 0)
		pelse();
	else if(strcmp(dir, "endif")  == 0)
		endif();
	else
		errorposf(&t->pos, "invalid directive %s", dir);
}
Example #5
0
pulsesequence()
{
	/* declaration of SGL kernel structures */
	SGL_KERNEL_INFO_T read, phase, slice, ss_pre, ss_post;


	/* declaration of internal variables */
	double freqlist[MAXNSLICE];
	double pe_steps;
	int shapelist1, table;
	double xtime, grad_duration, ror_pad,rod_pad;
	double temp_tr;

	double readAmp, phaseAmp, sliceAmp;
	double tepad, tepad2, temin2, htrmin, delayToRF, delayRFToAcq, delayAcqToRF;
	double rof_pad, delRof;

	double sliceRephTrim, sliceDephTrim;
	double readRephTrim, readDephTrim;

	int rfPhase[2] = {0,2};
	
	/* declaration of realtime variables */
	int  vpe_steps  = v1;
	int  vpe_ctr    = v2;
	int  vms_slices = v3;
	int  vms_ctr    = v4;
	int  vpe_offset = v5;
	int  vpe_index  = v6;
	int  vss        = v7;
	int  vssc       = v8;
	int  vacquire   = v9;
	int  vphase	= v10;
	
	settable(t2,2,rfPhase);

	/* setup phase encoding order */
	table = set_pe_order();

	init_mri();

	if( (sliceRephTrim = getvalnwarn("sliceRephTrim")) == 0.0 ) {
		sliceRephTrim = 1.0;
	}	
	
	if( (sliceDephTrim = getvalnwarn("sliceDephTrim")) == 0.0 ) {
		sliceDephTrim = 1.0;
	}	

	if( (readRephTrim = getvalnwarn("readRephTrim")) == 0.0 ) {
		readRephTrim = 1.0;
	}	
	
	if( (readDephTrim = getvalnwarn("readDephTrim")) == 0.0 ) {
		readDephTrim = 1.0;
	}	

	shape_rf( &p1_rf, "p1", p1pat, p1, flip1, rof1, rof2 );	// excitation pulse

	init_slice( &ss_grad, "ss", thk );					// slice gradient
	init_slice_refocus( &ssr_grad, "ssr" );				// slice refocus
	init_slice_refocus( &ssd_grad, "ssd" );				// slice refocus

	init_readout( &ro_grad, "ro", lro, np, sw );		// read gradient
	init_readout_refocus( &ror_grad, "ror" );			// read dephase
	init_readout_refocus( &rod_grad, "ror" );			// read dephase

	init_phase( &pe_grad, "pe", lpe, nv );				// phase gradient

	ss_grad.maxGrad = gmax * 0.57;
	ssr_grad.maxGrad = gmax * 0.57;
	ssd_grad.maxGrad = gmax * 0.57;
	ro_grad.maxGrad = gmax * 0.57;
	ror_grad.maxGrad = gmax * 0.57;
	rod_grad.maxGrad = gmax * 0.57;
	pe_grad.maxGrad = glimpe < 0.57? gmax*glimpe : gmax * 0.57;

	/* calculate the RF pulses, gradient pulses and their interdependencies */
	calc_rf( &p1_rf, "tpwr1", "tpwr1f" );
	calc_slice( &ss_grad, &p1_rf, NOWRITE, "gss" );

	ssr_grad.amp = ss_grad.amp;	
	ssr_grad.gmult = sliceRephTrim;
	ssr_grad.calcFlag = DURATION_FROM_MOMENT_AMPLITUDE;
	calc_slice_refocus( &ssr_grad, &ss_grad, NOWRITE, "gssr" );
	ssd_grad.amp = ss_grad.amp;	
	ssd_grad.gmult = sliceDephTrim; 
	ssd_grad.calcFlag = DURATION_FROM_MOMENT_AMPLITUDE;
	calc_slice_dephase( &ssd_grad, &ss_grad, NOWRITE, "gssd" ); 
	
	calc_readout( &ro_grad, NOWRITE, "gro", "sw", "at" );

	ror_grad.amp = ro_grad.amp;	
	ror_grad.calcFlag = DURATION_FROM_MOMENT_AMPLITUDE;

	rod_grad.amp = ro_grad.amp;	
	rod_grad.calcFlag = DURATION_FROM_MOMENT_AMPLITUDE;

	ror_grad.gmult = readRephTrim;
	calc_readout_refocus( &ror_grad, &ro_grad, NOWRITE, "gror" );
	rod_grad.gmult = readDephTrim;
	calc_readout_rephase( &rod_grad, &ro_grad, NOWRITE, "grod" );

	calc_phase( &pe_grad, NOWRITE, "gpe", "tpe" );

	/* work out the position of the markers */
	/* markerA */
	/* ss_grad.rfDelayFront indicates the starting point of the
	   RF pulse measured from the start of the slice gradient
       ( rof1:pulse length:rof2 ) */	

	double granulatedRFDelayFront = granularity( ss_grad.rfDelayFront, GRADIENT_RES );
	if( granulatedRFDelayFront > ss_grad.rfDelayFront ) {
		granulatedRFDelayFront -= GRADIENT_RES;
	}

	/* ss_grad.rfDelayBack indicates the end point of the
	   RF pulse measured to the end of the slice gradient
       ( rof1:pulse length:rof2 ) */	

	double granulatedRFDelayBack = granularity( ss_grad.rfDelayBack, GRADIENT_RES );
	if( granulatedRFDelayBack > ss_grad.rfDelayBack ) {
		granulatedRFDelayBack -= GRADIENT_RES;
	}
	
	double granulatedRFDelay = granulatedRFDelayFront < granulatedRFDelayBack ? granulatedRFDelayFront : granulatedRFDelayBack;

	double markerADelay = granulatedRFDelay;

	/* read and phase gradients can overlap the start or end of the slice gradient by max of granulatedRFDElay */

	double granulatedATDelayFront = granularity(ro_grad.atDelayFront, GRADIENT_RES);
	if( granulatedATDelayFront > ro_grad.atDelayFront ) {
		granulatedATDelayFront -= GRADIENT_RES;
	}
	double granulatedATDelayBack = granularity(ro_grad.atDelayBack, GRADIENT_RES);
	if( granulatedATDelayBack > ro_grad.atDelayBack ) {
		granulatedATDelayBack -= GRADIENT_RES;
	}
	double granulatedATDelay = granulatedATDelayFront < granulatedATDelayBack ? granulatedATDelayFront : granulatedATDelayBack;

	/* longest gradient between RF pulse and acquire dominates */

	xtime = ssr_grad.duration + granulatedRFDelay;
	xtime = xtime > ssd_grad.duration + granulatedRFDelay ? xtime : ssd_grad.duration + granulatedRFDelay;
	xtime = xtime > ror_grad.duration + granulatedATDelay ? xtime : ror_grad.duration + granulatedATDelay;
	xtime = xtime > rod_grad.duration + granulatedATDelay ? xtime : rod_grad.duration + granulatedATDelay;
	xtime = xtime > pe_grad.duration ? xtime : pe_grad.duration;

	ror_pad = xtime - ror_grad.duration - granulatedATDelay;
	rod_pad = xtime - rod_grad.duration - granulatedATDelay;

	/* make a gradient list */
	start_kernel( &sk );
	add_gradient( (void*)&ss_grad,  "slice",    	SLICE, START_TIME,	"",         0.0,	PRESERVE );
	add_gradient( (void*)&ssr_grad, "sliceReph", 	SLICE, BEHIND,		"slice",    0.0,	INVERT );
	add_gradient( (void*)&ror_grad, "readDeph", 	READ,  BEHIND,		"slice",   -granulatedRFDelay + ror_pad, INVERT );
	add_gradient( (void*)&ro_grad,  "read",     	READ,  BEHIND,		"readDeph", 0.0,	PRESERVE );	
	add_gradient( (void*)&pe_grad,  "phase",    	PHASE, SAME_START,	"readDeph", 0.0,	PRESERVE );
	add_gradient( (void*)&rod_grad, "readReph", 	READ,  BEHIND,		"read",     0.0,	INVERT );
	add_gradient( (void*)&pe_grad,  "rewind",		PHASE, SAME_END,	"readReph", 0.0, INVERT );
	add_gradient( (void*)&ss_grad,	"nextSlice",	SLICE, BEHIND,		"readReph", rod_pad - granulatedRFDelay, PRESERVE );
	add_gradient( (void*)&ssd_grad,	"sliceDeph",	SLICE, BEFORE,		"nextSlice",    0, INVERT );

	add_marker( "markerA", SAME_START, "slice", granulatedRFDelay );
	add_marker( "markerB", SAME_START, "nextSlice", granulatedRFDelay );

	/* get the minimum echo time */
	temin = get_timing( FROM_RF_CENTER_OF, "slice", TO_ECHO_OF, "read" );
	temin2 = get_timing( FROM_ECHO_OF, "read", TO_RF_CENTER_OF, "nextSlice" );
	
	htrmin = MAX( temin, temin2 );
	
	if( minte[0] == 'y' ){
		te = htrmin;
	}
	
	tepad = granularity( te - temin, GRADIENT_RES );
	tepad2 = granularity( te - temin2, GRADIENT_RES );

	te = temin + tepad;	
	putCmd("setvalue('te', %f, 'current')\n", te );

	if( tepad>0.0 )		change_timing( "readDeph", tepad );
	if( tepad2>0.0 )	change_timing( "nextSlice", tepad2 );

	tr = get_timing( FROM_START_OF, "slice", TO_START_OF, "nextSlice" );
	putvalue("tr", tr );

	delayRFToAcq = get_timing( FROM_RF_PULSE_OF, "slice", TO_ACQ_OF, "read" );
	delayAcqToRF = get_timing( FROM_ACQ_OF, "read", TO_RF_PULSE_OF, "nextSlice" );

	set_comp_info( &ss_pre, "ss_pre" );
	write_comp_grads_snippet( NULL, NULL, &ss_pre, "START_OF_KERNEL", "markerA" );

	set_comp_info( &read, "ro" );
	set_comp_info( &phase, "pe" );
	set_comp_info( &slice, "ss" );
	write_comp_grads_snippet( &read, &phase, &slice, "markerA", "markerB" );

	set_comp_info( &ss_post, "ss_post" );
	write_comp_grads_snippet( NULL, NULL, &ss_post, "markerB", "END_OF_KERNEL" );

	/* Set up frequency offset pulse shape list ********/   	
	offsetlist(pss,ss_grad.ssamp,0,freqlist,ns,seqcon[1]);
	shapelist1 = shapelist(p1_rf.pulseName,ss_grad.rfDuration,freqlist,ns,ss_grad.rfFraction, seqcon[1]);

	/* Set pe_steps for profile or full image **********/   	
	pe_steps = prep_profile(profile[0],nv,&pe_grad,&pe_grad);/* profile[0] is n y or r */
	F_initval(pe_steps/2.0,vpe_offset);

	g_setExpTime(trmean*(ntmean*pe_steps*arraydim + (1+fabs(ssc))*arraydim));

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

	/* PULSE SEQUENCE */
	status( A );
	rotate();
        triggerSelect(trigger);
	obsoffset( resto );
	delay( GRADIENT_RES );
	initval( 1+fabs( ssc ), vss );
	
	obspower( p1_rf.powerCoarse );
	obspwrf( p1_rf.powerFine );
	delay( GRADIENT_RES );

	assign(one,vacquire);         // real-time acquire flag
	setacqvar(vacquire);          // Turn on acquire when vacquire is zero 
					
	obl_shapedgradient(ss_pre.name,ss_pre.dur,0,0,ss_pre.amp,NOWAIT);		
	sp1on();
	delay(GRADIENT_RES);
	sp1off();
	delay(ss_pre.dur-GRADIENT_RES );
	msloop( seqcon[1], ns, vms_slices, vms_ctr );
		
		assign(vss,vssc);

		peloop( seqcon[2], pe_steps, vpe_steps, vpe_ctr );

			sub(vpe_ctr,vssc,vpe_ctr);     // vpe_ctr counts up from -ssc
			assign(zero,vssc);
			if (seqcon[2] == 's')
				assign(zero,vacquire); // Always acquire for non-compressed loop
			else {
				ifzero(vpe_ctr);
				assign(zero,vacquire); // Start acquiring when vpe_ctr reaches zero
				endif(vpe_ctr);
			}
		
			if (table)
				getelem(t1,vpe_ctr,vpe_index);
			else {
				ifzero(vacquire);
					sub(vpe_ctr,vpe_offset,vpe_index);
				elsenz(vacquire);
					sub(zero,vpe_offset,vpe_index);
				endif(vacquire);
			}		
			
			pe_shaped3gradient( read.name, phase.name, slice.name,
								read.dur, read.amp, 0, slice.amp,
								-pe_grad.increment, vpe_index, NOWAIT );
			delay(ss_grad.rfDelayFront - granulatedRFDelay);
			shapedpulselist( shapelist1, ss_grad.rfDuration, oph, rof1, rof2, seqcon[1], vms_ctr );

			delay( delayRFToAcq - alfa );
			startacq(alfa);
			acquire( np, 1/ro_grad.bandwidth );
			endacq();
			delay( delayAcqToRF - ss_grad.rfDelayFront + granulatedRFDelay - GRADIENT_RES );
			sp1on();
			delay(GRADIENT_RES);
			sp1off();
			
		endpeloop( seqcon[2], vpe_ctr ); 

	endmsloop( seqcon[1], vms_ctr );

	obl_shapedgradient(ss_post.name,ss_post.dur,0,0,ss_post.amp,WAIT);
}
Example #6
0
void pulsesequence() 
{ 
  double gzlvl1 = getval("gzlvl1"),
	 gt1 = getval("gt1"), 
         gzlvlE = getval("gzlvlE"),
         gtE = getval("gtE"),
         EDratio = getval("EDratio"),
         gzlvl_max = getval("gzlvl_max"),
         del = getval("del"),
         dosyfrq=getval("sfrq"),
         gstab = getval("gstab"),
         gzlvlhs = getval("gzlvlhs"),
         hsgt = getval("hsgt"),
         gtau,tauc,gt4,gzlvl4,Ddelta,dosytimecubed; 
  char   convcomp[MAXSTR],sspul[MAXSTR],lkgate_flg[MAXSTR],satmode[MAXSTR],
         alt_grd[MAXSTR],arraystring[MAXSTR]; 
  int    iphase, icosel;
 
//synchronize gradients to srate for probetype='nano'
//   Preserve gradient "area"
        gt1 = syncGradTime("gt1","gzlvl1",1.0);
        gzlvl1 = syncGradLvl("gt1","gzlvl1",1.0);
        gtE = syncGradTime("gtE","gzlvlE",1.0);
        gzlvlE = syncGradLvl("gtE","gzlvlE",1.0);

  getstr("sspul",sspul); 
  getstr("convcomp",convcomp); 
  getstr("satmode",satmode);
  getstr("lkgate_flg",lkgate_flg); 
  getstr("alt_grd",alt_grd);
  getstr("array",arraystring);
  iphase = (int)(getval("phase")+0.5); 
  icosel = 1; 
  tau = 1/(2*(getval("jnxh"))); 
  gtau =  2*gstab + GRADIENT_DELAY; 
  tauc = gtau+gtE-gstab; 
  if (strcmp(arraystring,"gzlvl1,phase")!=0)
       fprintf(stdout,"Warning:  array should be 'gzlvl1,phase' for this experiment");
Ddelta=gt1;             /* the diffusion-encoding pulse width is gt1 */ 
if (convcomp[0] == 'y') dosytimecubed=2.0*Ddelta*Ddelta*(del-2.0*(Ddelta/3.0));
else dosytimecubed=2.0*Ddelta*Ddelta*(del-(Ddelta/3.0)); 
putCmd("makedosyparams(%e,%e)\n",dosytimecubed,dosyfrq); 
if (ni>1) putCmd("dosy3Dproc=\'y\'\n");
else putCmd("dosy3Dproc=\'n\'");
 
  if (tau < (gtE+gstab)) 
  { 
    abort_message("0.5/jnxh must be greater than gtE+gstab"); 
  } 
 
  if (tau < (1.0*(gt1+gstab)+del)) 
  { 
    abort_message("0.5/jnxh must be greater than del+gt1+gstab"); 
  } 
  settable(t1,2,ph1); 
  settable(t2,4,ph2); 
  settable(t3,4,ph3); 
 
  assign(zero,v4); 
  getelem(t1,ct,v1); 
  getelem(t3,ct,oph); 
 
  if (iphase == 2)  icosel = -1;
 
  initval(2.0*(double)((int)(d2*getval("sw1")+0.5)%2),v11);  
  add(v1,v11,v1); 
  add(v4,v11,v4); 
  add(oph,v11,oph); 
 
   mod2(ct,v10);        /* gradients change sign at odd transients */

 status(A); 
     decpower(pwxlvl); 
     if (sspul[0] == 'y') 
     { 
         zgradpulse(gzlvlhs,hsgt);
         rgpulse(pw,zero,rof1,rof1);
         zgradpulse(gzlvlhs,hsgt);
     } 
 
  if (lkgate_flg[0]=='y') lk_sample();  /* turn lock sampling on */
 
	if (convcomp[0]=='y') 
		gt4=gt1*2.0; 
	else 
		gt4=gt1; 

	gzlvl4=sqrt(gzlvl_max*gzlvl_max-gzlvl1*gzlvl1); 
 
         if (satmode[0] == 'y')
          {
            if (d1 - satdly > 0) delay(d1 - satdly);
            obspower(satpwr);
            rgpulse(satdly,zero,rof1,rof1);
            obspower(tpwr);
          }
         else
         {  delay(d1); }

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

  if (lkgate_flg[0]=='y') lk_hold();   /* turn lock sampling off */
 
 status(B); 
         if (alt_grd[0] == 'y')
         {  ifzero(v10);
               zgradpulse(gzlvl4,gt4);
            elsenz(v10);
               zgradpulse(-1.0*gzlvl4,gt4);
            endif(v10);
         }
         else zgradpulse(gzlvl4,gt4);
	delay(gstab); 
         if (alt_grd[0] == 'y')
         {  ifzero(v10);
               zgradpulse(-1.0*gzlvl4,gt4);
            elsenz(v10);
               zgradpulse(gzlvl4,gt4);
            endif(v10);
         }
         else zgradpulse(-1.0*gzlvl4,gt4);
	delay(gstab); 
     rgpulse(pw,zero,rof1,1.0e-6); 
	if (convcomp[0]=='y') 
	{ 
		delay((tau - 1.0e-6 - (2*pw/PI)-del-2.333*gt1-2.0*gstab)/2.0); 
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(-1.0*gzlvl1,gt1);
                if (satmode[1] == 'y')
                  {  obspower(satpwr);
                     rgpulse(del/2.0-5.0*gt1/6.0-2.0*rof1,zero,rof1,rof1);
                  }
		 else delay(del/2.0-5.0*gt1/6.0); 
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
		delay(gstab); 
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
                if (satmode[1] == 'y')
                  {  rgpulse(del/2.0-5.0*gt1/6.0-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                  }
		else delay(del/2.0-5.0*gt1/6.0); 
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(-1.0*gzlvl1,gt1);
		delay((tau - 1.0e-6 - (2*pw/PI)-del-2.333*gt1)/2.0); 
	} 
	else 
	{ 
		delay((tau - 1.0e-6 - (2*pw/PI)-del-gt1-gstab)/2.0); 
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
                if (satmode[1] == 'y')
                  {  obspower(satpwr);
                     rgpulse(del-gt1-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                  }
		else delay(del-gt1); 
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
		delay(gstab); 
		delay((tau - 1.0e-6 - (2*pw/PI)-del-gt1-gstab)/2.0); 
	} 
 
     decrgpulse(pwx,v1,1.0e-6,1.0e-6); 
     delay(gtE+gtau); 
     decrgpulse(2*pwx,v4,1.0e-6,1.0e-6); 
     delay(gstab); 
     if (alt_grd[0] == 'y')
         {  ifzero(v10);
               zgradpulse(gzlvlE,gtE);
            elsenz(v10);
               zgradpulse(-1.0*gzlvlE,gtE);
            endif(v10);
         }
     else zgradpulse(gzlvlE,gtE);
     delay(gstab); 
 
     if (d2/2 > pw) 
        delay(d2/2 - pw); 
     else 
        delay(d2/2); 
     rgpulse(2.0*pw,zero,1.0e-6,1.0e-6); 
     if (d2/2 > pw)  
        delay(d2/2 - pw); 
     else  
        delay(d2/2); 
 
     delay(gstab); 
     if (alt_grd[0] == 'y')
         {  ifzero(v10);
               zgradpulse(gzlvlE,gtE);
            elsenz(v10);
               zgradpulse(-1.0*gzlvlE,gtE);
            endif(v10);
         }
     else zgradpulse(gzlvlE,gtE);
     delay(gstab); 
     decrgpulse(2*pwx,zero,1.0e-6,1.0e-6); 
     delay(gtE+gtau); 
     decrgpulse(pwx,t2,1.0e-6,1.0e-6); 
 
     delay(gstab); 
     if (alt_grd[0] == 'y')
         {  ifzero(v10);
               zgradpulse(icosel*2.0*gzlvlE/EDratio,gtE);
            elsenz(v10);
               zgradpulse(-1.0*icosel*2.0*gzlvlE/EDratio,gtE);
            endif(v10);
         }
     else zgradpulse(icosel*2.0*gzlvlE/EDratio,gtE);
        if (convcomp[0]=='y') 
        { 
                delay((tau-tauc - 1.0e-6 - (2*pw/PI)-del-2.333*gt1-2.0*gstab)/2.0); 
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(-1.0*gzlvl1,gt1);
                if (satmode[1] == 'y')
                  {  obspower(satpwr);
                     rgpulse(del/2.0-5.0*gt1/6.0-2.0*rof1,zero,rof1,rof1);
                  }
                 else delay(del/2.0-5.0*gt1/6.0);
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
                delay(gstab); 
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
                if (satmode[1] == 'y')
                  {  rgpulse(del/2.0-5.0*gt1/6.0-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                  }
                else delay(del/2.0-5.0*gt1/6.0);
                zgradpulse(-gzlvl1,gt1); 
                delay((tau-tauc - 1.0e-6 - (2*pw/PI)-del-2.333*gt1)/2.0); 
                if (lkgate_flg[0]=='y') lk_sample();
        }         
        else 
        { 
                delay((tau-tauc - 1.0e-6 - (2*pw/PI)-del-gt1-gstab)/2.0); 
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(-1.0*gzlvl1,gt1);
                if (satmode[1] == 'y')
                  {  obspower(satpwr);
                     rgpulse(del-gt1-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                  }
                else delay(del-gt1);
                if (alt_grd[0] == 'y')
                 {  ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                  elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                  endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
                delay(gstab); 
                delay((tau-tauc - 1.0e-6 - (2*pw/PI)-del-gt1-gstab)/2.0); 
                if (lkgate_flg[0]=='y') lk_sample();
        }       
     decpower(dpwr); 
     delay(rof2 - POWER_DELAY); 
 
 status(C); 
}  
Example #7
0
void pulsesequence()
{
   double          p1lvl,
                   trim,
                   mix,
                   window,
                   cycles;
   char            sspul[MAXSTR];


/* LOAD AND INITIALIZE VARIABLES */
   mix = getval("mix");
   trim = getval("trim");
   p1lvl = getval("p1lvl");
   window=getval("window");
   getstr("sspul", sspul);

/* CHECK CONDITIONS */
   if ((phase1 != 3) && (arrayelements > 2))
   {
      fprintf(stdout, "PHASE=3 is required if MIX is arrayed!\n");
      psg_abort(1);
   }
   if (satdly > 9.999)
   {
      fprintf(stdout, "Presaturation period is too long.\n");
      psg_abort(1);
   }
   if (!newtransamp)
   {
      fprintf(stdout, "TOCSY requires linear amplifiers on transmitter.\n");
      fprintf(stdout, "Use DECTOCSY with the appropriate re-cabling,\n");
      psg_abort(1);
   }
   if ((p1 == 0.0) && (ix == 1))
      fprintf(stdout, "Warning:  P1 has a zero value.\n");
   if ((rof1 < 9.9e-6) && (ix == 1))
      fprintf(stdout,"Warning:  ROF1 is less than 10 us\n");

   if (satpwr > 40)
        {
         printf("satpwr too large  - acquisition aborted./n");
         psg_abort(1);
        }

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

   ifzero(ssctr);
      hlv(ct, v13);
      mod2(ct, v1);
      hlv(ct, v2);
   elsenz(ssctr);
      sub(ssval, ssctr, v12);	/* v12 = 0,...,ss-1 */
      hlv(v12, v13);
      mod2(v12, v1);
      hlv(v12, v2);
   endif(ssctr);


/* CALCULATE PHASES */
/* A 2-step cycle is performed on the first pulse (90 degrees) to suppress
   axial peaks in the first instance.  Second, the 2-step F2 quadrature image
   suppression subcycle is added to all pulse phases and receiver phase.
   Finally, a 2-step cycle is performed on the spin-lock pulses. */

   mod2(v13, v13);
   dbl(v1, v1);
   incr(v1);
   hlv(v2, v2);
   mod2(v2, v2);
   dbl(v2, v2);
   incr(v2);
   add(v13, v2, v2);
   sub(v2, one, v3);
   add(two, v2, v4);
   add(two, v3, v5);
   add(v1, v13, v1);
   assign(v1, oph);
   if (phase1 == 2)
      incr(v1);
   if (phase1 == 3)
      add(v1, id2, v1);

 /*HYPERCOMPLEX MODE USES REDFIELD TRICK TO MOVE AXIAL PEAKS TO EDGE*/
   if ((phase1==1)||(phase1==2))
   {
      initval(2.0*(double)(d2_index%2),v6);
      add(v1,v6,v1); add(oph,v6,oph);
   } 

/* CALCULATE AND INITIALIZE LOOP COUNTER */
      if (pw > 0.0)
      {
         cycles = (mix - trim) / (64.66*pw+32*window);
         cycles = 2.0*(double) (int) (cycles/2.0);
      }
      else
      {
         cycles = 0.0;
      }
      initval(cycles, v9);			/* V9 is the MIX loop count */

/* BEGIN ACTUAL PULSE SEQUENCE CODE */
   status(A);
      obspower(p1lvl);
      if (sspul[0] == 'y')
      {
         rgpulse(1000*1e-6, zero, rof1, 0.0e-6);
         rgpulse(1000*1e-6, one, 0.0e-6, rof1);
      }
      hsdelay(d1);
     if (satmode[A] == 'y')
     { obspower(satpwr);
      rgpulse(satdly,zero,rof1,rof2);
      obspower(p1lvl);}
   status(B);
      rgpulse(p1, v1, rof1, 1.0e-6);
      if (satmode[B] =='y')
       {
        if (d2 > 0.0)
         {
           obspower(satpwr);
           rgpulse(d2 - (2*POWER_DELAY) - 1.0e-6 - (2*p1/3.1416),zero,0.0,0.0);
         }
       }
      else
       {
        if (d2 > 0.0)
          delay(d2 - POWER_DELAY - 1.0e-6  - (2*p1/3.1416));
       } 
      rcvroff();
      obsunblank();
      obspower(tpwr); 
      txphase(v3);
      xmtron();
      delay(trim);
      if (cycles > 1.0)
      {
         starthardloop(v9);
            mleva(window); mleva(window); mlevb(window); mlevb(window);
            mlevb(window); mleva(window); mleva(window); mlevb(window);
            mlevb(window); mlevb(window); mleva(window); mleva(window);
            mleva(window); mlevb(window); mlevb(window); mleva(window);
            rgpulse(.66*pw,v3,rof1,rof2);
         endhardloop();
      }
      txphase(v13);
      xmtroff();

/* detection */
      delay(rof2);
      rcvron();
      obsblank();
   status(C);
}
Example #8
0
pulsesequence()
{
/* DECLARE VARIABLES */

 char       fsat[MAXSTR],
            fscuba[MAXSTR],
            f1180[MAXSTR],    /* Flag to start t1 @ halfdwell             */
            codecseq[MAXSTR],
            ddseq[MAXSTR], 
            shca180[MAXSTR],
            shca90[MAXSTR];

 int         phase,  ni, 
             t1_counter,   /* used for states tppi in t1           */ 
             tau2;

 double      tau1,         /*  t1 delay */
             taua,         /*  ~ 1/4JCH =  1.7 ms */
             taub,         /* ~ 1/2JCH for AX spin systems */
             taud,         /* ~ 1/4JCD 12.5 ms for AX spin system */
             TC,           /* carbon constant time period 1/2JCC */
             pwc,          /* 90 c pulse at dhpwr            */
             tsatpwr,      /* low level 1H trans.power for presat  */
             dhpwr,        /* power level for high power 13C pulses on dec1 */
             sw1,          /* sweep width in f1                    */ 
             time_T2,      /*  total relaxation time for T2 measurement */
             pwcodec,      /* pw90 for C' decoupling */
             dressed,      /* = 2 for seduce-1 decoupling */
             dpwrsed,
             pwd,          /* pulse width for D decoupling at dpwr3_D  */
             dresD,
             dpwr3_D,
             lk_wait,      /* delay for lk receiver recovery  */

             pwd1,         /* pulse width for D +/- pulses at dpwr3  */

             d_ca180,
             pwca180,

             pwca90,       /* ca selective pulse at 57.5 ppm */
             d_ca90,       /* power level for pwca90   */

             dpwr3_sl,     /* D power level for spin locking */
             pwd_sl,       /* pw for D at dpwr3_sl    */

             gt1,
             gt2,
             gt3,
             gt4,
             gt5,
             gt6,
             gt7,
             gt8,
             gstab=getval("gstab"),

             gzlvl1,
             gzlvl2,
             gzlvl3,
             gzlvl4,
             gzlvl5,
             gzlvl6,
             gzlvl7,
             gzlvl8;

/*  variables commented out are already defined by the system      */


/* LOAD VARIABLES */

  getstr("fsat",fsat);
  getstr("f1180",f1180);
  getstr("fscuba",fscuba);
  getstr("codecseq",codecseq);
  getstr("ddseq",ddseq);
  getstr("shca180",shca180);
  getstr("shca90",shca90);

  taua   = getval("taua"); 
  taub   = getval("taub"); 
  taud   = getval("taud"); 
  TC = getval("TC");
  pwc = getval("pwc");
  tpwr = getval("tpwr");
  tsatpwr = getval("tsatpwr");
  dhpwr = getval("dhpwr");
  dpwr = getval("dpwr");
  phase = (int) ( getval("phase") + 0.5);
  sw1 = getval("sw1");
  ni = getval("ni");
  pwcodec = getval("pwcodec");
  dressed = getval("dressed");
  dpwrsed = getval("dpwrsed");
  pwd = getval("pwd");
  dresD = getval("dresD");
  dpwr3_D = getval("dpwr3_D");
  lk_wait = getval("lk_wait");

  pwd1 = getval("pwd1");

  d_ca180 = getval("d_ca180");
  pwca180 = getval("pwca180");

  pwca90 = getval("pwca90");
  d_ca90 = getval("d_ca90");

  dpwr3_sl = getval("dpwr3_sl"); 
  pwd_sl = getval("pwd_sl");

  gt1 = getval("gt1");
  gt2 = getval("gt2");
  gt3 = getval("gt3");
  gt4 = getval("gt4");
  gt5 = getval("gt5");
  gt6 = getval("gt6");
  gt7 = getval("gt7");
  gt8 = getval("gt8");

  gzlvl1 = getval("gzlvl1");
  gzlvl2 = getval("gzlvl2");
  gzlvl3 = getval("gzlvl3");
  gzlvl4 = getval("gzlvl4");
  gzlvl5 = getval("gzlvl5");
  gzlvl6 = getval("gzlvl6");
  gzlvl7 = getval("gzlvl7");
  gzlvl8 = getval("gzlvl8");

/* LOAD PHASE TABLE */

  settable(t1,16,phi1);
  settable(t2,2,phi2);
  settable(t3,16,phi3);
  settable(t4,4,phi4);
  settable(t6,4,phi6);
  settable(t7,8,phi7);
  settable(t5,16,rec_d);

/* CHECK VALIDITY OF PARAMETER RANGES */

    if( TC - 0.50*(ni-1)*1/(sw1) - WFG_STOP_DELAY 
             - gt6 - 102e-6 - POWER_DELAY 
             - PRG_START_DELAY - POWER_DELAY
             - 4.0e-6 - pwd1 - POWER_DELAY
             - PRG_START_DELAY - PRG_STOP_DELAY
             - 2.0e-6 - POWER_DELAY - 2.0e-6
             < 0.2e-6 ) 
    {
        printf(" ni is too big\n");
        psg_abort(1);
    }


    if((dm[A] == 'y' || dm[B] == 'y' || dm[C] == 'y' ))
    {
        printf("incorrect dec1 decoupler flags!  ");
        psg_abort(1);
    }

    if((dm2[A] == 'y' || dm2[B] == 'y' || dm2[C] == 'y' || dm2[D] == 'y'))
    {
        printf("incorrect dec2 decoupler flags!  ");
        psg_abort(1);
    }

    if( tsatpwr > 6 )
    {
        printf("TSATPWR too large !!!  ");
        psg_abort(1);
    }

    if( dpwr > 48 )
    {
        printf("don't fry the probe, DPWR too large!  ");
        psg_abort(1);
    }

    if( dpwr2 > 49 )
    {
        printf("don't fry the probe, DPWR2 too large!  ");
        psg_abort(1);
    }

    if( dhpwr > 63 )
    {
        printf("don't fry the probe, DHPWR too large!  ");
        psg_abort(1);
    }

    if( pw > 200.0e-6 )
    {
        printf("dont fry the probe, pw too high ! ");
        psg_abort(1);
    } 

    if(gt1 > 15e-3 || gt2 > 15e-3 || gt3 > 15e-3 || 
        gt4 > 15e-3 || gt5 > 15e-3 || gt6 > 15e-3 || gt7 > 15e-3
        || gt8 > 15e-3)
    {
        printf("gradients on for too long. Must be < 15e-3 \n");
        psg_abort(1);
    }

   if(dpwr3_D > 54)
   {
       printf("D decoupling power is too high\n");
       psg_abort(1);
   }

   if(lk_wait > .015 )
   {
       printf("lk_wait delay may be too long\n");
       psg_abort(1);
   }
/* change back to 48 */
   if(dpwr3_sl > 53) {
       printf("dpwr3_sl is too large; must be less than 53\n");
       psg_abort(1);
   }
/* change back to 250 */
   if(pwd_sl < 170.0e-6) {
       printf("pwd_sl is too large; Must be larger than 170 us\n");
       psg_abort(1);
   }


/* Calculation of IzCzDz relaxation delay */

   tau2 = (int) (d3+0.1);
   time_T2 = z_array[tau2];

   if(time_T2 > 0.030) {
       printf("time_T2 is too long; Must be less than 30 ms\n");
       psg_abort(1);
   }

/*  Phase incrementation for hypercomplex 2D data */

    if (phase == 2) {
      tsadd(t7,1,4);  
    }

/*  Set up f1180  tau1 = t1               */
   
    tau1 = d2;
    if(f1180[A] == 'y') {
        tau1 += ( 1.0 / (2.0*sw1) );
        if(tau1 < 0.4e-6) tau1 = 0.4e-6;
    }
        tau1 = tau1/2.0;


/* Calculate modifications to phases for States-TPPI acquisition          */

   if( ix == 1) d2_init = d2 ;
   t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5 );
   if(t1_counter % 2) {
      tsadd(t7,2,4);     
      tsadd(t5,2,4);    
    }


/* BEGIN ACTUAL PULSE SEQUENCE */

status(A);
   decoffset(dof);
   obspower(tsatpwr);     /* Set transmitter power for 1H presaturation */
   decpower(dhpwr);       /* Set Dec1 power for hard 13C pulses         */
   dec2power(dpwr2);      /* Set Dec2 power for 15N decoupling       */

/* Presaturation Period */

status(B);


   if (fsat[0] == 'y')
   {
        rgpulse(d1,zero,2.0e-6,2.0e-6); /* presat */
        obspower(tpwr);    /* Set transmitter power for hard 1H pulses */
        delay(2.0e-5);
        if(fscuba[0] == 'y')
        {
                delay(2.2e-2);
                rgpulse(pw,zero,2.0e-6,0.0);
                rgpulse(2*pw,one,2.0e-6,0.0);
                rgpulse(pw,zero,2.0e-6,0.0);
                delay(2.2e-2);
        }
   }
   else
   {
    delay(d1);
   }

   obspower(tpwr);          /* Set transmitter power for hard 1H pulses */
   txphase(zero);
   dec2phase(zero);
   decphase(zero);
   delay(1.0e-5);

/* Begin Pulses */

status(C);

/* Prepare for signs of gradients 0 1 0 1 0 1   */

   mod2(ct,v1);

   rcvroff();
   lk_hold();
   delay(20.0e-6);

/* first ensure that magnetization does infact start on H and not C */

   decrgpulse(pwc,zero,2.0e-6,2.0e-6);

   delay(2.0e-6);
   zgradpulse(gzlvl1,gt1);
   delay(gstab);


/* this is the real start */

   rgpulse(pw,zero,0.0,0.0);                    /* 90 deg 1H pulse */

   delay(2.0e-6);
   zgradpulse(gzlvl2,gt2);
   delay(2.0e-6);

   delay(taua - gt2 - 4.0e-6);                 /* taua <= 1/4JCH */                          

   simpulse(2*pw,2*pwc,zero,zero,0.0,0.0);

   txphase(one); decphase(t1);

   delay(2.0e-6);
   zgradpulse(gzlvl2,gt2);
   delay(2.0e-6);

   delay(taua - gt2 - 4.0e-6); 

   rgpulse(pw,one,0.0,0.0);
   txphase(zero);

   delay(2.0e-6);
   zgradpulse(gzlvl3,gt3);
   delay(gstab);

   /* 2D decoupling on */
   dec3phase(one);
   dec3power(dpwr3);
   dec3rgpulse(pwd1,one,4.0e-6,0.0);
   dec3phase(zero);
   dec3unblank();
   dec3power(dpwr3_D);                    /* keep power down */
   dec3prgon(ddseq,pwd,dresD);
   dec3on();
   /* 2D decoupling on */

   decrgpulse(pwc,t1,2.0e-6,0.0); 

   decphase(zero);

   delay(taub - 2.0*pw - 2.0e-6);

   rgpulse(pw,zero,0.0,0.0);
   rgpulse(pw,t2,2.0e-6,0.0);

   delay(TC - taub 
           - gt4 - 102e-6
           - PRG_STOP_DELAY - POWER_DELAY - pwd1
           - 4.0e-6 - POWER_DELAY - 4.0e-6 - WFG_START_DELAY);

   /* 2D decoupling off */
   dec3off();
   dec3prgoff();
   dec3blank();
   dec3phase(three);
   dec3power(dpwr3);
   dec3rgpulse(pwd1,three,4.0e-6,0.0);
   /* 2D decoupling off */

   ifzero(v1);

   delay(2.0e-6);
   zgradpulse(gzlvl4,gt4);
   delay(gstab);

   elsenz(v1);

   delay(2.0e-6);
   zgradpulse(-1.0*gzlvl4,gt4);
   delay(gstab);

  endif(v1);

   initval(1.0,v3);
   decstepsize(353.0);
   dcplrphase(v3); 

   decpower(d_ca180);
   decshaped_pulse(shca180,pwca180,zero,4.0e-6,0.0);
   dcplrphase(zero); 

   ifzero(v1);

   delay(2.0e-6);
   zgradpulse(gzlvl4,gt4);
   delay(gstab);

   elsenz(v1);

   delay(2.0e-6);
   zgradpulse(-1.0*gzlvl4,gt4);
   delay(gstab);

  endif(v1);

   /* 2D decoupling on */  
   dec3phase(one);
   dec3power(dpwr3);
   dec3rgpulse(pwd1,one,4.0e-6,0.0);
   dec3phase(zero);
   dec3unblank();
   dec3power(dpwr3_D);   /* keep power down */ 
   dec3prgon(ddseq,pwd,dresD);
   dec3on();
   /* 2D decoupling on */

    delay(TC - taud - WFG_STOP_DELAY - gt4 - 102e-6
            - POWER_DELAY - 4.0e-6 - pwd1 - POWER_DELAY 
            - PRG_START_DELAY); 

   /* 2D decoupling off */
   dec3off();
   dec3prgoff();
   dec3blank();
   decphase(three);
   dec3power(dpwr3);
   dec3rgpulse(pwd1,three,4.0e-6,0.0);
   /* 2D decoupling off */

   delay(taud - PRG_STOP_DELAY -POWER_DELAY - pwd1 - 4.0e-6 
         - POWER_DELAY
         - WFG_START_DELAY - pwca90 - 4.0e-6
         - WFG_STOP_DELAY - POWER_DELAY - 4.0e-6);

   decpower(d_ca90);
   decshaped_pulse(shca90,pwca90,t3,4.0e-6,0.0);
   decpower(dhpwr);

   decrgpulse(pwc,one,4.0e-6,0.0);

   /* T2 period */

   dec3power(dpwr3);   

      dec3rgpulse(pwd1,t4,2.0e-6,0.0);

      dec3phase(one);
      dec3power(dpwr3_sl);
      dec3rgpulse(time_T2,one,2.0e-6,2.0e-7);
      dec3phase(zero);

      dec3power(dpwr3);
      dec3rgpulse(pwd1,zero,2.0e-6,0.0);

       
      ifzero(v1);

      delay(2.0e-6);
      zgradpulse(gzlvl5,gt5);
      delay(gstab);

      elsenz(v1);

      delay(2.0e-6);
      zgradpulse(-1.0*gzlvl5,gt5);
      delay(gstab);

      endif(v1);

   decphase(zero);

   decrgpulse(pwc,t7,4.0e-6,0.0);

   /* C' decoupling on */
   decpower(dpwrsed);
   decprgon(codecseq,pwcodec,dressed);
   decon();
   /* C' decoupling on */

  if(taud + 3.0*POWER_DELAY + 2.0*PRG_START_DELAY + pwd1 + 4.0e-6 >= tau1) {
        
        delay(tau1);
        rgpulse(2.0*pw,zero,0.0,0.0);
        delay(taud + 3.0*POWER_DELAY + 2.0*PRG_START_DELAY + pwd1 + 4.0e-6
              - tau1);

        /* 2D decoupling on */  
        dec3phase(t6);
        dec3power(dpwr3);
        dec3rgpulse(pwd1,t6,4.0e-6,0.0);
        dec3phase(zero);
        dec3unblank();
        dec3power(dpwr3_D);   /* keep power down */ 
        dec3prgon(ddseq,pwd,dresD);
        dec3on();
        /* 2D decoupling on */

        delay(TC - taud + tau1 - POWER_DELAY 
              - PRG_START_DELAY - 2.0*pw
              - POWER_DELAY - pwd1 - 4.0e-6 - POWER_DELAY - PRG_START_DELAY
              - 3.0*POWER_DELAY - 2.0*PRG_START_DELAY - pwd1 - 4.0e-6 
              - PRG_STOP_DELAY - POWER_DELAY - pwd1 - 4.0e-6 
              - PRG_STOP_DELAY
              - POWER_DELAY - gt6 - 102e-6
              - WFG_START_DELAY);

        /* 2D decoupling off */  
        dec3off();
        dec3prgoff();
        dec3blank();
        dec3power(dpwr3);
        dec3rgpulse(pwd1,three,4.0e-6,0.0);
        /*  2D decoupler off */

        /* C' decoupling off */
        decoff();
        decprgoff();
        decpower(d_ca180);  /* set power for reburp  */
        /* C' decoupling off */

     }

     else {

        delay(taud);

        /* 2D decoupling on */  
        dec3phase(t6);
        dec3power(dpwr3);
        dec3rgpulse(pwd1,t6,4.0e-6,0.0);
        dec3phase(zero);
        dec3unblank();
        dec3power(dpwr3_D);   /* keep power down */ 
        dec3prgon(ddseq,pwd,dresD);
        dec3on();
        /* 2D decoupling on */

        delay(tau1 - taud - POWER_DELAY - PRG_START_DELAY
              - POWER_DELAY - pwd1 - 4.0e-6 
              - POWER_DELAY - PRG_START_DELAY);

        rgpulse(2.0*pw,zero,0.0,0.0);

        delay(TC 
              - 2.0*pw - PRG_STOP_DELAY - POWER_DELAY - pwd1 - 4.0e-6 
              - POWER_DELAY
              - PRG_STOP_DELAY - gt6 - 102e-6
              - WFG_START_DELAY);

        /* 2D decoupling off */  
        dec3off();
        dec3prgoff();
        dec3blank();
        dec3phase(three);
        dec3power(dpwr3);
        dec3rgpulse(pwd1,three,4.0e-6,0.0);
        /*  2D decoupler off */

        /* C' decoupling off */
        decoff();
        decprgoff();
        decpower(d_ca180);  /* set power for reburp  */
        /* C' decoupling off */

     }

   initval(1.0,v4);
   decstepsize(353.0);
   dcplrphase(v4); 

   ifzero(v1);

   delay(2.0e-6);
   zgradpulse(gzlvl6,gt6);
   delay(gstab);

   elsenz(v1);

   delay(2.0e-6);
   zgradpulse(-1.0*gzlvl6,gt6);
   delay(gstab);

   endif(v1);

   decshaped_pulse(shca180,pwca180,zero,0.0,0.0);
   dcplrphase(zero); 

   ifzero(v1);

   delay(2.0e-6);
   zgradpulse(gzlvl6,gt6);
   delay(gstab);

   elsenz(v1);

   delay(2.0e-6);
   zgradpulse(-1.0*gzlvl6,gt6);
   delay(gstab);

   endif(v1);

   /* C' decoupling on */
   decpower(dpwrsed);
   decprgon(codecseq,pwcodec,dressed);
   decon();
   /* C' decoupling on */

   /* 2D decoupling on */  
   dec3phase(one);
   dec3power(dpwr3);
   dec3rgpulse(pwd1,one,4.0e-6,0.0);
   dec3phase(zero);
   dec3unblank();
   dec3power(dpwr3_D);   /* keep power down */ 
   dec3prgon(ddseq,pwd,dresD);
   dec3on();
   /* 2D decoupling on */

   delay(TC - tau1 - WFG_STOP_DELAY - gt6
           - 102e-6 - POWER_DELAY - PRG_START_DELAY - POWER_DELAY - pwd1
           - 4.0e-6 - POWER_DELAY - PRG_START_DELAY - PRG_STOP_DELAY
           - POWER_DELAY - 4.0e-6);

   /* C' decoupling off */
   decoff();
   decprgoff();
   decpower(dhpwr);
   /* C' decoupling off */

   decrgpulse(pwc,one,4.0e-6,0.0);

   /* 2D decoupling off */  
   dec3off();
   dec3prgoff();
   dec3blank();
   dec3phase(three);
   dec3power(dpwr3);
   dec3rgpulse(pwd1,three,4.0e-6,0.0);
   /*  2D decoupler off */

  ifzero(v1);

   delay(2.0e-6);
   zgradpulse(gzlvl7,gt7);
   delay(gstab);

  elsenz(v1);

   delay(2.0e-6);
   zgradpulse(-1.0*gzlvl7,gt7);
   delay(gstab);

  endif(v1);
  
   delay(lk_wait);   /* delay for lk receiver recovery */

   rgpulse(pw,zero,0.0,0.0);

   delay(2.0e-6);
   zgradpulse(gzlvl8,gt8);

  decphase(zero);

  delay(taua - gt8 - 4.0e-6);

  simpulse(2*pw,2*pwc,zero,zero,0.0,0.0);

   delay(2.0e-6);
   zgradpulse(gzlvl8,gt8);
   delay(2.0e-6);

   delay(taua - 2*POWER_DELAY - gt8 - 4.0e-6);

   decpower(dpwr);  /* Set power for decoupling */
   dec2power(dpwr2);  /* Set power for decoupling */

   rgpulse(pw,zero,0.0,rof2);

  lk_sample();

/*   rcvron();  */          /* Turn on receiver to warm up before acq */ 

/* BEGIN ACQUISITION */

status(D);
   setreceiver(t5);

}
Example #9
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 #10
0
pulsesequence()
{
  char    mixpat[MAXSTR], pshape[MAXSTR], httype[MAXSTR], sspul[MAXSTR];
  double  rg1	= 2.0e-6,
          mix	= getval("mix"),	/* mixing time */
	  mixpwr = getval("mixpwr"),	/* mixing pwr */
	  compH  = getval("compH"),
	  gt0    = getval("gt0"),	/* gradient pulse in sspul */
	  gt2    = getval("gt2"),	/* gradient pulse preceding mixing */
	  gzlvl0 = getval("gzlvl0"),	/* gradient level for gt0 */
	  gzlvl2 = getval("gzlvl2"),	/* gradient level for gt2 */
	  gstab  = getval("gstab");	/* delay for gradient recovery */
  shape   hdx;
  void    setphases();

  getstr("sspul", sspul);
  getstr("pshape", pshape);
  getstr("httype", httype);
  getstr("mixpat", mixpat);
  setlimit("mixpwr", mixpwr, 48.0);

  (void) setphases();
  if (httype[0] == 'i')
    assign(zero,v2);

  /* MAKE PBOX SHAPES */

  if (FIRST_FID)
    hhmix = pbox_mix("HHmix", mixpat, mixpwr, pw*compH, tpwr);

  /* HADAMARD stuff */
  if(httype[0] == 'e')                           /* excitation */
    hdx = pboxHT_F1e(pshape, pw*compH, tpwr);
  else if(httype[0] == 'r')                      /* refocusing */
    hdx = pboxHT_F1r(pshape, pw*compH, tpwr);
  else if(httype[0] == 'd')                      /* DPFGSE */
  {
    hdx = pboxHT_F1r(pshape, pw*compH, tpwr);
    if (FIRST_FID)
      ref180 = hdx;
  }
  else /* httype[0] == 'i' */                    /* inversion */
    hdx = pboxHT_F1i(pshape, pw*compH, tpwr);

  if (getval("htcal1") > 0.5)          /* Optional fine power calibration */
    hdx.pwr += getval("htpwr1");

 /* THE PULSE PROGRAMM STARTS HERE */

  status(A);


    delay(5.0e-5);
    zgradpulse(gzlvl0,gt0);
    if (sspul[A] == 'y')
    {
      rgpulse(pw,zero,rof1,rof1);
      zgradpulse(gzlvl0,gt0);
    }

    pre_sat();
      
    if (getflag("wet"))
      wet4(zero,one);
      
    delay(1.0e-5);

    obspower(tpwr);
    delay(1.0e-5);

  status(B);

    if (httype[0] == 'i')           /* longitudinal encoding */
    {
      ifzero(v1);
        delay(2.0*(pw+rg1));
        zgradpulse(gzlvl2,gt2);
        delay(gstab);
      elsenz(v1);
        rgpulse(2.0*pw,v3,rg1,rg1);
        zgradpulse(gzlvl2,gt2);
        delay(gstab);
      endif(v1);

      pbox_pulse(&hdx, zero, rg1, rg1);
      zgradpulse(gzlvl2,gt2);
      delay(gstab);
    }
    else                            /* transverse encoding */
    {
      if (httype[0] == 'e')
        pbox_pulse(&hdx, oph, rg1, rg1);
      else
      {
        rgpulse(pw,oph,rg1,rg1);
        if (httype[0] == 'd')       /* DPFGSE */
        {
          zgradpulse(2.0*gzlvl2,gt2);
          delay(gstab);
          pbox_pulse(&ref180, oph, rg1, rg1);
          zgradpulse(2.0*gzlvl2,gt2);
          delay(gstab);
        }
        zgradpulse(gzlvl2,gt2);
        delay(gstab);
        pbox_pulse(&hdx, v2, rg1, rof2);
        zgradpulse(gzlvl2,gt2);
        delay(gstab - POWER_DELAY);
      }
    }

    if (mix)
      pbox_spinlock(&hhmix, mix, v2);

    if (httype[0] == 'i')
    {
      zgradpulse(0.87*gzlvl2,gt2);
      delay(gstab);
      obspower(tpwr);
      txphase(v3);
      rgpulse(pw,v3,rg1,rof2);
    }

  status(C);
}
Example #11
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 #12
0
pulsesequence()
{
  /* Internal variable declarations *************************/
  double  freqEx[MAXNSLICE];
  double  maxgradtime,spoilMoment,perTime,tau1,te_delay,tr_delay;
  double  te2=0.0,te3=0.0,te2min,te3min,tau2,tau3,te2_delay,te3_delay=0;
  char    minte2[MAXSTR],minte3[MAXSTR],spoilflag[MAXSTR];
  int     sepSliceRephase,sepReadRephase=0,readrev,table,shapeEx;
  int     i;

  /* Real-time variables used in this sequence **************/
  int  vpe_steps    = v1;      // Number of PE steps
  int  vpe_ctr      = v2;      // PE loop counter
  int  vms_slices   = v3;      // Number of slices
  int  vms_ctr      = v4;      // Slice loop counter
  int  vpe_offset   = v5;      // PE/2 for non-table offset
  int  vpe_mult     = v6;      // PE multiplier, ranges from -PE/2 to PE/2
  int  vper_mult    = v7;      // PE rewinder multiplier; turn off rewinder when 0
  int  vssc         = v8;      // Compressed steady-states
  int  vacquire     = v9;      // Argument for setacqvar, to skip steady state acquires
  int  vrfspoil_ctr = v10;     // RF spoil counter
  int  vrfspoil     = v11;     // RF spoil multiplier
  int  vtrimage     = v12;     // Counts down from nt, trimage delay when 0
  int  vne          = v13;     // Number of echoes
  int  vne_ctr      = v14;     // Echo loop counter
  int  vneindex     = v15;     // Echo index, odd or even
  int  vnelast      = v16;     // Check for last echo
  int  vtrigblock   = v17;     // Number of slices per trigger block

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

  getstr("spoilflag",spoilflag);
  te2=getval("te2");
  te3=getval("te3");
  getstr("minte2",minte2);
  getstr("minte3",minte3);
  readrev=(int)getval("readrev");

  /*  Check for external PE table ***************************/
  table = 0;
  if (strcmp(petable,"n") && strcmp(petable,"N") && strcmp(petable,"")) {
    loadtable(petable);
    table = 1;
  }

  /* Set Rcvr/Xmtr phase increments for RF Spoiling ********/
  /* Ref:  Zur, Y., Magn. Res. Med., 21, 251, (1991) *******/
  if (rfspoil[0] == 'y') {
    rcvrstepsize(rfphase);
    obsstepsize(rfphase);
  }

  /* Initialize gradient structures *************************/
  shape_rf(&p1_rf,"p1",p1pat,p1,flip1,rof1,rof2 );   // excitation pulse
  init_slice(&ss_grad,"ss",thk);                     // slice select gradient
  init_slice_refocus(&ssr_grad,"ssr");               // slice refocus gradient
  init_readout(&ro_grad,"ro",lro,np,sw);             // readout gradient
  ro_grad.pad1=alfa; ro_grad.pad2=alfa;
  init_readout_refocus(&ror_grad,"ror");             // dephase gradient
  init_phase(&pe_grad,"pe",lpe,nv);                  // phase encode gradient
  init_dephase(&spoil_grad,"spoil");                 // optimized spoiler
  init_dephase(&ref_grad,"ref");                     // readout rephase

  /* RF Calculations ****************************************/
  calc_rf(&p1_rf,"tpwr1","tpwr1f");

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

  spoilMoment = ro_grad.acqTime*ro_grad.roamp;   // Optimal spoiling is at*gro for 2pi per pixel
  spoilMoment -= ro_grad.m0def;                  // Subtract partial spoiling from back half of readout
  calc_dephase(&spoil_grad,WRITE,spoilMoment,"gspoil","tspoil");

  /* Is TE long enough for separate slice refocus? ******/
  maxgradtime = MAX(ror_grad.duration,pe_grad.duration);
  if (spoilflag[0] == 'y')
    maxgradtime = MAX(maxgradtime,spoil_grad.duration);
  tau1 = ss_grad.rfCenterBack + ssr_grad.duration + maxgradtime + ro_grad.timeToEcho + GRADIENT_RES;

  /* Equalize refocus and PE gradient durations *********/
  if ((te >= tau1) && (minte[0] != 'y')) {
    sepSliceRephase = 1;                         // Set flag for separate slice rephase
    calc_sim_gradient(&ror_grad,&pe_grad,&spoil_grad,tpemin,WRITE);
  } else {
    sepSliceRephase = 0;
    calc_sim_gradient(&ror_grad,&pe_grad,&ssr_grad,tpemin,WRITE);
    calc_sim_gradient(&ror_grad,&spoil_grad,&null_grad,tpemin,NOWRITE);
  }

  perTime = 0.0;
  if ((perewind[0] == 'y') || (spoilflag[0] == 'y'))
    perTime = spoil_grad.duration;
  if (spoilflag[0] == 'n')
    spoil_grad.amp = 0.0;

  /* 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')   create_inversion_recovery();

  /* Set up frequency offset pulse shape list ********/   	
  offsetlist(pss,ss_grad.ssamp,0,freqEx,ns,seqcon[1]);
  shapeEx = shapelist(p1_rf.pulseName,ss_grad.rfDuration,freqEx,ns,ss_grad.rfFraction,seqcon[1]);
  
  /* Check that all Gradient calculations are ok ************/
  sgl_error_check(sglerror);

  /* Min TE ******************************************/
  tau1 = ss_grad.rfCenterBack + pe_grad.duration + ro_grad.timeToEcho;
  tau1 += (sepSliceRephase) ? ssr_grad.duration : 0.0;   // Add slice refocusing if separate event

  temin = tau1 + GRADIENT_RES;  /* ensure that te_delay is at least GRADIENT_RES */
  te = granularity(te,GRADIENT_RES);
  if (minte[0] == 'y') {
    te = temin;
    putvalue("te",te);
  }
  if (FP_LT(te,temin)) {
    abort_message("TE too short.  Minimum TE= %.3fms\n",temin*1000);   
  }
  te_delay = te - tau1;

  /* Min TE2 *****************************************/
  tau2 = (readrev) ? 2*ro_grad.timeFromEcho : ro_grad.duration+ref_grad.duration;
  te2min = tau2 + GRADIENT_RES;
  te2 = granularity(te2,GRADIENT_RES);
  if (minte2[0] == 'y') {
    te2 = te2min;
    putvalue("te2",te2);
  }
  if (FP_LT(te2,te2min)) {
    abort_message("TE2 too short.  Minimum TE2= %.3fms\n",te2min*1000);
  }

  if (readrev) te2_delay = te2 - tau2;
  else {
    tau2 = ro_grad.duration + 3*ror_grad.duration;
    if (te2 >= tau2) {
      sepReadRephase = 1; // Set flag for separate read rephase
      te2_delay = te2 - ro_grad.duration - 2*ror_grad.duration;
    } else {
      sepReadRephase = 0;
      if (te2 > te2min+GRADIENT_RES) {
        ref_grad.duration = granularity(te2-ro_grad.duration-2*GRADIENT_RES,GRADIENT_RES);
        ref_grad.calcFlag = AMPLITUDE_FROM_MOMENT_DURATION;
        calc_dephase(&ref_grad,WRITE,ro_grad.m0,"","");
      }
      te2_delay = te2 - ro_grad.duration - ref_grad.duration;
    }
  }

  /* Min TE3 *****************************************/
  if (readrev) {  
    tau3 = 2*ro_grad.timeToEcho;
    te3min = tau3 + GRADIENT_RES;
    te3 = granularity(te3,GRADIENT_RES);
    if (minte3[0] == 'y') {
      te3 = te3min;
      putvalue("te3",te3);
    }
    if (FP_LT(te3,te3min)) {
      abort_message("TE3 too short.  Minimum TE3= %.3fms\n",te3min*1000);
    }
    te3_delay = te3 - tau3;
  }

  /* Now set the TE array accordingly */
  putCmd("TE = 0"); /* Re-initialize TE */
  putCmd("TE[1] = %f",te*1000);
  if (readrev) {
    for (i=1;i<ne;i++) {
      if (i%2 == 0) putCmd("TE[%d] = TE[%d]+%f",i+1,i,te3*1000);
      else putCmd("TE[%d] = TE[%d]+%f",i+1,i,te2*1000);
    }
  } else {
    for (i=1;i<ne;i++) putCmd("TE[%d] = TE[%d]+%f",i+1,i,te2*1000);
  }

  /* Check nsblock, the number of slices blocked together
     (used for triggering and/or inversion recovery) */
  check_nsblock();

  /* Min TR ******************************************/
  trmin  = ss_grad.duration + te_delay + pe_grad.duration + ne*ro_grad.duration + perTime + 2*GRADIENT_RES;
  trmin += (sepSliceRephase) ? ssr_grad.duration : 0.0;   // Add slice refocusing if separate event
  if (readrev) trmin += (ne/2)*te2_delay + ((ne-1)/2)*te3_delay;
  else trmin += (sepReadRephase) ? (ne-1)*(te2_delay+2*ror_grad.duration) : (ne-1)*(te2_delay+ref_grad.duration);

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

  /* Adjust for all slices ***************************/
  trmin *= ns;

  /* Inversion recovery *********************************/
  if (ir[0] == 'y') {
    /* tauti is the additional time beyond IR component to be included in ti */
    /* satTime, fsatTime and mtTime all included as those modules will be after IR */
    tauti = satTime + fsatTime + mtTime + GRADIENT_RES + ss_grad.rfCenterFront;
    /* calc_irTime checks ti and returns the time of all IR components */
    trmin += calc_irTime(tauti,trmin,mintr[0],tr,&trtype);
  }

  if (mintr[0] == 'y') {
    tr = trmin;
    putvalue("tr",tr);
  }
  if (FP_LT(tr,trmin)) {
    abort_message("TR too short.  Minimum TR = %.3fms\n",trmin*1000);
  }

  /* Calculate tr delay */
  tr_delay = granularity((tr-trmin)/ns,GRADIENT_RES);

  /* Set pe_steps for profile or full image **********/   	
  pe_steps = prep_profile(profile[0],nv,&pe_grad,&per_grad);
  F_initval(pe_steps/2.0,vpe_offset);

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

  /* Adjust experiment time for VnmrJ *********************/
  if (ssc<0) {
    if (seqcon[2] == 'c') g_setExpTime(trmean*(ntmean*pe_steps*arraydim - ssc*arraydim));
    else g_setExpTime(trmean*(ntmean*pe_steps*arraydim - ssc*pe_steps*arraydim));
  }
  else g_setExpTime(trmean*ntmean*pe_steps*arraydim + tr*ssc);

  /* PULSE SEQUENCE ***************************************/
  status(A);
  rotate();
  triggerSelect(trigger);       // Select trigger input 1/2/3
  obsoffset(resto);
  delay(GRADIENT_RES);
  initval(fabs(ssc),vssc);      // Compressed steady-state counter
  if (seqcon[2]=='s') assign(zero,vssc); // Zero for standard peloop
  assign(zero,vrfspoil_ctr);    // RF spoil phase counter
  assign(zero,vrfspoil);        // RF spoil multiplier
  assign(one,vacquire);         // real-time acquire flag
  setacqvar(vacquire);          // Turn on acquire when vacquire is zero 

  /* trigger */
  if (ticks > 0) F_initval((double)nsblock,vtrigblock);

  /* Begin phase-encode loop ****************************/       
  peloop(seqcon[2],pe_steps,vpe_steps,vpe_ctr);

    if (trtype) delay(ns*tr_delay);   // relaxation delay

    /* Compressed steady-states: 
       1st array & transient, all arrays if ssc is negative */
    if ((ix > 1) && (ssc > 0))
      assign(zero,vssc);
    sub(vpe_ctr,vssc,vpe_ctr);  // vpe_ctr counts up from -ssc
    assign(zero,vssc);
    if (seqcon[2] == 's')
      assign(zero,vacquire);    // Always acquire for non-compressed loop
    else {
      ifzero(vpe_ctr);
        assign(zero,vacquire);  // Start acquiring when vpe_ctr reaches zero
      endif(vpe_ctr);
    }

    /* Set rcvr/xmtr phase for RF spoiling *******************/
    if (rfspoil[0] == 'y') {
      incr(vrfspoil_ctr);                    // vrfspoil_ctr = 1  2  3  4  5  6
      add(vrfspoil,vrfspoil_ctr,vrfspoil);   // vrfspoil =     1  3  6 10 15 21
      xmtrphase(vrfspoil);
      rcvrphase(vrfspoil);
    }

    /* Read external kspace table if set ******************/       
    if (table)
      getelem(t1,vpe_ctr,vpe_mult);
    else {
      ifzero(vacquire);
        sub(vpe_ctr,vpe_offset,vpe_mult);
      elsenz(vacquire);
        sub(zero,vpe_offset,vpe_mult);  // Hold PE mult at initial value for steady states
      endif(vacquire);
    }

    /* PE rewinder follows PE table; zero if turned off ***/       
    if (perewind[0] == 'y') assign(vpe_mult,vper_mult);
    else assign(zero,vper_mult);

    /* Begin multislice loop ******************************/       
    msloop(seqcon[1],ns,vms_slices,vms_ctr);

      if (!trtype) delay(tr_delay);   // Relaxation delay

      if (ticks > 0) {
        modn(vms_ctr,vtrigblock,vtest);
        ifzero(vtest);                // if the beginning of an trigger block
          xgate(ticks);
          grad_advance(gpropdelay);
          delay(GRADIENT_RES);
        elsenz(vtest);
          delay(GRADIENT_RES);
        endif(vtest);
      }

      /* TTL scope trigger **********************************/       
      sp1on(); delay(GRADIENT_RES); sp1off();

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

      /* Slice select RF pulse ******************************/ 
      obspower(p1_rf.powerCoarse);
      obspwrf(p1_rf.powerFine);
      delay(GRADIENT_RES);
      obl_shapedgradient(ss_grad.name,ss_grad.duration,0,0,ss_grad.amp,NOWAIT);
      delay(ss_grad.rfDelayFront);
      shapedpulselist(shapeEx,ss_grad.rfDuration,oph,rof1,rof2,seqcon[1],vms_ctr);
      delay(ss_grad.rfDelayBack);

     /* Phase encode, refocus, and dephase gradient ********/
      if (sepSliceRephase) {                // separate slice refocus gradient
        obl_shapedgradient(ssr_grad.name,ssr_grad.duration,0,0,-ssr_grad.amp,WAIT);
        delay(te_delay);                    // delay between slab refocus and pe
        pe_shapedgradient(pe_grad.name,pe_grad.duration,-ror_grad.amp,0,0,
            -pe_grad.increment,vpe_mult,WAIT);
      } else {
        pe_shapedgradient(pe_grad.name,pe_grad.duration,-ror_grad.amp,0,-ssr_grad.amp,
            -pe_grad.increment,vpe_mult,WAIT);
        delay(te_delay);                    // delay after refocus/pe
      }

      F_initval(ne,vne);
      loop(vne,vne_ctr);

        if (readrev) {
          mod2(vne_ctr,vneindex);
          ifzero(vneindex);
            /* Shift DDR for pro *******************************/
            roff = -poffset(pro,ro_grad.roamp);
            /* Readout gradient ********************************/
            obl_shapedgradient(ro_grad.name,ro_grad.duration,ro_grad.amp,0,0,NOWAIT);
            delay(ro_grad.atDelayFront-alfa);
            /* Acquisition ***************************************/
            startacq(alfa);
            acquire(np,1.0/sw);
            delay(ro_grad.atDelayBack);
            endacq();
            sub(vne,vne_ctr,vnelast);
            sub(vnelast,one,vnelast);
            ifzero(vnelast);
            elsenz(vnelast);
              delay(te2_delay);
            endif(vnelast);
          elsenz(vneindex);
            /* Shift DDR for pro *******************************/
            roff = -poffset(pro,-ro_grad.roamp);
            /* Readout gradient ********************************/
            obl_shapedgradient(ro_grad.name,ro_grad.duration,-ro_grad.amp,0,0,NOWAIT);
            delay(ro_grad.atDelayFront-alfa);
            /* Acquisition ***************************************/
            startacq(alfa);
            acquire(np,1.0/sw);
            delay(ro_grad.atDelayBack);
            endacq();
            sub(vne,vne_ctr,vnelast);
            sub(vnelast,one,vnelast);
            ifzero(vnelast);
            elsenz(vnelast);
              delay(te3_delay);
            endif(vnelast);
          endif(vneindex);
        } else {
          /* Shift DDR for pro *******************************/
          roff = -poffset(pro,ro_grad.roamp);
          /* Readout gradient ********************************/
          obl_shapedgradient(ro_grad.name,ro_grad.duration,ro_grad.amp,0,0,NOWAIT);
          delay(ro_grad.atDelayFront-alfa);
          /* Acquisition ***************************************/
          startacq(alfa);
          acquire(np,1.0/sw);
          delay(ro_grad.atDelayBack);
          endacq();
	  sub(vne,vne_ctr,vnelast);
	  sub(vnelast,one,vnelast);
	  ifzero(vnelast);
	  elsenz(vnelast);
            if (sepReadRephase) {
              obl_shapedgradient(ror_grad.name,ror_grad.duration,-ror_grad.amp,0,0,WAIT);
              delay(te2_delay);
              obl_shapedgradient(ror_grad.name,ror_grad.duration,-ror_grad.amp,0,0,WAIT);
            } else {
              obl_shapedgradient(ref_grad.name,ref_grad.duration,-ref_grad.amp,0,0,WAIT);
              delay(te2_delay);
            }
	  endif(vnelast);
        }

      endloop(vne_ctr);

      /* Rewind / spoiler gradient **************************/
      if ((perewind[0] == 'y') || (spoilflag[0] == 'y')) {
        pe_shapedgradient(pe_grad.name,pe_grad.duration,spoil_grad.amp,0,0,pe_grad.increment,vper_mult,WAIT);
      }

    endmsloop(seqcon[1],vms_ctr);

  endpeloop(seqcon[2],vpe_ctr);

  /* Inter-image delay **********************************/
  sub(ntrt,ct,vtrimage);
  decr(vtrimage);
  ifzero(vtrimage);
    delay(trimage);
  endif(vtrimage);
}
Example #13
0
pulsesequence()
{
double	del    = getval("del"),
        gstab  = getval("gstab"),
	gt1    = getval("gt1"),
	gzlvl1 = getval("gzlvl1"),
        gt2    = getval("gt2"),
        gzlvl2 = getval("gzlvl2"),
        satpwr = getval("satpwr"),
        satdly = getval("satdly"),
        prgtime = getval("prgtime"),
        prgpwr = getval("prgpwr"),
        gzlvlhs   = getval("gzlvlhs"),
        hsgt     = getval("hsgt"),
        d3 = getval("d3"),
	Dtau,Ddelta,dosytimecubed, dosyfrq;
char	delflag[MAXSTR],satmode[MAXSTR],prg_flg[MAXSTR],alt_grd[MAXSTR],
        sspul[MAXSTR],lkgate_flg[MAXSTR];

   getstr("delflag",delflag);
   getstr("satmode",satmode);
   getstr("prg_flg",prg_flg);
   getstr("alt_grd",alt_grd);
   getstr("lkgate_flg",lkgate_flg);
   getstr("sspul",sspul);

       //synchronize gradients to srate for probetype='nano'
       //   Preserve gradient "area"
          gt1 = syncGradTime("gt1","gzlvl1",0.5);
          gzlvl1 = syncGradLvl("gt1","gzlvl1",0.5);
          gt2 = syncGradTime("gt2","gzlvl2",1.0);
          gzlvl2 = syncGradLvl("gt2","gzlvl2",1.0);

   /* In pulse sequence, minimum del=4.0*pw+3*rof1+gt1+2.0*gstab	*/
   if (del < (4*pw+3.0*rof1+gt1+2.0*gstab))
   {  abort_message("Dbppste error: 'del' is less than %g, too short!",
		(4.0*pw+3*rof1+gt1+2.0*gstab));
   }

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


   /* phase cycling calculation */
   mod2(ct,v1); dbl(v1,v1);    hlv(ct,v2);
   mod2(v2,v3); dbl(v3,v3);    hlv(v2,v2);
   mod2(v2,v4); add(v1,v4,v1);			/*   v1    */
   hlv(v2,v2);  add(v2,v3,v4);			/*   v4    */
   hlv(v2,v2);  mod2(v2,v3);   dbl(v3,v5);
   hlv(v2,v2);  mod2(v2,v3);   dbl(v3,v3);	/*   v3    */
   hlv(v2,v2);  mod2(v2,v6);   add(v5,v6,v5);	/*   v5    */
   hlv(v2,v2);  mod2(v2,v2);   dbl(v2,v2);	/*   v2    */

   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*/
   add(v1,v3,v7); add(v4,v7,v7);
   add(two,v7,v8);

   mod2(ct,v10);        /* gradients change sign at odd transients */

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

   /* equilibrium period */
   status(A);
     if (sspul[0]=='y')
       {
         zgradpulse(gzlvlhs,hsgt);
         rgpulse(pw,zero,rof1,rof1);
         zgradpulse(gzlvlhs,hsgt);
       }

      if (satmode[0] == 'y')
       {
       if (d1 - satdly > 0)
         delay(d1 - satdly);
         obspower(satpwr);
         txphase(zero);
         rgpulse(satdly,zero,rof1,rof1);
         obspower(tpwr);
      }
      else
      delay(d1); 
   status(B);
   /* first part of bppdel sequence */
   if (delflag[0]=='y')
   {  if (gt1>0 && gzlvl1>0)
      {  rgpulse(pw, v1, rof1, 0.0);		/* first 90, v1 */

         if (lkgate_flg[0] == 'y') lk_hold();   /* turn lock sampling off */
         if (alt_grd[0] == 'y')
         {  ifzero(v10);
              zgradpulse(gzlvl1,gt1/2.0);
            elsenz(v10);
              zgradpulse(-1.0*gzlvl1,gt1/2.0);
            endif(v10);
         }
         else 
            zgradpulse(gzlvl1,gt1/2.0);
   	 delay(gstab);
	 rgpulse(pw*2.0, v2, rof1, 0.0);	/* first 180, v2 */
         if (alt_grd[0] == 'y')
         {  ifzero(v10);
              zgradpulse(-1.0*gzlvl1,gt1/2.0);
            elsenz(v10);
              zgradpulse(gzlvl1,gt1/2.0);
            endif(v10);
         }
         else
            zgradpulse(-1.0*gzlvl1,gt1/2.0);
   	 delay(gstab);
   	 rgpulse(pw, v3, rof1, 0.0);		/* second 90, v3 */

       if (satmode[1] == 'y')
        {
         obspower(satpwr);
         rgpulse(del-4.0*pw-3.0*rof1-gt1-2.0*gstab,zero,rof1,rof1);
         obspower(tpwr);
        }
       else
   	{
         delay(del-4.0*pw-3.0*rof1-gt1-2.0*gstab);/*diffusion delay */
        }
         rgpulse(pw, v4, rof1, 0.0);            /* third 90, v4 */

         if (alt_grd[0] == 'y')
         {  ifzero(v10);
              zgradpulse(gzlvl1,gt1/2.0);
            elsenz(v10);
              zgradpulse(-1.0*gzlvl1,gt1/2.0);
            endif(v10);
         }
         else
            zgradpulse(gzlvl1,gt1/2.0);
   	 delay(gstab);
  	 rgpulse(pw*2.0, v5, rof1, rof1);	/* second 180, v5 */
         if (alt_grd[0] == 'y')
         {  ifzero(v10);
              zgradpulse(-1.0*gzlvl1,gt1/2.0);
            elsenz(v10);
              zgradpulse(gzlvl1,gt1/2.0);
            endif(v10);
         }
         else
            zgradpulse(-1.0*gzlvl1,gt1/2.0);
   	 delay(gstab);
           if (prg_flg[0] == 'y')
                     { 
                         add(one,v7,v9);
                         obspower(prgpwr);
                         rgpulse(prgtime, v9, rof1, rof1);
                         obspower(tpwr);
                     }

        }
           zgradpulse(gzlvl2,gt2);
           delay(gstab);
            rgpulse(pw*0.231,v7,rof1,rof1);
            delay(d3);
            rgpulse(pw*0.692,v7,rof1,rof1);
            delay(d3);
            rgpulse(pw*1.462,v7,rof1,rof1);
            delay(d3);
            rgpulse(pw*1.462,v8,rof1,rof1);
            delay(d3);
            rgpulse(pw*0.692,v8,rof1,rof1);
            delay(d3);
            rgpulse(pw*0.231,v8,rof1,rof1);
          zgradpulse(gzlvl2,gt2);
          delay(gstab);
          if (lkgate_flg[0] == 'y') lk_sample();     /* turn lock on */
   }
   else
      rgpulse(pw,oph,rof1,rof2);

   /* --- observe period --- */

   status(C);
}
Example #14
0
pulsesequence ()
{

double  gstab = getval("gstab"),
	gt1 = getval("gt1"),
        gzlvl1 = getval("gzlvl1"),
        gzlvlhs = getval("gzlvlhs"),
        wselpw = getval("wselpw"),
        wselpwr = getval("wselpwr"),
        mixN = getval("mixN"),
        prgtime = getval("prgtime"),
        prgpwr = getval("prgpwr"),
        phincr1 = getval("phincr1");

char    wselshape[MAXSTR], sspul[MAXSTR],flipshape[MAXSTR], ESmode[MAXSTR],
	flipback[MAXSTR],prg_flg[MAXSTR],alt_grd[MAXSTR]; 

rof1 = getval("rof1"); if(rof1 > 2.0e-6) rof1 = 2.0e-6;
  getstr("wselshape", wselshape);
  getstr("flipshape", flipshape);
  getstr("prg_flg", prg_flg);
  getstr("alt_grd",alt_grd);
  if (phincr1 < 0.0) phincr1=360+phincr1;
  initval(phincr1,v8);

   settable(t1,16,phi1);
   settable(t3,16,phi3);
   settable(t5,16,phi5);
   settable(t6,16,rec);
   settable(t9,16,phi9);

   sub(ct,ssctr,v12);

   getelem(t1,v12,v1);
   getelem(t3,v12,v3);
   getelem(t5,v12,v5);
   getelem(t9,v12,v9);
   getelem(t6,v12,oph);
   add(v1,one,v10);
   if (alt_grd[0] == 'y') mod2(ct,v6);
                     /* alternate gradient sign on every 2nd transient */

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

   decpower(dpwr); obspower(tpwr);
   if (getflag("sspul"))
        steadystate();
   delay(d1);

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

status(B);
 if (getflag("ESmode")) 
 {
   rgpulse(pw,zero,rof1,rof1);
     ifzero(v6); zgradpulse(gzlvl1,gt1);
       elsenz(v6); zgradpulse(-1.0*gzlvl1,gt1); endif(v6);
   obspower(wselpwr);
   delay(gstab);
   shaped_pulse(wselshape,wselpw,v9,10.0e-6,rof1);
     ifzero(v6); zgradpulse(gzlvl1,gt1);
       elsenz(v6); zgradpulse(-1.0*gzlvl1,gt1); endif(v6);
   obspower(tpwr);
   delay(gstab);
                              /* do mixing */
   rgpulse(pw,zero,rof1,rof1);
      ifzero(v6); rgradient('z',gzlvlhs); /* make it compatible with cold probes */
        elsenz(v6); rgradient('z',-1.0*gzlvlhs); endif(v6);
     delay(mixN);
   rgradient('z',0.0);
   delay(gstab);
   if (getflag("flipback"))
     FlipBack(v1,v8);
   rgpulse(pw,v1,rof1,rof1);
   ExcitationSculpting(v5,v3,v6);
       if (prg_flg[A] == 'y')    /* optional purge pulse */
           { obspower(prgpwr);
             add(v1,one,v1);
            rgpulse(prgtime,v1,rof1,rof2);
           }
       else delay(rof2);
 }
 else
	rgpulse(pw,v1,rof1,rof2);
status(C);
}
Example #15
0
pulsesequence()
{
  /* Internal variable declarations *************************/
  double  freqEx[MAXNSLICE], freqIR[MAXNSLICE];
  double  pe_steps,pespoil_amp;
  double  perTime, seqtime, tau1, tauIR=0, te_delay, tr_delay, ti_delay=0;
  int     table, shapeEx, shapeIR=0;
  char    spoilflag[MAXSTR],per_name[MAXSTR];

  /* Real-time variables used in this sequence **************/
  int  vpe_steps    = v1;      // Number of PE steps
  int  vpe_ctr      = v2;      // PE loop counter
  int  vms_slices   = v3;      // Number of slices
  int  vms_ctr      = v4;      // Slice loop counter
  int  vpe_offset   = v5;      // PE/2 for non-table offset
  int  vpe_mult     = v6;      // PE multiplier, ranges from -PE/2 to PE/2
  int  vper_mult    = v7;      // PE rewinder multiplier; turn off rewinder when 0
  int  vssc         = v8;      // Compressed steady-states
  int  vacquire     = v9;      // Argument for setacqvar, to skip steady state acquires
  int  vrfspoil_ctr = v10;     // RF spoil counter
  int  vrfspoil     = v11;     // RF spoil multiplier
  int  vtrimage     = v12;     // Counts down from nt, trimage delay when 0

  /* Initialize paramaters **********************************/
  get_parameters();
  get_ovsparameters();
  getstr("spoilflag",spoilflag);

  /*  Check for external PE table ***************************/
  table = 0;
  if (strcmp(petable,"n") && strcmp(petable,"N") && strcmp(petable,"")) {
    loadtable(petable);
    table = 1;
  }

  /* Set Rcvr/Xmtr phase increments for RF Spoiling ********/
  /* Ref:  Zur, Y., Magn. Res. Med., 21, 251, (1991) *******/
  if (rfspoil[0] == 'y') {
    rcvrstepsize(rfphase);
    obsstepsize(rfphase);
  }

  /* Initialize gradient structures *************************/
  init_rf(&p1_rf,p1pat,p1,flip1,rof1,rof2 );         // excitation pulse
  init_slice(&ss_grad,"ss",thk);                     // slice select gradient
  init_slice_refocus(&ssr_grad,"ssr");               // slice refocus gradient
  init_readout(&ro_grad,"ro",lro,np,sw);             // readout gradient
  init_readout_refocus(&ror_grad,"ror");             // dephase gradient
  init_phase(&pe_grad,"pe",lpe,nv);                  // phase encode gradient
  init_phase(&per_grad,"per",lpe,nv);                // phase encode gradient
  init_generic(&spoil_grad,"spoil",gspoil,tspoil);   // spoiler gradient

  /* RF Calculations ****************************************/
  calc_rf(&p1_rf,"tpwr1","tpwr1f");

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

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

  /* Calculate phase-rewind & spoiler gradients *************/
  pespoil_amp = 0.0;
  perTime = 0.0;
  if ((perewind[0] == 'y') && (spoilflag[0] == 'n')) {       // Rewinder, no spoiler
    calc_phase(&per_grad,WRITE,"","");
    strcpy(per_name,per_grad.name);
    perTime = per_grad.duration;
    spoil_grad.amp = 0.0;
  }
  else if ((perewind[0] == 'n') && (spoilflag[0] == 'y')) {  // Spoiler, no rewinder
    calc_generic(&spoil_grad,WRITE,"","");
    strcpy(per_name,spoil_grad.name);
    perTime = spoil_grad.duration;
    pespoil_amp = spoil_grad.amp;      // Apply spoiler on PE axis if no rewinder
  }
  else if ((perewind[0] == 'y') && (spoilflag[0] == 'y')) {  // Rewinder and spoiler
    calc_phase(&per_grad,NOWRITE,"","");
    calc_generic(&spoil_grad,NOWRITE,"","");
    calc_sim_gradient(&per_grad,&spoil_grad,&null_grad,0.0,WRITE);
    strcpy(per_name,per_grad.name);
    perTime = per_grad.duration;
  }

  /* Create optional prepulse events ************************/
  if (sat[0] == 'y')  create_satbands();
  if (fsat[0] == 'y') create_fatsat();
  if (mt[0] == 'y')   create_mtc();
  if (ovs[0] == 'y') {
    /* Must set up a few voxel specific parameters for create_ovsbands() to function */
    vox1_grad.thickness   = vox1;
    vox2_grad.thickness   = vox2;
    vox3_grad.thickness   = vox3;
    vox1_grad.rfBandwidth = vox2_grad.rfBandwidth = vox3_grad.rfBandwidth = p1_rf.bandwidth;
    create_ovsbands();
  }

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

    tauIR = ss_grad.duration - ss_grad.rfCenterBack; // Duration of ss_grad before RF center
    ti_delay = ti - (ssi_grad.rfCenterFront + tauIR);

    if (ti_delay < 0) {
      abort_message("TI too short, Minimum TI = %.2fms\n",(ti-ti_delay)*1000);
    }
    irTime = 4e-6 + ti + ssi_grad.duration - ssi_grad.rfCenterBack;  // Time to add to TR
  }
  
  /* Check that all Gradient calculations are ok ************/
  sgl_error_check(sglerror);

  /* Min TE ******************************************/
  tau1 = ss_grad.rfCenterBack + pe_grad.duration + alfa + ro_grad.timeToEcho;

  temin = tau1 + 4e-6;  /* ensure that te_delay is at least 4us */
  if (minte[0] == 'y') {
    te = temin;
    putvalue("te",te);
  }
  if (te < temin) {
    abort_message("TE too short.  Minimum TE= %.2fms\n",temin*1000+0.005);   
  }
  te_delay = te - tau1;
   
  /* Min TR ******************************************/   	
  seqtime  = ss_grad.duration + te_delay + pe_grad.duration
           + ro_grad.duration + perTime + tep + alfa;

  /* Increase TR if any options are selected ****************/
  if (sat[0] == 'y')  seqtime += satTime;
  if (fsat[0] == 'y') seqtime += fsatTime;
  if (mt[0] == 'y')   seqtime += mtTime;
  if (ovs[0] == 'y')  seqtime += ovsTime;
  if (ir[0] == 'y') {
    seqtime += irTime;
    seqtime -= tauIR;  /* subtract out ss_grad which was already included in TR */
  }

  trmin = seqtime + 4e-6;  /* ensure that tr_delay is at least 4us */
  trmin *= ns;
  if (mintr[0] == 'y') {
    tr = trmin;
    putvalue("tr",tr);
  }
  if (tr < trmin) {
    abort_message("TR too short.  Minimum TR= %.2fms\n",trmin*1000+0.005);   
  }
  tr_delay = (tr - seqtime*ns)/ns;

  /* Set up frequency offset pulse shape list ********/   	
  offsetlist(pss,ss_grad.ssamp,0,freqEx,ns,seqcon[1]);
  shapeEx = shapelist(p1pat,ss_grad.rfDuration,freqEx,ns,0,seqcon[1]);
  if (ir[0] == 'y') {
    offsetlist(pss,ssi_grad.ssamp,0,freqIR,ns,seqcon[1]);
    shapeIR = shapelist(pipat,ssi_grad.rfDuration,freqIR,ns,0,seqcon[1]);
  }
  
  /* Set pe_steps for profile or full image **********/   	
  pe_steps = prep_profile(profile[0],nv,&pe_grad,&per_grad);
  initval(pe_steps/2.0,vpe_offset);

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

  g_setExpTime(tr*(nt*pe_steps*arraydim + ssc));

  /* PULSE SEQUENCE *************************************/
  status(A);
  rotate();
  obsoffset(resto);
  delay(4e-6);
  initval(fabs(ssc),vssc);      // Compressed steady-state counter
  assign(zero,vrfspoil_ctr);    // RF spoil phase counter
  assign(zero,vrfspoil);        // RF spoil multiplier
  assign(one,vacquire);         // real-time acquire flag
  setacqvar(vacquire);          // Turn on acquire when vacquire is zero 

  /* Delay all channels except gradient *****************/       
  sub(ssval,ssctr,v30);
  add(v30,ct,v30);
  if (ix == 1) { ifzero(v30); grad_advance(tep); endif(v30); }

  /* Begin phase-encode loop ****************************/       
  peloop(seqcon[2],pe_steps,vpe_steps,vpe_ctr);

    /* Compressed steady-states: 1st array & transient, all arrays if ssc is negative */
    if ((ix > 1) && (ssc > 0))
      assign(zero,vssc);
    sub(vpe_ctr,vssc,vpe_ctr);  // vpe_ctr counts up from -ssc
    assign(zero,vssc);
    if (seqcon[2] == 's')
      assign(zero,vacquire);    // Always acquire for non-compressed loop
    else {
      ifzero(vpe_ctr);
        assign(zero,vacquire);  // Start acquiring when vpe_ctr reaches zero
      endif(vpe_ctr);
    }

    /* Set rcvr/xmtr phase for RF spoiling *******************/
    if (rfspoil[0] == 'y') {
      incr(vrfspoil_ctr);                    // vrfspoil_ctr = 1  2  3  4  5  6
      add(vrfspoil,vrfspoil_ctr,vrfspoil);   // vrfspoil =     1  3  6 10 15 21
      xmtrphase(vrfspoil);
      rcvrphase(vrfspoil);
    }

    /* Read external kspace table if set ******************/       
    if (table)
      getelem(t1,vpe_ctr,vpe_mult);
    else {
      ifzero(vacquire);
        sub(vpe_ctr,vpe_offset,vpe_mult);
      elsenz(vacquire);
        sub(zero,vpe_offset,vpe_mult);  // Hold PE mult at initial value for steady states
      endif(vacquire);
    }

    /* PE rewinder follows PE table; zero if turned off ***/       
    if (perewind[0] == 'y')
      assign(vpe_mult,vper_mult);
    else
      assign(zero,vper_mult);

    /* Begin multislice loop ******************************/       
    msloop(seqcon[1],ns,vms_slices,vms_ctr);
      triggerSelect(trigger);           // Selectable trigger input
      delay(4e-6);
      if (ticks) {
        xgate(ticks);
        grad_advance(tep);              // Gradient propagation delay
      }

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

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

      /* Optional IR pulse **********************************/ 
      if (ir[0] == 'y') {
	obspower(ir_rf.powerCoarse);
	obspwrf(ir_rf.powerFine);
	delay(4e-6);
	obl_shapedgradient(ssi_grad.name,ssi_grad.duration,0,0,ssi_grad.amp,NOWAIT);
	delay(ssi_grad.rfDelayFront);
	shapedpulselist(shapeIR,ssi_grad.rfDuration,oph,rof2,rof2,seqcon[1],vms_ctr);
	delay(ssi_grad.rfDelayBack);
	delay(ti_delay);
      }

      /* Slice select RF pulse ******************************/ 
      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(shapeEx,ss_grad.rfDuration,oph,rof1,rof2,seqcon[1],vms_ctr);
      delay(ss_grad.rfDelayBack);

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

      /* TE delay *******************************************/
      delay(te_delay);

      /* Readout gradient and acquisition ********************/
      obl_shapedgradient(ro_grad.name,ro_grad.duration,ro_grad.amp,0,0,NOWAIT);
      delay(ro_grad.atDelayFront);
      startacq(alfa);
      acquire(np,1.0/sw);
      delay(ro_grad.atDelayBack);
      endacq();

      /* Rewind / spoiler gradient *********************************/
      if ((perewind[0] == 'y') || (spoilflag[0] == 'y')) {
        pe_shapedgradient(per_name,perTime,spoil_grad.amp,pespoil_amp,spoil_grad.amp,
            per_grad.increment,vper_mult,WAIT);
      }

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

    if (trtype)
      delay(ns*tr_delay);
  endpeloop(seqcon[2],vpe_ctr);

  /* Inter-image delay **********************************/
  sub(ntrt,ct,vtrimage);
  decr(vtrimage);
  ifzero(vtrimage);
    delay(trimage);
  endif(vtrimage);

}
Example #16
0
pulsesequence()
{
    /*DEFINE LOCAL VARIABLES */
    double mix,control,sattime,spacing;
    int pattern,times,jj;
    char intsub[MAXSTR],cycle[MAXSTR],sspul[MAXSTR];


    /* LOAD AND INITIALIZE VARIABLES */
    getstr("intsub",intsub);
    getstr("cycle",cycle);
    getstr("sspul",sspul);
    control = getval("control");
    sattime = getval("sattime");
    spacing = getval("spacing");
    pattern = (int)getval("pattern");
    mix = getval("mix");
    if (pattern == 0) pattern = 1;
    if (tau == 0.0) tau = 0.1;
    times = (int)(sattime/(pattern*tau));

    /* CHECK CONDITIONS */
    if (!newtrans)
    {
        fprintf(stdout,"REQUIRED:  direct syn. RF and linear amplifiers.\n");
        psg_abort(1);
    }


    /* CALCULATE PHASES */
    if (intsub[0] == 'y') hlv(ct,v1);
    else assign(ct,v1);
    assign(v1,oph);
    if (intsub[0] == 'y')
    {
        mod2(ct,v14);  /* trigger for the alteration of the saturation freq */
        ifzero(v14);
        add(oph,two,oph);
        endif(v14);
    }


    /* BEGIN ACTUAL PULSE SEQUENCE CODE */
    status(A);
    if (sspul[A] == 'y')
    {
        pulse(200*pw,zero);
        pulse(200*pw,one);
    }
    hsdelay(d1);
    obspower(satpwr);
    delay(0.2e-6);                             /*reduce xmtr leakage */
    status(B);

    /* selective pulse or decoupler saturation */
    /* no cycling or interleaved subtraction (make control an array)*/
    if ((intsub[0] == 'n') && (cycle[0] == 'n'))
    {
        obsoffset(satfrq);
        rgpulse(sattime,zero,rof1,rof2);
    }
    /* interleaved subtraction without cycling */
    if ((intsub[0] == 'y') && (cycle[0] == 'n'))
    {
        ifzero(v14);
        obsoffset(control);
        rgpulse(sattime,zero,rof1,rof2);
        elsenz(v14);
        obsoffset(satfrq);
        rgpulse(sattime,zero,rof1,rof2);
        endif(v14);
    }
    /* no interleaved subtraction but cycling is used (make cycle array)*/
    if ((cycle[0] == 'y') && (intsub[0] == 'n'))
    {
        for (jj = 0; jj < times; jj++)
        {
            double startfrq;
            int i;
            startfrq = satfrq - (pattern/2)*spacing;
            if ((pattern %2) == 0) startfrq = startfrq + spacing/2.0;
            for (i = 0; i < pattern; i++)
            {
                obsoffset(startfrq);
                rgpulse(tau,zero,rof1,rof2);
                startfrq = startfrq + spacing;
            }
        }
    }
    /* interleaved subtraction with cycling (no array needed for one
       value of satfrq. Link array satfrq with pattern and spacing for
       multiple noe difference spectra within one experiment. For example
       set array = '(satfrq,pattern,spacing)') */

    if ((cycle[0] == 'y') && (intsub[0] == 'y'))
    {
        ifzero(v14);
        for (jj = 0; jj < times; jj++)
        {
            double startfrq;
            int i;
            startfrq = control - (pattern/2)*spacing;
            if ((pattern %2) == 0) startfrq = startfrq + spacing/2.0;
            for (i = 0; i < pattern; i++)
            {
                obsoffset(startfrq);
                rgpulse(tau,zero,rof1,rof2);
                startfrq = startfrq + spacing;
            }
        }
        elsenz(v14);
        for (jj = 0; jj < times; jj++)
        {
            double startfrq;
            int i;
            startfrq = satfrq - (pattern/2)*spacing;
            if ((pattern %2) == 0) startfrq = startfrq + spacing/2.0;
            for (i = 0; i < pattern; i++)
            {
                obsoffset(startfrq);
                rgpulse(tau,zero,rof1,rof2);
                startfrq = startfrq + spacing;
            }
        }
        endif(v14);
    }
    /* restore power levels as controlled by tpwr   */
    obsoffset(tof);
    obspower(tpwr);


    status(C);
    /* NOE mixing time */
    hsdelay(mix);
    status(D);
    /* sampling pulse */
    rgpulse(pw,v1,rof1,rof2);
}
Example #17
0
pulsesequence()
{
   double	   slpwrT = getval("slpwrT"),
		   slpwT = getval("slpwT"),
		   mixT = getval("mixT"),
		   gzlvl1 = getval("gzlvl1"),
		   gt1 = getval("gt1"),
		   gzlvl2 = getval("gzlvl2"),
		   gt2 = getval("gt2"),
		   gstab = getval("gstab"),
                   selpwrA = getval("selpwrA"),
                   selpwA = getval("selpwA"),
                   gzlvlA = getval("gzlvlA"),
                   gtA = getval("gtA"),
                   selpwrB = getval("selpwrB"),
                   selpwB = getval("selpwB"),
                   gzlvlB = getval("gzlvlB"),
                   gtB = getval("gtB"),
		   selfrq = getval("selfrq"),
                   zqfpw1 = getval("zqfpw1"),
                   zqfpwr1 = getval("zqfpwr1"),
                   zqfpw2 = getval("zqfpw2"),
                   zqfpwr2 = getval("zqfpwr2"),
                   gzlvlzq1 = getval("gzlvlzq1"),
                   gzlvlzq2 = getval("gzlvlzq2");
                   
   char		   slpatT[MAXSTR],
                   selshapeA[MAXSTR],
                   selshapeB[MAXSTR],
                   zqfpat1[MAXSTR],
                   zqfpat2[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("zqfpat1",zqfpat1);
   getstr("zqfpat2",zqfpat2);

   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);

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

   ifzero(ssctr);
      assign(ct,v13);
   elsenz(ssctr);
      sub(ssval, ssctr, v13); /* v13 = 0,...,ss-1 */
   endif(ssctr);

   mod4(v13,v1); /* v1 = 0 1 2 3 */
   hlv(v13,v13);
   hlv(v13,v13);
   mod4(v13,v11); /* v11 = 0000 1111 2222 3333 */
   dbl(v1,oph);
   add(v11,oph,oph);
   add(v11,oph,oph); /* oph = 2v1 + 2v11 */

/* CYCLOPS */
   hlv(v13,v13);
   hlv(v13,v14);
   add(v1,v14,v1);
   add(v11,v14,v11);
   add(oph,v14,oph);
   assign(v14,v3);
   add(one,v3,v3);
   add(two,v3,v12);

   sub(v3,one,v2);
   add(v3,one,v4);
   add(v3,two,v5);

/* BEGIN THE ACTUAL PULSE SEQUENCE */
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);
        satpulse(satdly,v6,rof1,rof1);
     }
   else
        delay(d1);

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

   status(B);

        rgpulse(pw, v14, rof1, rof1);

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

        zgradpulse(gzlvlA,gtA);
        delay(gstab);
        obspower(selpwrA);
        shaped_pulse(selshapeA,selpwA,v1,rof1,rof1);
        obspower(tpwr);
        zgradpulse(gzlvlA,gtA);
        delay(gstab);

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

        zgradpulse(gzlvlB,gtB);
        delay(gstab);
        obspower(selpwrB);
        shaped_pulse(selshapeB,selpwB,v11,rof1,rof1);
        obspower(tpwr);
        zgradpulse(gzlvlB,gtB);
        delay(gstab);

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

        rgpulse(pw, v14, rof1, rof1);
        if (getflag("Gzqfilt"))
        {
         obspower(zqfpwr1);
         rgradient('z',gzlvlzq1);
         delay(100.0e-6);
         shaped_pulse(zqfpat1,zqfpw1,v14,rof1,rof1);
         delay(100.0e-6);
         rgradient('z',0.0);
         delay(gstab);
        }
        obspower(slpwrT);

        zgradpulse(gzlvl1,gt1);
        delay(gstab);

	if (mixT > 0.0)
	{
          if (dps_flag)
          	rgpulse(mixT,v3,0.0,0.0);
          else
          	SpinLock(slpatT,mixT,slpwT,v2,v3,v4,v5, v9);
        }

        if (getflag("Gzqfilt"))
        {
         obspower(zqfpwr2);
         rgradient('z',gzlvlzq2);
         delay(100.0e-6);
         shaped_pulse(zqfpat2,zqfpw2,v14,rof1,rof1);
         delay(100.0e-6);
         rgradient('z',0.0);
         delay(gstab);
        }
        obspower(tpwr);

        zgradpulse(gzlvl2,gt2);
        delay(gstab);

	rgpulse(pw,v14,rof1,rof2);

   status(C);
}
Example #18
0
/*-------------------------------------------------------------------
|
|	test4acquire() 
|	check too see if data has been acquired yet.
|	if it has not then do an implicit acuire.
|	else do not.
|				Author Greg Brissey  7/10/86
+------------------------------------------------------------------*/
void test4acquire()
{
    int	    i;
    int	    chan;
    int     MINch;
    double  acqdelay;	/* delay time between receiver On an data acquired*/
    codeint *tmpptr;	/* temp pointer into codes */
    extern void prg_dec_off();
    double truefrq=0.0, dqdfrq=0.0;
    char osskip[4];

    if (bgflag)
	fprintf(stderr,"test4acquire(): acqtriggers = %d \n",acqtriggers);
    if (acqtriggers == 0)	/* No data acquisition Yet? */
    {
	if (nf > 1.0)
	{
	    text_error("Number of FIDs (nf) Not Equal to One\n");
	    psg_abort(0);
	}
        if (ap_interface < 4)
	   HSgate(rcvr_hs_bit,FALSE);	/* turn receiver On */
	else
           SetRFChanAttr(RF_Channel[OBSch], SET_RCVRGATE, ON, 0);

	if (newacq)
        {
           /* execute osskip delay if osskip parameter set */
           if ((P_getstring(GLOBAL,"qcomp",osskip,1,2)) == 0)
           {
             if (osskip[0] == 'y')
             {
               /* fprintf(stderr,"hwlooping:test4acquire(): executing dsposskipdelay= %g\n", dsposskipdelay); */
               if (dsposskipdelay >= 0.0) G_Delay(DELAY_TIME, dsposskipdelay, 0);
             }
           }

           HSgate(INOVA_RCVRGATE,FALSE);        /* turn receiver On */
        }

	/* txphase(zero);	*/	/* set xmitter phase to zero */
	/* decphase(zero);	*/	/* set decoupler phase to zero */
	/* acqdelay = alfa + (1.0 / (beta * fb) ); */

	for (i = 1; i <= NUMch; i++)  /* zero HS phaseshifts */
	   SetRFChanAttr(RF_Channel[i], SET_RTPHASE90, zero, 0);

	if ((!noiseacquire) && (dsp_params.il_oversamp > 1))
	   find_dqdfrq(&truefrq, &dqdfrq);
	if (fabs(dqdfrq) > 0.1)
	   set_spare_freq(OBSch); 
/*	   obsoffset(truefrq+dqdfrq); */

	acqdelay = alfa + (1.0 / (beta * fb) );
	if (acqdelay > ACQUIRE_START_DELAY)
	   acqdelay = acqdelay - ACQUIRE_START_DELAY;
	if ((fabs(dqdfrq) > 0.1) && (acqdelay > 1.7e-6)) /* more like 40us?? */
	    acqdelay = acqdelay - 1.7e-6;

        if ((acqdelay < 0.0) && (ix == 1))
	   text_error("Acquisition filter delay (fb, alfa) is negative (%f).\n",
             acqdelay);
        else
	   G_Delay(DELAY_TIME,acqdelay,0);	/* alfa delay */
	acquire(np,1.0/sw);	/* acquire data */

	MINch = (ap_interface < 4) ? DODEV : TODEV;
	for (chan = MINch; chan <= NUMch; chan++)
	{
           if ( is_y(rfwg[chan-1]) )
           {
	      if ( (ModInfo[chan].MI_dm[0] == 'n') ||
                   ((ModInfo[chan].MI_dm[0] == 'y') &&
		    (ModInfo[chan].MI_dmm[0] != 'p')) )
              {
                 prg_dec_off(2, chan);
              }
           }
        }

	tmpptr = Aacode + multhwlp_ptr; /* get address into codes */
	*tmpptr = 1;		/* impliicit acquisition */
    }
    if (newacq)
    {
	if (explicitacq)
	{
              codeint *ptr;
	      /* update last acquire with disable overload */;
    	      ptr = Aacode + disovld_ptr;
	      *ptr++ = DISABLEOVRFLOW;
      	      *ptr = adccntrl;
	}
	/* Always set to FALSE for the next array element */
	explicitacq = FALSE;
    }

    if (grad_flag == TRUE) 
    {
      zero_all_gradients();
    }
    if (newacq)
    {
      gatedecoupler(A,15.0e-6);	/* init to status A conditions */
      statusindx = A;
    }
    putcode(STFIFO);	/* start fifo if it already hasn't */
    putcode(HKEEP);		/* do house keeping */
    if (newacq)
    {
      if ( getIlFlag() )
      {
	ifzero(ilflagrt);
    	   putcode(IFZFUNC);	/* brach to start of scan (NSC) if ct<nt */
	   putcode((codeint)ct);
	   putcode((codeint)ntrt);
    	   putcode(nsc_ptr);	/* pointer to nsc */
	elsenz(ilflagrt);
     	   add(strt,one,tmprt);	
   	   putcode(IFZFUNC);	/* brach to start of scan (NSC) if ct<strt+1 */
	   putcode((codeint)ct);
	   putcode((codeint)tmprt);
    	   putcode(nsc_ptr);	/* pointer to nsc */
	   modn(ct, bsval, tmprt);
    	   putcode(IFZFUNC);	/* brach to start of scan (NSC) if ct%bs */
	   putcode((codeint)zero);
	   putcode((codeint)tmprt);
    	   putcode(nsc_ptr);	/* pointer to nsc */
	endif(ilflagrt);
      }
      else
      {
    	   putcode(IFZFUNC);	/* brach to start of scan (NSC) if ct<nt */
	   putcode((codeint)ct);
	   putcode((codeint)ntrt);
    	   putcode(nsc_ptr);	/* pointer to nsc */
      }
    }
    else
    {
    	putcode(BRANCH);	/* brach back to start of scan (NSC) */
    	putcode(nsc_ptr);	/* pointer to nsc */
    }
}
Example #19
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 #20
0
pulsesequence()
{
  /* Internal variable declarations *********************/
  double  freq90[MAXNSLICE],freq180[MAXNSLICE];
  double  te_delay1,te_delay2,tr_delay,tau1,tau2,thk2fact,te_delay3=0.0,te_delay4=0.0,navTime=0.0;
  double  crushm0,pem0,gcrushr,gcrushp,gcrushs,pecrush;
  double  refsign=1,crushsign=1,navsign=1;
  int     shape90,shape180,table=0,sepRefocus;
  char    slprofile[MAXSTR];

  /* sequence dependent diffusion variables */
  double Gro,Gss;          // "gdiff" for readout/readout refocus and slice/slice refocus
  double dgro,dgss;        // "delta" for readout/readout refocus and slice/slice refocus
  double Dgro,Dgss;        // "DELTA" for readout/readout refocus and slice/slice refocus
  double dcrush,dgss2;     // "delta" for crusher and gss2 gradients
  double Dcrush,Dgss2;     // "DELTA" for crusher and gss2 gradients

  int    i;

  /* Real-time variables used in this sequence **********/
  int  vpe_steps  = v1;    // Number of PE steps
  int  vpe_ctr    = v2;    // PE loop counter
  int  vms_slices = v3;    // Number of slices
  int  vms_ctr    = v4;    // Slice loop counter
  int  vpe_offset = v5;    // PE/2 for non-table offset
  int  vpe_mult   = v6;    // PE multiplier, ranges from -PE/2 to PE/2
  int  vph180     = v7;    // Phase of 180 pulse
  int  vph2       = v8;    // alternate phase of 180 on odd transients
  int  vssc       = v9;    // Compressed steady-states
  int  vtrimage   = v10;   // Counts down from nt, trimage delay when 0
  int  vacquire   = v11;   // Argument for setacqvar, to skip steady state acquires
  int  vtrigblock = v12;   // Number of slices per trigger block

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

  thk2fact=getval("thk2fact");
  pecrush=getval("pecrush");
  sepRefocus=getvalnwarn("sepRefocus");
  getstrnwarn("slprofile",slprofile);

  /*  Check for external PE table ***********************/
  init_tablepar("pelist");          // Initialize pelist parameter
  if (strcmp(petable,"n") && strcmp(petable,"N") && strcmp(petable,"")) {
    loadtable(petable);
    writetabletopar(t1,"pelist");   // Write t1 table to pelist parameter
    table = 1;
  }

  /* RF Power & Bandwidth Calculations ******************/
  shape_rf(&p1_rf,"p1",p1pat,p1,flip1,rof1,rof2);
  shape_rf(&p2_rf,"p2",p2pat,p2,flip2,rof1,rof2);
  calc_rf(&p1_rf,"tpwr1","tpwr1f");
  calc_rf(&p2_rf,"tpwr2","tpwr2f");

  /* Initialize gradient structures *********************/
  init_slice(&ss_grad,"ss",thk);
  init_slice(&ss2_grad,"ss2",thk*thk2fact);
  init_dephase(&crush_grad,"crush");
  init_slice_refocus(&ssr_grad,"ssr");
  if (FP_LT(tcrushro,alfa)) tcrushro=alfa;
  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_generic(&spoil_grad,"spoil",gspoil,tspoil);

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

  /* Make sure crushing in PE dimension does not refocus signal from 180 */
  crushm0=fabs(gcrush*tcrush);
  pem0=0.0; gcrushp=0.0;
  if (pecrush) pem0=pe_grad.m0;
  calc_dephase(&crush_grad,WRITE,crushm0+pem0,"","");
  gcrushr = crush_grad.amp*crushm0/crush_grad.m0;
  if (pecrush) gcrushp = crush_grad.amp;
  gcrushs = crush_grad.amp*crushm0/crush_grad.m0;

  /* Allow phase encode and read dephase to be separated from slice refocus */
  if (sepRefocus) {
    /* Equalize read dephase and PE gradient durations */
    calc_sim_gradient(&ror_grad,&pe_grad,&null_grad,0,WRITE);
    crushsign=-1;
  } else {
    if (slprofile[0] == 'y') {
      /* Combined slice refocusing and read dephasing,
         reverse gradient sign if ror > ssr integral */
      refsign = (ss_grad.m0ref > ro_grad.m0ref) ? 1.0 : -1.0;
      ss_grad.m0ref -= ro_grad.m0ref;
      calc_slice_refocus(&ssr_grad,&ss_grad,NOWRITE,"gssr");
    }
    /* Equalize both refocus and PE gradient durations */
    calc_sim_gradient(&ror_grad,&pe_grad,&ssr_grad,0,WRITE);
  }

  /* Create optional prepulse events ********************/
  if (fsat[0] == 'y') create_fatsat();
  if (sat[0] == 'y')  create_satbands();
  if (mt[0] == 'y')   create_mtc();
  if (ir[0] == 'y')   create_inversion_recovery();
  if (diff[0] == 'y') init_diffusion(&diffusion,&diff_grad,"diff",gdiff,tdelta);

  sgl_error_check(sglerror);

  /* Min TE *********************************************/
  te = granularity(te,2*GRADIENT_RES);
  /* tau1, tau2 are the sum of events in each half echo period */
  /* tau1, tau2 include a GRADIENT_RES as this is minimum delay time */
  tau1 = ss_grad.rfCenterBack + ssr_grad.duration + crush_grad.duration + ss2_grad.rfCenterFront + 2*GRADIENT_RES;
  tau2 = ss2_grad.rfCenterBack + crush_grad.duration + ro_grad.timeToEcho + GRADIENT_RES;
  if (sepRefocus) tau2 += ror_grad.duration;
  temin = 2*MAX(tau1,tau2);

  /* Diffusion ******************************************/
  if (diff[0] == 'y') {
    /* granulate tDELTA */
    tDELTA = granularity(tDELTA,GRADIENT_RES);
    /* taudiff is the duration of events between diffusion gradients */
    taudiff = ss2_grad.duration + 2*crush_grad.duration + GRADIENT_RES;
    /* set minimum diffusion structure requirements for gradient echo: taudiff, tDELTA, te and minte[0] */
    set_diffusion(&diffusion,taudiff,tDELTA,te,minte[0]);
    /* set additional diffusion structure requirements for spin echo: tau1 and tau2 */
    set_diffusion_se(&diffusion,tau1,tau2);
    /* calculate the diffusion structure delays.
       address &temin is required in order to update temin accordingly */
    calc_diffTime(&diffusion,&temin);
  }

  /* TE delays ******************************************/
  if (minte[0] == 'y') {
    te = temin;
    putvalue("te",te);
  }
  if (FP_LT(te,temin)) {
    abort_message("TE too short, minimum TE = %.3f ms\n",temin*1000);
  }
  te_delay1 = te/2 - tau1 + GRADIENT_RES;
  te_delay2 = te/2 - tau2 + GRADIENT_RES;

  if (navigator[0] == 'y') {
    /* tau1, tau2 are the sum of events in each half echo period */
    tau1 = ro_grad.timeFromEcho + pe_grad.duration + crush_grad.duration + ss2_grad.rfCenterFront;
    tau2 = ss2_grad.rfCenterBack + crush_grad.duration + ro_grad.timeToEcho;
    if (FP_GT(tau1,tau2)) {
      te_delay3 = GRADIENT_RES;
      te_delay4 = tau1-tau2+GRADIENT_RES;
    } else {
      te_delay3 = tau2-tau1+GRADIENT_RES;
      te_delay4 = GRADIENT_RES;
    }
    navTime = te_delay3 + ss2_grad.duration + 2*crush_grad.duration + ro_grad.duration + te_delay4 + 2*GRADIENT_RES;
  }

  /* Check nsblock, the number of slices blocked together
     (used for triggering and/or inversion recovery) */
  check_nsblock();

  /* Min TR *********************************************/   	
  trmin = ss_grad.rfCenterFront  + te + ro_grad.timeFromEcho + pe_grad.duration + 2*GRADIENT_RES;

  /* Increase TR if any options are selected ************/
  if (spoilflag[0] == 'y') trmin += spoil_grad.duration;
  if (navigator[0] == 'y') trmin += navTime;
  if (sat[0] == 'y')       trmin += satTime;
  if (fsat[0] == 'y')      trmin += fsatTime;
  if (mt[0] == 'y')        trmin += mtTime;
  if (ticks > 0)           trmin += GRADIENT_RES;

  /* Adjust for all slices ******************************/
  trmin *= ns;

  /* Inversion recovery *********************************/
  if (ir[0] == 'y') {
    /* tauti is the additional time beyond IR component to be included in ti */
    /* satTime, fsatTime and mtTime all included as those modules will be after IR */
    tauti = satTime + fsatTime + mtTime + GRADIENT_RES + ss_grad.rfCenterFront;
    /* calc_irTime checks ti and returns the time of all IR components */
    trmin += calc_irTime(tauti,trmin,mintr[0],tr,&trtype);
  }

  if (mintr[0] == 'y') {
    tr = trmin;
    putvalue("tr",tr);
  }
  if (FP_LT(tr,trmin)) {
    abort_message("TR too short, minimum TR = %.3f ms\n",trmin*1000);
  }

  /* TR delay *******************************************/
  tr_delay = granularity((tr-trmin)/ns,GRADIENT_RES);

  /* Calculate B values *********************************/
  if (ix == 1) {
    /* Calculate bvalues according to main diffusion gradients */
    calc_bvalues(&diffusion,"dro","dpe","dsl");
    /* Add components from additional diffusion encoding imaging gradients peculiar to this sequence */
    /* Initialize variables */
    dgro = 0.5*(ror_grad.duration+ro_grad.timeToEcho);
    Gro = ro_grad.m0ref/dgro; Dgro = dgro;
    if (!sepRefocus) Dgro = te-ss_grad.rfCenterBack-ro_grad.timeToEcho;
    dgss = 0.5*(ss_grad.rfCenterBack+ssr_grad.duration);
    Gss = ss_grad.m0ref/dgss; Dgss = dgss;
    dgss2 = ss2_grad.duration/2; Dgss2 = dgss2;
    dcrush = crush_grad.duration-crush_grad.tramp; Dcrush = crush_grad.duration+ss2_grad.duration;
    for (i = 0; i < diffusion.nbval; i++)  {
      /* set droval, dpeval and dslval */
      set_dvalues(&diffusion,&droval,&dpeval,&dslval,i);
      /* Readout */
      diffusion.bro[i] += bval(Gro,dgro,Dgro);
      diffusion.bro[i] += bval(crushsign*gcrushr,dcrush,Dcrush);
      diffusion.bro[i] += bval_nested(gdiff*droval,tdelta,tDELTA,crushsign*gcrushr,dcrush,Dcrush);
      if (!sepRefocus) {
        diffusion.bro[i] += bval_nested(Gro,dgro,Dgro,gdiff*droval,tdelta,tDELTA);
        diffusion.bro[i] += bval_nested(Gro,dgro,Dgro,crushsign*gcrushr,dcrush,Dcrush);
      }
      /* Phase */
      if (pecrush) {
        diffusion.bpe[i] += bval(gcrushp,dcrush,Dcrush);
        diffusion.bpe[i] += bval_nested(gdiff*dpeval,tdelta,tDELTA,gcrushp,dcrush,Dcrush);
      }
      /* Slice */
      diffusion.bsl[i] += bval(Gss,dgss,Dgss);
      diffusion.bsl[i] += bval(gcrushs,dcrush,Dcrush);
      diffusion.bsl[i] += bval(ss2_grad.ssamp,dgss2,Dgss2);
      diffusion.bsl[i] += bval_nested(gdiff*dslval,tdelta,tDELTA,gcrushs,dcrush,Dcrush);
      diffusion.bsl[i] += bval_nested(gdiff*dslval,tdelta,tDELTA,ss2_grad.ssamp,dgss2,Dgss2);
      diffusion.bsl[i] += bval_nested(gcrushs,dcrush,Dcrush,ss2_grad.ssamp,dgss2,Dgss2);
      /* Readout/Phase Cross-terms */
      diffusion.brp[i] += bval_cross(gdiff*dpeval,tdelta,tDELTA,crushsign*gcrushr,dcrush,Dcrush);
      diffusion.brp[i] += bval_cross(gdiff*dpeval,tdelta,tDELTA,crushsign*gcrushr,dcrush,Dcrush);
      if (pecrush) diffusion.brp[i] += bval_cross(gdiff*droval,tdelta,tDELTA,gcrushp,dcrush,Dcrush);
      if (!sepRefocus) {
        diffusion.brp[i] += bval_cross(Gro,dgro,Dgro,gdiff*dpeval,tdelta,tDELTA);
        if (pecrush) diffusion.brp[i] += bval_cross(Gro,dgro,Dgro,gcrushp,dcrush,Dcrush);
      }
      /* Readout/Slice Cross-terms */
      diffusion.brs[i] += bval2(crushsign*gcrushr,gcrushs,dcrush,Dcrush);
      diffusion.brs[i] += bval_cross(gdiff*droval,tdelta,tDELTA,gcrushs,dcrush,Dcrush);
      diffusion.brs[i] += bval_cross(gdiff*dslval,tdelta,tDELTA,crushsign*gcrushr,dcrush,Dcrush);
      diffusion.brs[i] += bval_cross(gdiff*droval,tdelta,tDELTA,ss2_grad.ssamp,dgss2,Dgss2);
      if (!sepRefocus) {
        diffusion.brs[i] += bval_cross(Gro,dgro,Dgro,gdiff*dslval,tdelta,tDELTA);
        diffusion.brs[i] += bval_cross(Gro,dgro,Dgro,gcrushs,dcrush,Dcrush);
        diffusion.brs[i] += bval_cross(Gro,dgro,Dgro,ss2_grad.ssamp,dgss2,Dgss2);
      }
      /* Slice/Phase Cross-terms */
      diffusion.bsp[i] += bval_cross(gdiff*dpeval,tdelta,tDELTA,gcrushs,dcrush,Dcrush);
      diffusion.bsp[i] += bval_cross(gdiff*dpeval,tdelta,tDELTA,ss2_grad.ssamp,dgss2,Dgss2);
      if (pecrush) { 
        diffusion.bsp[i] += bval2(gcrushs,gcrushp,dcrush,Dcrush);
        diffusion.bsp[i] += bval_cross(gdiff*dslval,tdelta,tDELTA,gcrushp,dcrush,Dcrush);
        diffusion.bsp[i] += bval_cross(gcrushp,dcrush,Dcrush,ss2_grad.ssamp,dgss2,Dgss2);
      }
    }  /* End for-all-directions */
    /* Write the values */
    write_bvalues(&diffusion,"bval","bvalue","max_bval");
  }

  /* Generate phase-ramped pulses ***********************/
  offsetlist(pss,ss_grad.ssamp,0,freq90,ns,seqcon[1]);
  offsetlist(pss,ss2_grad.ssamp,0,freq180,ns,seqcon[1]);
  shape90 = shapelist(p1_rf.pulseName,ss_grad.rfDuration,freq90,ns,ss_grad.rfFraction,seqcon[1]);
  shape180 = shapelist(p2_rf.pulseName,ss2_grad.rfDuration,freq180,ns,ss2_grad.rfFraction,seqcon[1]);

  /* Set pe_steps for profile or full image *************/   	
  pe_steps = prep_profile(profile[0],nv,&pe_grad,&null_grad);
  F_initval(pe_steps/2.0,vpe_offset);

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

  /* Adjust experiment time for VnmrJ *******************/
  if (ssc<0) {
    if (seqcon[2] == 'c') g_setExpTime(trmean*(ntmean*pe_steps*arraydim - ssc*arraydim));
    else g_setExpTime(trmean*(ntmean*pe_steps*arraydim - ssc*pe_steps*arraydim));
  }
  else g_setExpTime(trmean*ntmean*pe_steps*arraydim + tr*ssc);

  /* Slice profile **************************************/
  if (slprofile[0] == 'y' && !sepRefocus) ror_grad.amp = 0;

  /* Set phase cycle table ******************************/
  if (sepRefocus) settable(t2,1,ph180); // Phase encode is just before readout
  else settable(t2,2,ph180);

  /* PULSE SEQUENCE *************************************/
  status(A);                          // Set status A
  rotate();                           // Set gradient rotation according to psi, phi and theta
  triggerSelect(trigger);             // Select trigger input 1/2/3
  obsoffset(resto);                   // Set spectrometer frequency
  delay(GRADIENT_RES);                // Delay for frequency setting
  initval(fabs(ssc),vssc);            // Compressed steady-state counter
  if (seqcon[2]=='s') assign(zero,vssc); // Zero for standard peloop
  assign(one,vacquire);               // real-time acquire flag
  setacqvar(vacquire);                // Turn on acquire when vacquire is zero 

  /* trigger */
  if (ticks > 0) F_initval((double)nsblock,vtrigblock);

  /* Begin phase-encode loop ****************************/       
  peloop(seqcon[2],pe_steps,vpe_steps,vpe_ctr);

    if (trtype) delay(ns*tr_delay);   // relaxation delay

    /* Compressed steady-states: 1st array & transient, all arrays if ssc is negative */
    if ((ix > 1) && (ssc > 0))
      assign(zero,vssc);
    sub(vpe_ctr,vssc,vpe_ctr);        // vpe_ctr counts up from -ssc
    assign(zero,vssc);
    if (seqcon[2] == 's')
      assign(zero,vacquire);          // Always acquire for non-compressed loop
    else {
      ifzero(vpe_ctr);
        assign(zero,vacquire);        // Start acquiring when vpe_ctr reaches zero
      endif(vpe_ctr);
    }

    /* Read external kspace table if set ******************/       
    if (table)
      getelem(t1,vpe_ctr,vpe_mult);
    else {
      ifzero(vacquire);
        sub(vpe_ctr,vpe_offset,vpe_mult);
      elsenz(vacquire);
        sub(zero,vpe_offset,vpe_mult);      // Hold PE mult at initial value for steady states
      endif(vacquire);
    }

    /* Phase cycle ****************************************/       
    getelem(t2,vpe_ctr,vph180);             // For phase encoding with slice rephase
    add(oph,vph180,vph180);                 // 180 deg pulse phase alternates +/- 90 from receiver
    mod2(ct,vph2);
    dbl(vph2,vph2);
    add(vph180,vph2,vph180);                // Alternate phase for 180 on odd transients

    /* Begin multislice loop ******************************/       
    msloop(seqcon[1],ns,vms_slices,vms_ctr);

      if (!trtype) delay(tr_delay);         // Relaxation delay

      if (ticks > 0) {
        modn(vms_ctr,vtrigblock,vtest);
        ifzero(vtest);                      // if the beginning of an trigger block
          xgate(ticks);
          grad_advance(gpropdelay);
          delay(GRADIENT_RES);
        elsenz(vtest);
          delay(GRADIENT_RES);
        endif(vtest);
      }

      sp1on(); delay(GRADIENT_RES); sp1off();     // Scope trigger

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

      /* Slice select RF pulse ******************************/ 
      obspower(p1_rf.powerCoarse);
      obspwrf(p1_rf.powerFine);
      delay(GRADIENT_RES);
      obl_shapedgradient(ss_grad.name,ss_grad.duration,0,0,ss_grad.amp,NOWAIT);
      delay(ss_grad.rfDelayFront);
      shapedpulselist(shape90,ss_grad.rfDuration,oph,rof1,rof2,seqcon[1],vms_ctr);
      delay(ss_grad.rfDelayBack);

      /* Slice refocus gradient *****************************/
      if (sepRefocus) 
        obl_shapedgradient(ssr_grad.name,ssr_grad.duration,0,0,-ssr_grad.amp,WAIT);
      else
        /* Include phase encode and readout dephase gradient if refocus gradients not separated */
        pe_shapedgradient(pe_grad.name,pe_grad.duration,ror_grad.amp,0,-ssr_grad.amp*refsign,pe_grad.increment,vpe_mult,WAIT);

      if (diff[0] == 'y') {
        delay(diffusion.d1);
        diffusion_dephase(&diffusion,dro,dpe,dsl);
        delay(diffusion.d2);
      } 
      else 
        delay(te_delay1);

      /* Refocusing RF pulse ********************************/ 
      obspower(p2_rf.powerCoarse);
      obspwrf(p2_rf.powerFine);
      delay(GRADIENT_RES);
      obl_shapedgradient(crush_grad.name,crush_grad.duration,crushsign*gcrushr,gcrushp,gcrushs,WAIT);
      obl_shapedgradient(ss2_grad.name,ss2_grad.duration,0,0,ss2_grad.amp,NOWAIT);
      delay(ss2_grad.rfDelayFront);
      shapedpulselist(shape180,ss2_grad.rfDuration,vph180,rof2,rof2,seqcon[1],vms_ctr);
      delay(ss2_grad.rfDelayBack);
      obl_shapedgradient(crush_grad.name,crush_grad.duration,crushsign*gcrushr,gcrushp,gcrushs,WAIT);

      if (diff[0] == 'y') {
        delay(diffusion.d3);
        diffusion_rephase(&diffusion,dro,dpe,dsl);
        delay(diffusion.d4);
      } 
      else 
        delay(te_delay2);

      /* Readout dephase, phase encode & readout gradients **/
      roff = -poffset(pro,ro_grad.roamp);  // incase inverted navigator is acquired
      if (slprofile[0] == 'y') {
        /* Readout gradient only if refocus gradients not separated */
        if (sepRefocus)
          obl_shapedgradient(ror_grad.name,ror_grad.duration,0,0,-ror_grad.amp,WAIT);
        obl_shapedgradient(ro_grad.name,ro_grad.duration,0,0,ro_grad.amp,NOWAIT);
      } else {
        /* Readout gradient only if refocus gradients not separated */
        if (sepRefocus) 
          pe_shapedgradient(pe_grad.name,pe_grad.duration,-ror_grad.amp,0,0,-pe_grad.increment,vpe_mult,WAIT);
        obl_shapedgradient(ro_grad.name,ro_grad.duration,ro_grad.amp,0,0,NOWAIT);
      }

      /* Acquisition ****************************************/
      delay(ro_grad.atDelayFront-alfa);
      startacq(alfa);
      acquire(np,1.0/sw);
      delay(ro_grad.atDelayBack);
      endacq();

      /* Rewind Phase encoding ******************************/
      pe_shapedgradient(pe_grad.name,pe_grad.duration,0,0,0,pe_grad.increment,vpe_mult,WAIT);

      /* Navigator acquisition ******************************/
      if (navigator[0] == 'y') {
        delay(te_delay3);
        obl_shapedgradient(crush_grad.name,crush_grad.duration,-crushsign*gcrushr,0,-gcrushs,WAIT);
        obl_shapedgradient(ss2_grad.name,ss2_grad.duration,0,0,ss2_grad.amp,NOWAIT);
        delay(ss2_grad.rfDelayFront);
        shapedpulselist(shape180,ss2_grad.rfDuration,vph180,rof2,rof2,seqcon[1],vms_ctr);
        delay(ss2_grad.rfDelayBack);
        obl_shapedgradient(crush_grad.name,crush_grad.duration,-crushsign*gcrushr,0,-gcrushs,WAIT);
        delay(te_delay4);
        obl_shapedgradient(ro_grad.name,ro_grad.duration,navsign*ro_grad.amp,0,0,NOWAIT);
        delay(ro_grad.atDelayFront-alfa);
        startacq(alfa);
        acquire(np,1.0/sw);
        delay(ro_grad.atDelayBack);
        endacq();
      }

      if (spoilflag[0] == 'y') {
        obl_shapedgradient(spoil_grad.name,spoil_grad.duration,navsign*spoil_grad.amp,0,spoil_grad.amp,WAIT);
      }

    endmsloop(seqcon[1],vms_ctr);

  endpeloop(seqcon[2],vpe_ctr);

  /* Inter-image delay **********************************/
  sub(ntrt,ct,vtrimage);
  decr(vtrimage);
  ifzero(vtrimage);
    delay(trimage);
  endif(vtrimage);

  /* Duty cycle *****************************************/
  calc_grad_duty(tr);

}
Example #21
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 #22
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 #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];

//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);

   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,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(t2,4,ph2);   getelem(t2,v6,v2);
   settable(t7,8,ph7);   getelem(t7,v6,v7);
   settable(t8,4,ph8);   getelem(t8,v6,v8);
   
   if (getflag("zqfilt"))
     getelem(t4,v6,oph);
   else
     assign(v1,oph);

   sub(v2,one,v3);
   add(v2,two,v4);
   add(v3,two,v5);

   mod4(ct,v10);

/* BEGIN THE ACTUAL PULSE SEQUENCE */
   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);
        satpulse(satdly,v6,rof1,rof1);
     }
   else
        delay(d1);

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

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

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

        zgradpulse(gzlvlA,gtA);
        delay(gstab);
        obspower(selpwrA);
        shaped_pulse(selshapeA,selpwA,v1,rof1,rof1);
        obspower(tpwr);
        zgradpulse(gzlvlA,gtA);
        delay(gstab);

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

        zgradpulse(gzlvlB,gtB);
        delay(gstab);
        obspower(selpwrB);
        shaped_pulse(selshapeB,selpwB,v2,rof1,rof1);
        obspower(slpwrT);
        zgradpulse(gzlvlB,gtB);
        delay(gstab);

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

     if (mixT > 0.0)
      { 
        rgpulse(trim,v11,0.0,0.0);
        if (dps_flag)
          rgpulse(mixT,v3,0.0,0.0);
        else
          SpinLock(slpatT,mixT,slpwT,v2,v3,v4,v5, v9);
       }

      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,rof2);
      }
      else
	 delay(rof2);

   status(C);
}
Example #24
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 #25
0
pulsesequence() 
{ 
 double gstab = getval("gstab"),
	gt1 = getval("gt1"),
	gzlvl1 = getval("gzlvl1"),
	gt2 = getval("gt2"),
	gzlvl2 = getval("gzlvl2"),
        satpwr = getval("satpwr"),
        satdly = getval("satdly"),
	del = getval("del"),
	del2 = getval("del2"),
	dosyfrq = getval("sfrq"),
        gzlvlhs = getval("gzlvlhs"),
        hsgt = getval("hsgt"),
	Ddelta,dosytimecubed; 
 char convcomp[MAXSTR],satmode[MAXSTR],alt_grd[MAXSTR],lkgate_flg[MAXSTR],
      sspul[MAXSTR]; 
 
 getstr("convcomp",convcomp); 
 getstr("satmode",satmode);
 getstr("alt_grd",alt_grd);
 getstr("lkgate_flg",lkgate_flg);
 getstr("sspul",sspul);

       //synchronize gradients to srate for probetype='nano'
       //   Preserve gradient "area"
          gt1 = syncGradTime("gt1","gzlvl1",1.0);
          gzlvl1 = syncGradLvl("gt1","gzlvl1",1.0);
          gt2 = syncGradTime("gt2","gzlvl2",1.0);
          gzlvl2 = syncGradLvl("gt2","gzlvl2",1.0);

/* CHECK CONDITIONS */ 
  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); 
 
 	Ddelta=gt1;             /*the diffusion-encoding pulse width is gt1*/ 
	if (convcomp[A]=='y') 
		dosytimecubed=Ddelta*Ddelta*(del - (4.0*Ddelta/3.0)); 
        else 
		dosytimecubed=Ddelta*Ddelta*(del - (Ddelta/3.0)); 
 
   putCmd("makedosyparams(%e,%e)\n",dosytimecubed,dosyfrq); 
   mod2(ct,v10);        /* gradients change sign at odd transients */
 
/* BEGIN ACTUAL SEQUENCE */ 
 status(A); 
     if (sspul[0]=='y')
       {
         zgradpulse(gzlvlhs,hsgt);
         rgpulse(pw,zero,rof1,rof1);
         zgradpulse(gzlvlhs,hsgt);
       }
     if (satmode[0] == 'y')
      {
        if (d1 - satdly > 0) delay(d1 - satdly);
        obspower(satpwr);
        rgpulse(satdly,zero,rof1,rof1);
        obspower(tpwr);
      }
     else delay(d1);

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

 status(B); 
   if (del>0.0) { 
      if (convcomp[A]=='y')
	{ 
                if (lkgate_flg[0] == 'y')  lk_hold(); /* turn lock sampling off */
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(-gzlvl2,2.0*gt2);
                   elsenz(v10);
                     zgradpulse(gzlvl2,2.0*gt2);
                   endif(v10);
                 }
                else zgradpulse(-gzlvl2,2.0*gt2);
		delay(gstab); 
             rgpulse(pw, v1, rof1, rof1); 
		delay(d2/2.0); 
		delay(gstab); 
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
                if (satmode[1] == 'y')
                   { obspower(satpwr);
                     rgpulse(((del+del2)/4)-gt1-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                   }
                else delay(((del+del2)/4)-gt1);
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(-1.0*gzlvl1,gt1);
		delay(gstab); 
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(-1.0*gzlvl1,gt1);
                if (satmode[1] == 'y')
                   { obspower(satpwr);
                     rgpulse(((del-del2)/4)-gt1-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                   }
		else delay(((del-del2)/4)-gt1); 
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
		delay(gstab); 
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(gzlvl2,gt2);
                   elsenz(v10);
                     zgradpulse(-1.0*gzlvl2,gt2);
                   endif(v10);
                 }
                else zgradpulse(gzlvl2,gt2);
		delay(gstab); 
             rgpulse(p1, v2, rof1, rof1); 
		delay(gstab); 
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(gzlvl2,gt2);
                   elsenz(v10);
                     zgradpulse(-1.0*gzlvl2,gt2);
                   endif(v10);
                 }
                else zgradpulse(gzlvl2,gt2);
		delay(gstab); 
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
                if (satmode[1] == 'y')
                   { obspower(satpwr);
                     rgpulse(((del-del2)/4)-gt1-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                   }
                else delay(((del-del2)/4)-gt1);
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(-1.0*gzlvl1,gt1);
		delay(gstab); 
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(-1.0*gzlvl1,gt1);
                if (satmode[1] == 'y')
                   { obspower(satpwr);
                     rgpulse(((del+del2)/4)-gt1-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                   }
                else delay(((del+del2)/4)-gt1);
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
		delay(gstab); 
		delay(d2/2.0); 
                if (lkgate_flg[0] == 'y') lk_sample(); /* turn lock sampling on */
	} 
else
        { 
	     rgpulse(pw, v1, rof1, rof1); 
                if (lkgate_flg[0] == 'y')  lk_hold(); /* turn lock sampling off */
         	delay(d2/2.0); 
        	delay(gstab); 
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
                if (satmode[1] == 'y')
                   { obspower(satpwr);
                     rgpulse((del-p1-2.0*rof1-gt1)/2.0-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                   }
                else delay((del-p1-2.0*rof1-gt1)/2.0);
             rgpulse(p1, v2, rof1, rof1); 
                if (satmode[1] == 'y')
                   { obspower(satpwr);
                     rgpulse((del-p1-2.0*rof1-gt1)/2.0-2.0*rof1,zero,rof1,rof1);
                     obspower(tpwr);
                   }
                else delay((del-p1-2.0*rof1-gt1)/2.0);
                if (alt_grd[0] == 'y')
                 { ifzero(v10);
                     zgradpulse(gzlvl1,gt1);
                   elsenz(v10);
                     zgradpulse(-1.0*gzlvl1,gt1);
                   endif(v10);
                 }
                else zgradpulse(gzlvl1,gt1);
        	delay(gstab); 
        	delay(d2/2.0); 
                if (lkgate_flg[0] == 'y') lk_sample(); /* turn lock sampling on */
	} 
    } 
   else 
	rgpulse(pw,oph,rof1,rof2); 
 status(C); 
} 
Example #26
0
pulsesequence()
{
   double          tau, rg1 = 2.0e-6,
                   jXH = getval("jXH"),
                   mult = getval("mult"),
                   gt0 = getval("gt0"),
                   gzlvl0 = getval("gzlvl0"),
                   gt1 = getval("gt1"),
                   gzlvl1 = getval("gzlvl1"),
                   gt2 = getval("gt2"),
                   gzlvl2 = getval("gzlvl2"),
                   gt3 = getval("gt3"),
                   gzlvl3 = getval("gzlvl3"),
                   Gratio = getval("Gratio"),
                   gstab = getval("gstab"),
                   compH = getval("compH"),
                   compX = getval("compX"),
                   Hpwr = getval("Hpwr"),
		   jevol = 0.25 / 140.0;    /* default for C-13 */

   char            pshape[MAXSTR], zz[MAXSTR], ad180[MAXSTR], sspul[MAXSTR];
   shape           hdx;                     /* HADAMARD stuff */
   void            setphases();

   getstr("pshape", pshape);              /* pulse shape as in wavelib */
   getstr("sspul", sspul);
   getstr("zz", zz);
   getstr("ad180", ad180);
   if (jXH > 0.0) jevol = 0.25 / jXH;
   
   tau = gt3 + gstab;
   if (mult > 0.5)
    tau = 2*jevol;

   setphases();

   /* MAKE PBOX SHAPES */

   if (FIRST_FID)
   {
     ad180sh = pbox_ad180("ad180", pwx, pwxlvl);    /* make adiabatic 180 */
     if (strcmp(pwpat,"Hdec") == 0)
     {
       /* make H decoupling shape */
       Hdec = pboxHT_dec(pwpat, pshape, jXH, 20.0, pw, compH, tpwr);
       Hpwr = Hdec.pwr;
     }
   }

   hdx = pboxHT_F1i(pshape, pwx*compX, pwxlvl);         /* HADAMARD stuff */
   if (getval("htcal1") > 0.5)           /* enable manual power calibration */
     hdx.pwr += getval("htpwr1");

 /* THE PULSE PROGRAMM STARTS HERE */
   status(A);

    delay(5.0e-5);
    zgradpulse(gzlvl0,gt0);
    if (sspul[0] == 'y')
    {
      rgpulse(pw,zero,rof1,rof1);
      zgradpulse(gzlvl0,gt0);
    }

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

   decoffset(dof);
   decpower(pwxlvl);
   obspower(tpwr);
   obsoffset(tof);
   delay(2.0e-5);
 
   status(B);

   rgpulse(pw, v2, rg1, rg1);
   delay(jevol - ad180sh.pw/2.0 - 3.0*rg1); /* +rg on both sides */
   decshaped_pulse(ad180sh.name, ad180sh.pw, zero, rg1, rg1);
   rgpulse(2.0*pw, zero, rg1, rg1);
   delay(jevol + ad180sh.pw/2.0 - rg1);
   rgpulse(pw, one, rg1, rg1);

   zgradpulse(-gzlvl2, gt2);
   delay(gstab);

   decpower(hdx.pwr);
   if (strcmp(pwpat,"") == 0)
     decshaped_pulse(hdx.name, hdx.pw, zero, rg1, rg1);
   else
   {
     obspower(Hpwr);
     simshaped_pulse(pwpat, hdx.name, hdx.pw, hdx.pw, zero, zero, rg1, rg1);
   }
   zgradpulse(gzlvl2*1.4, gt2);
   decpower(pwxlvl); obspower(tpwr);

   if((zz[A] == 'y') && (mult == 0)) 
   {
     ifzero(v1);
       decshaped_pulse(ad180sh.name, ad180sh.pw, zero, rg1, rg1);
     elsenz(v1);
       delay(0.5e-3);
     endif(v1);
   }
   else
   {
     delay(0.5e-3);
     decrgpulse(pwx,v1,rg1,rg1);
     if(ad180[A]=='y')
       decshaped_pulse(ad180sh.name, ad180sh.pw, zero, rg1, rg1);
     if(zz[A] == 'y')
       delay(tau);
     else
     {
       zgradpulse(gzlvl1,gt1);
       delay(tau - gt1 - 2*GRADIENT_DELAY);
     }
     if(ad180[A]=='y')
     {
       rgpulse(mult*pw, zero, rg1, rg1);
       decshaped_pulse(ad180sh.name, ad180sh.pw, zero, rg1, rg1);
     }
     else
       simpulse(mult*pw,2*pwx,zero,one,rg1,rg1);
     delay(tau); 
     decrgpulse(pwx,zero,rg1,rg1);
   }
   zgradpulse(gzlvl2/1.7, gt2);
   delay(gstab);

   rgpulse(pw, zero, rg1, rg1);
   delay(jevol - ad180sh.pw/2.0 - 3.0*rg1);  /* +rg on both sides */
   decshaped_pulse(ad180sh.name, ad180sh.pw, zero, rg1, rg1);
   rgpulse(2.0*pw, zero, rg1, rg1);

   if(zz[A] == 'y') 
   {
     delay(jevol + ad180sh.pw/2.0 - rg1);
     rgpulse(pw, one, rg1, rg1);
     zgradpulse(-gzlvl3, gt3);
     decpower(dpwr);
     delay(gstab);
     rgpulse(pw, three, rg1, rof2);
   }
   else
   {
     zgradpulse(2.0*gzlvl1/Gratio, gt1/2.0);
     decpower(dpwr);
     delay(jevol + ad180sh.pw/2.0 - rg1 - gt1/2.0 - 2*GRADIENT_DELAY - POWER_DELAY + rof2);
   }
   status(C);
}
Example #27
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 #28
0
pulsesequence()
{
double	del      = getval("del"),
        gstab    = getval("gstab"),
	gt1      = getval("gt1"),
	gzlvl1   = getval("gzlvl1"),
        gt2      = getval("gt2"),
        gzlvl2   = getval("gzlvl2"),
        gt0      = getval("gt0"),
        gzlvl0   = getval("gzlvl0"),
        gths     = getval("gths"),
        gzlvlhs  = getval("gzlvlhs"),
        satpwr   = getval("satpwr"),
        satdly   = getval("satdly"),
        satfrq   = getval("satfrq"),
        trim     = getval("trim"),
        trimpwr  = getval("trimpwr"),
        mix      = getval("mix"),
        wrefpwr  = getval("wrefpwr"),
        wrefpw   = getval("wrefpw"),
        wrefpwrf = getval("wrefpwrf");
char	delflag[MAXSTR],satmode[MAXSTR],dpfgse_flg[MAXSTR],sspul[MAXSTR],
        trim_flg[MAXSTR],alt_grd[MAXSTR],wrefshape[MAXSTR];

   getstr("delflag",delflag);
   getstr("satmode",satmode);
   getstr("dpfgse_flg",dpfgse_flg);
   getstr("trim_flg", trim_flg);
   getstr("alt_grd",alt_grd);
   getstr("wrefshape", wrefshape);
   getstr("sspul",sspul);

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

/* SET PHASES */
  sub(ct,ssctr,v12); /* Steady-state phase cycling */
  settable(t1, 2, phi1); getelem(t1,v12,v1);
  settable(t2, 8, phi2); getelem(t2,v12,v2);
  settable(t3,16, phi3); getelem(t3,v12,v3);
  settable(t4,64, phi4); getelem(t4,v12,v4);
  settable(t5,64, rec);  getelem(t5,v12,oph);

   /* equilibrium period */
   status(A);
      obspower(tpwr);
      if (sspul[A] == 'y')
      {
       zgradpulse(gzlvl0,gt0);
       rgpulse(pw,zero,rof1,rof1);
       zgradpulse(gzlvl0,gt0);
      }
      if (satmode[0] == 'y')
      {
       if (d1 - satdly > 0) delay(d1 - satdly);
       else delay(0.02);
       obspower(satpwr);
        if (satfrq != tof) obsoffset(satfrq);
        rgpulse(satdly,zero,rof1,rof1);
        if (satfrq != tof) obsoffset(tof);
       obspower(tpwr);
       delay(1.0e-5);
      }
      else delay(d1);
   status(B);
   /* first part of bppdel sequence */
   if (delflag[0]=='y')
   {  if (gt1>0 && gzlvl1>0)
      {  rgpulse(pw, zero, rof1, 0.0);		/* first 90, zero */

         ifzero(v6); zgradpulse(gzlvl1,gt1/2.0);
             elsenz(v6); zgradpulse(-1.0*gzlvl1,gt1/2.0); endif(v6);
   	 delay(gstab);
	 rgpulse(pw*2.0, zero, rof1, 0.0);	/* first 180, zero */
         ifzero(v6); zgradpulse(-1.0*gzlvl1,gt1/2.0);
             elsenz(v6); zgradpulse(gzlvl1,gt1/2.0); endif(v6);
   	 delay(gstab);
   	 rgpulse(pw, v1, rof1, 0.0);		/* second 90, v1 */

       if (satmode[1] == 'y')
        {
         obspower(satpwr);
         rgpulse(del-4.0*pw-3.0*rof1-gt1-2.0*gstab,zero,rof1,rof1);
         obspower(tpwr);
        }
       else
   	{
         delay(del-4.0*pw-3.0*rof1-gt1-2.0*gstab);/*diffusion delay */
        }
         rgpulse(pw, v2, rof1, 0.0);            /* third 90, v2 */

         ifzero(v6); zgradpulse(gzlvl1,gt1/2.0);
             elsenz(v6); zgradpulse(-1.0*gzlvl1,gt1/2.0); endif(v6);
   	 delay(gstab);
	 rgpulse(pw*2.0, zero, rof1, rof1);	/* second 180, zero */
         ifzero(v6); zgradpulse(-1.0*gzlvl1,gt1/2.0);
             elsenz(v6); zgradpulse(gzlvl1,gt1/2.0); endif(v6);
   	 delay(gstab);
         rgpulse(pw, v3, rof1, rof1);           /* mixing 90, v3 */
         delay(0.7*mix);
         ifzero(v6); zgradpulse(gzlvlhs,gths);
             elsenz(v6); zgradpulse(-1.0*gzlvlhs,gths); endif(v6);
         delay(0.3*mix-gths);
         if ((dpfgse_flg[A] == 'n')&&(trim_flg[0] == 'n')) rgpulse(pw, v4, rof1, rof2);
         else rgpulse(pw, v4, rof1, rof1);      /* read pulse  */

         /*   DPFGSE block   */

         if (dpfgse_flg[A] == 'y')
          {
           add(v4,two,v7);
           ifzero(v6); zgradpulse(gzlvl2,gt2);
                  elsenz(v6); zgradpulse(-gzlvl2,gt2); endif(v6);
           obspower(wrefpwr+6); obspwrf(wrefpwrf);
               delay(gstab);
           shaped_pulse(wrefshape,wrefpw,v7,rof1,rof1);
           obspower(tpwr); obspwrf(4095.0);
           rgpulse(2.0*pw,v4,rof1,rof1);
           ifzero(v6); zgradpulse(gzlvl2,gt2);
                  elsenz(v6); zgradpulse(-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,v7,rof1,rof1);
           obspower(tpwr); obspwrf(4095.0);
           if (trim_flg[A] == 'y') rgpulse(2.0*pw,v4,rof1,0.0);
           else        rgpulse(2.0*pw,v4,rof1,rof2);
           ifzero(v6); zgradpulse(1.2*gzlvl2,gt2);
                  elsenz(v6); zgradpulse(-1.2*gzlvl2,gt2); endif(v6);
           delay(gstab);
          }
          if (trim_flg[A] == 'y')
               { obspower(trimpwr);
                 add(v4,one,v5);
                rgpulse(trim,v5,rof1,rof2);
               }
     }
   }
   else
      rgpulse(pw,oph,rof1,rof2);

   /* --- observe period --- */

   status(C);
}
Example #29
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 #30
0
void pulsesequence()
{
    char            sspul[MAXSTR];


    /* LOAD VARIABLES AND CHECK CONDITIONS */
    getstr("sspul", sspul);

    if (satpwr > 40)
    {
        printf("satpwr too large  - acquisition aborted./n");
        psg_abort(1);
    }
    if ((rof1 < 9.9e-6) && (ix== 1))
        fprintf(stdout,"Warning:  ROF1 is less than 10 us\n");

    /* 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 REDFIED TRICK 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')
    {
        rgpulse(200*pw, one, 10.0e-6, 0.0e-6);
        rgpulse(200*pw, zero, 0.0e-6, 1.0e-6);
    }
    hsdelay(d1);
    if (satmode[A] == 'y')
    {
        obspower(satpwr);
        rgpulse(satdly,zero,rof1,rof2);
        obspower(tpwr);
    }
    status(B);
    rgpulse(pw, v1, rof1, 1.0e-6);
    if (satmode[B] == 'y')
    {
        obspower(satpwr);
        if (d2>100.0e-6)
            rgpulse(d2-(2*POWER_DELAY)-1.0e-6-rof1-(4*pw)/3.14159,zero,0.0,0.0);
        obspower(tpwr);
    }
    else 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);
    status(C);
}