; SRI-FESTA experiment
;
; Doubly selective refocused INEPT - TOCSY (19F - 1H correlation and 1H-1H TOCSY transfer)
;    using selective 90 19F pulse for excitation 
;    using  selective 180 19F pulse for refocusing (optional)
;    using  selective 180 1H pulse for refocusing
;    using PFG for CTP selection
;    homonuclear Hartman-Hahn transfer using DIPSI2 sequence for mixing with zero quantum suppression (optional)
; For QNP-operation (F-19 via X-QNP output of switchbox)
;		
; Developed by:
;   NMR Methodology Group
;   University of Manchester
;
; L. Castaņar, P. Moutzouri, T. Barbosa, C. Tormena, R. Rittner, A. Phillips, S. Coombes, M. Nilsson, G. A. Morris. 
;   Anal. Chem., 2018, 90, 8, 5445-5450
;   DOI: 10.1021/acs.analchem.8b00753
;
; Options:
;   [cnst1 = 0] without 1H purge pulses before d1
;   [cnst1 = 1] with 1H purge pulses before d1
;   [cnst5 = 0] with 180 19F hard pulses
;   [cnst5 = 1] with 180 19F selective pulses
;   [cnst6 = 0] without TOCSY (SRI-SME)
;   [cnst6 = 1] with TOCSY (SRI-FESTA)


;$CLASS=HighRes
;$DIM=1D
;$TYPE=
;$SUBTYPE=
;$COMMENT=

#include <Avance.incl>
#include <Grad.incl>
#include <Delay.incl>


"d2=1s/(cnst2*4*cnst3)"
"d3=1s/(cnst2*4*cnst4)"
"d13 = 20u"
"d16 = 200u"

"cnst10=2/3.1415"

"DELTA1=d2-p16-d16-d13-(p3*cnst10)"
"DELTA2=d2-d13-(p3*cnst10)-2*p16-2*d16"
"DELTA3=d3-p16-d16-(p3*cnst10)-d13"
"DELTA4=d3-d13-(p3*cnst10)-2*d16-2*p16"
"DELTA11=d2-p16-d16-(p11*cnst10)-d13"
"DELTA12=d2-d13-(p11*cnst10)-2*p16-2*d16"
"DELTA13=d3-p16-d16-(p11*cnst10)-d13"
"DELTA14=d3-d13-(p11*cnst10)-2*d16-2*p16"

"p2=p1*2"
"p4=p3*2"

"spoff11=0"
"spoff12=bf1*(cnst12/1000000)-o1"
"spoff15=0"
"spoff29=0"

"FACTOR1=(d9/(p6*115.112))/2"
"l1=FACTOR1*2"

"acqt0=-p1*2/3.1416"


1 ze
  d13 QNP_X
  30m pl12:f2

2 30m do:f2
	d13 BLKGRAD

 if "cnst1 == 1"						;Purge pulses
    { 
  d13 UNBLKGRAD 
  d13 SWITO_H 
  d13 pl1:f1
  p16:gp20
  d16
  (p1 ph20):f1
  (p1 ph21):f1
  p16:gp21
  d16
  d13 BLKGRAD
   }
  else
   {
   }

  d1 											;F - H AP transfer
	d13 UNBLKGRAD
	d13 SWITO_F 
  d13 pl0:f2
  
  (p11:sp11 ph1):f2		
 
if "cnst5==0" 
   {
   DELTA1  
   p16:gp5
   d16 pl2:f2
   (p3 ph3):f2
   d13 SWITO_H pl0:f1
   (p12:sp12 ph2):f1
   d13 SWITO_F pl2:f2
   (p3 ph3):f2
	 p16:gp5
   d16
   DELTA2 
	 p16:gp1
   d16
   }
   else
   {
   DELTA11  
   p16:gp5
   d16 pl0:f2
   (p11:sp11 ph3):f2
   d13 SWITO_H pl0:f1
   (p12:sp12 ph2):f1 
   d13 SWITO_F pl0:f2
   (p11:sp11 ph3):f2
	 p16:gp5
   d16
   DELTA12 
	 p16:gp1
   d16
   }
  d13 pl2:f2pl1:f1
  (p3 ph4):f2
	p16:gp2
  d16 SWITO_H 
  (p1 ph5):f1
 
if "cnst5==0" 
   {
  DELTA3 								;IP transfer
  p16:gp3
  d16 SWITO_F pl2:f2
  (p3 ph7):f2
  d13 SWITO_H pl0:f1
  (p12:sp12 ph6):f1
  d13 SWITO_F pl2:f2
  (p3 ph7):f2
  p16:gp3
  d16 
  DELTA4
  p16:gp1*0.9407
	d16 
}
else
{
  DELTA13 								;IP transfer 
  p16:gp3
  d16 SWITO_F pl0:f2
  (p11:sp11 ph7):f2
  d13 SWITO_H pl0:f1
  (p12:sp12 ph6):f1
  d13 SWITO_F pl0:f2
  (p11:sp11 ph7):f2
  p16:gp3
  d16 
  DELTA14
  p16:gp1*0.9407
	d16 
}

 if "cnst6 == 1"		;TOCSY block with ZQF
    { 
  d13 SWITO_H pl1:f1
	(p1 ph8):f1
  10u gron0 pl0:f1
  (p32:sp29 ph9):f1
  10u groff 
  d16 pl10:f1 

												;begin DIPSI2
4 p6*3.556 ph23
  p6*4.556 ph25
  p6*3.222 ph23
  p6*3.167 ph25
  p6*0.333 ph23
  p6*2.722 ph25
  p6*4.167 ph23
  p6*2.944 ph25
  p6*4.111 ph23
  
  p6*3.556 ph25
  p6*4.556 ph23
  p6*3.222 ph25
  p6*3.167 ph23
  p6*0.333 ph25
  p6*2.722 ph23
  p6*4.167 ph25
  p6*2.944 ph23
  p6*4.111 ph25

  p6*3.556 ph25
  p6*4.556 ph23
  p6*3.222 ph25
  p6*3.167 ph23
  p6*0.333 ph25
  p6*2.722 ph23
  p6*4.167 ph25
  p6*2.944 ph23
  p6*4.111 ph25

  p6*3.556 ph23
  p6*4.556 ph25
  p6*3.222 ph23
  p6*3.167 ph25
  p6*0.333 ph23
  p6*2.722 ph25
  p6*4.167 ph23
  p6*2.944 ph25
  p6*4.111 ph23
  lo to 4 times l1
						;end DIPSI2

	p16:gp4
  d16 pl0:f1 
  10u gron0*1.333
  (p32*0.75:sp29 ph9):f1
  10u groff
  d16 pl1:f1 

  (p1 ph10):f1
   }
  else
   { 
   }

  d13 SWITO_F pl12:f2
  go=2 ph31 cpd2:f2
  30m do:f2 mc #0 to 2 F0(zd)
	d13 BLKGRAD
exit


ph1=0 2 2 0 
ph2=0
ph3=0
ph4=1
ph5=0
ph6=0
ph7=0
ph8=1
ph9=0
ph10=0
ph20=0
ph21=1
ph23=3 
ph25=1
ph31=0 2 2 0 

;POWER LEVEL
;pl0  : zero power (0 W)
;pl1  : f1 channel - power level for pulse (default)
;pl2  : f2 channel - power level for pulse (default)
;pl10 : f1 channel - power level for TOCSY-spinlock
;pl12 : f2 channel - power level for CPD/BB decoupling
;sp11 : f2 channel - power level of excitation shaped pulse
;sp12 : f1 channel - power level of refocusing shaped pulse
;sp12 : f2 channel - power level of refocusing shaped pulse
;sp29 : f1 channel - power level of adiabatic pulse of ZQF element

;PULSE DURATION
;p1 : f1 channel - 90 degree high power pulse
;p2 : f1 channel - 180 degree high power pulse
;p3 : f2 channel - 90 degree high power pulse
;p4 : f2 channel - 180 degree high power pulse
;p6 : f1 channel - 90 degree low power pulse for DIPSI element
;p11: f2 channel - 90 degree low power shaped pulse 
;                  choose p11 according to desired selectivity
;p12: f1 channel - 180 degree low power shaped pulse
;                  choose p12 according to desired selectivity
;p13: f2 channel - 180 degree low power shaped pulse
;                  choose p13 according to desired selectivity
;p32: f1 channel - 180 degree shaped pulse (adiabatic)              [20 msec]

;GRADIENT DURATION
;p16: duration of CTP gradients                                     [0.8 msec]

;DELAY
;d1 : relaxation delay; 1-5 * T1
;d2 : 1/(nH*4*J(XH))
;d3 : 1/(nF*4*J(XH))
;d9 : TOCSY mixing time
;d12: delay for QNP switch                                         [20 usec] 
;d13: delay for power switch                                       [20 usec] 
;d16: delay for gradient recovery                                  [200 usec] 

;PULSE SHAPE
;spnam11 : f2 channel - file name for the selective 90 exciation shaped pulse    [Gauss]
;spnam12 : f1 channel - file name for the selective 180 refocusing shaped pulse  [Rsnob]
;spnam13 : f2 channel - file name for the selective 180 refocusing shaped pulse  [Rsnob]
;spnam29 : f1 channel - file name for the adiabatic shaped pulse using in ZQF    [Crp60,20,20.10]
;                     smoothed chirp (sweepwidth, 20% smoothing, 10000 points)

;GRADIENT SHAPE
;gpnam1 : SMSQ10.100
;gpnam2 : SMSQ10.100
;gpnam3 : SMSQ10.100
;gpnam4 : SMSQ10.100
;gpnam5 : SMSQ10.100
;gpnam20: SMSQ10.100
;gpnam21: SMSQ10.100

;GRADIENT STRENGTH
;gpz0  : ZQF gradient                      [3%]
;gpz1  : F-H CTP gradient                  [47%]
;gpz2  : homospoil gradient                [37%]
;gpz3  : 180 1H CTP gradient               [41%]
;gpz4  : homospoil gradient TOCSY          [17%]
;gpz5  : 180 1H CTP gradient               [33%]
;gpz20 : homospoil gradient purge pulses   [53%]
;gpz21 : homospoil gradient purge pulses   [59%]

;CONSTANTS 
;cnst1 : 0 (--) / 1 (Purge pulses) 
;cnst2 : J(XH)
;cnst3 : number of protons coupled with fluorine 
;cnst4 : number of fluorines coupled with protons  
;cnst5 : 0 (19F 180 hard pulses) / 1 (19F 180 selective pulses) 
;cnst6 : 0 (--) / 1 (ZQF-TOCSY)
;cnst12: chemical shift for selective 1H pulse (offset, in ppm)

;OTHER
;ns: 2 * n, total number of scans: NS * TD0
;ds: 2
;set O2 on resonance to the 19F signal of interest
;cpd2: p5m4sp180
;l1: loop for DIPSI cycle: ((p6*115.112) * l1) = mixing time
;if any DELTA become negative try to reduce the gradient duration or selective pulse duration