; SCALPEL_idiff
;
;	SCALPEL (Spectral Component Acquisition by Localized PARAFAC Extraction of Linear components)
;
; TOCSY-t1 encoding combined with
; double selective iDOSY z-TOCSY
; using DIPSI2 sequence for mixing
; with zero quantum suppression
; and option for water pre-saturation
;
; uses squared steps for sampling in t1-evolution
; and double selective excitation sculpting for iDOSY
;	
;	THE USE OF WAVEMAKER IS RECOMENDED
;
;	Guilherme Dal Poggetto
;	University of Manchester
;	<2018>
;
;
; (1) M.J. Thrippleton and J. Keeler, Angew. Chem. Int. Ed., 42, 3938 (2003)
; (2) N. Birlirakis and E. Guittet, JACS 118, 13083 (1996)
; (3) P. Howe, Magn. Reson. Chem. 55, 433 (2017)
; (4) L. Braunschweiler and R. R. Ernst, J. Magn. Reson., 53, 521 (1983)
; (5) G. Dal Poggetto, L. CastaƱar, R. A. Adams, G. A. Morris and M. Nilsson, Chem. Commun., 53, 7461 (2017)
;
;$CLASS=HighRes
;$DIM=3D
;$TYPE=
;$SUBTYPE=
;$COMMENT=


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

;%%%%%%%%%% WaveMaker Parameters %%%%%%%%%%

"d11=30m+1s/(cnst12)-1s/(cnst12)"
;sp12:wvm:gdp_reburp:f1 reburp(cnst12 Hz, PL; NPOINTS=10000)

;%%%%%%%%%% DOSY Parameters %%%%%%%%%%

define list<gradient> diff=<Difframp>

"cnst17=0" ;Dtau
"cnst18=0.000001*0.000001*p30*p30*(d20-(0.000001*p30/2))" ;Dosytimecubed
"DELTA1=((d20/2)-p12-p30-d16)/2"

;%%%%%%%% sel-TOCSY Parameters %%%%%%%

"p6=1000000.0/(cnst6*4)"
"cnst46= (p6/p1) * (p6/p1)"
"plw10=plw1/cnst46"

"p33=1000000.0/(cnst53*4)"
"cnst33= (p33/p1) * (p33/p1)"
"spw32=plw1/cnst33"

"p35=1000000.0/(cnst54*4)"
"cnst35= (p35/p1) * (p35/p1)"
"spw34=plw1/cnst35"

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

"spoal32=0.5"
"spoal34=0.5"
"spoff32=0"
"spoff34=0"

"cnst28=o1"
"cnst30=(cnst29*bf1)-cnst28"
"cnst31=0"

;%%%%%%%%%% TOCSY-t1 Parameters %%%%%%%%%

"d0=0u"
"l11=0"
"in0=1/2*cnst6"
"cnst2=0"
"cnst3=((cnst1*in0)*(cnst1*in0))/(td1-1)"

;%%%%%%%%%% Other Parameters %%%%%%%%%

"p2=2*p1"
"d11=30m"

"cnst40=(cnst49*bf1)-cnst28"

"acqt0=-p1*2/3.1416"
aqseq 312

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


1 ze

2 d11 pl1:f1
  "cnst2=cnst3*l11"
  "d0=sqrt(cnst2)"
  10u UNBLKGRAD
  p8 ph21
  p8 ph22
  p18:gp8
  d18 BLKGRAD
  1m fq=cnst40:f1
  20u pl9:f1
  d1 
  1s cw:f1 ph29
  4u do:f1
  1m fq=cnst31:f1
  20u pl1:f1
  50u UNBLKGRAD
  p18:gp8*-1
  d18
  
  p1 ph1
  d0
  p1 ph4

  10u fq=cnst30:f1
  5u pl0:f1
  100u gron0
  (p32:sp32 ph5):f1
  20u groff
  100u 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
  p18:gp8*-1
  d18

  5u pl0:f1
  100u gron10
  (p34:sp34 ph5):f1
  20u groff
  20u pl1:f1
  10u fq=cnst31:f1
  p1 ph4

5 p30:gp1*diff
  d16 pl0:f1
  DELTA1
  p12:sp12:f1 ph2
  DELTA1
  p30:gp1*diff
  d16 pl1:f1

  p2 ph4

  p30:gp1*-1*diff
  d16 pl0:f1
  DELTA1
  p12:sp12:f1 ph3
  DELTA1
  p30:gp1*-1*diff
  d16 pl1:f1

  p1 ph6
  10u fq=cnst30:f1
  5u pl0:f1
  100u gron0*-1
  (p32:sp32 ph5):f1
  20u groff
  1m pl10:f1
						;begin DIPSI2
6 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 6 times l1
						;end DIPSI2
  3u
  p18:gp8
  d18

  5u pl0:f1
  100u gron10*-1
  (p34:sp34 ph5):f1
  20u groff
  20u pl1:f1
  10u fq=cnst31:f1
  100u BLKGRAD
  p1 ph7

	go=2 ph31
	d11 mc #0 to 2
  F2QF(calgrad(diff))
  F1QF(calclc(l11,1))


exit 
 
; Phase cycling
ph1=  0 2
ph2=  0 0 1 1 2 2 3 3
ph3=  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
ph4=  0
ph5=  0 
ph6=  0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2
ph7=  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
ph21= 0
ph22= 1
ph23= 3
ph25= 1
ph29= 0
ph31= 0 2 2 0 0 2 2 0 2 0 0 2 2 0 0 2 2 0 0 2 2 0 0 2 0 2 2 0 0 2 2 0
      

;POWER LEVEL
;pl0  : zero power (0W)
;pl1  : power level for pulse (default)
;pl9 : power level for pre-saturation
;pl10 : power level for TOCSY-spinlock
;sp12 : power level of refocusing shaped pulse
;sp32 : power level of adiabatic pulse of first ZQF element
;sp34 : power level of adiabatic pulse of last ZQF element

;PULSE DURATION
;p1  : 90 degree high power pulse
;p2  : 180 degree high power pulse
;p6  : 90 degree low power pulse
;p8  : Spherical randomization pulse						[1-1.5 msec]
;p12 : 180 degree refocusing shaped pulse
;      choose p12 according to desired selectivity
;p32 : first ZQF 180 degree inversion shaped pulse (adiabatic)    		[10 msec]
;p34 : second ZQF 180 degree inversion shaped pulse (adiabatic)    		[30 msec]

;GRADIENT DURATION
;p18 : homospoil gradient					[1 msec]
;p30 : DOSY gradient pulse (little delta)					[0.5 - 4 msec]

;DELAY
;d0  : increment in TOCSY indirect dimension
;d1  : relaxation delay; 							[1-10 s]
;d9  : TOCSY mixing time 							[50-200 ms]
;d11 : delay for disk I/O							[30 msec]
;d16 : DOSY gradient pulse recovering delay
;d18 : saturation recovery pulse /TOCSY gradient pulse delay
;d20 : Diffusion encoding period (BIG DELTA)

;PULSE SHAPE
;spnam32 : file name for the adiabatic shaped pulse using in first ZQF 		[CHIRP]
;         smoothed chirp (low to high, 20% smoothing, 1000 points, 20KHz)
;spnam34 : file name for the adiabatic shaped pulse using in last ZQF 		[CHIRP]
;         smoothed chirp (low to high, 20% smoothing, 1000 points, 20KHz)

;GRADIENT SHAPE
;gpnam1 : SINE.100
;gpnam8 : SMSQ10.100

;GRADIENT STRENGTH
;gpz0 : first ZQF gradient 					[3%]
;gpz1 : DOSY gradients 						[100%]
;gpz8 : homospoil gradient 				[31%]
;gpz10: last ZQF gradient 					[4%]

;CONSTANTS
;cnst1: last time increment for t1-TOCSY
;cnst2: first time increment for t1-TOCSY
;cnst3: square of time increment for t1-TOCSY
;cnst6: bandwidth of TOCSY transfer
;cnst12: bandwidth of selective refocussing pulse
;cnst29: offset for TOCSY block (ppm)
;cnst49: water chemical shift (ppm)
;cnst53: GammaB1 of first adiabatic ZQF shaped pulse 
;cnst54: GammaB1 of last adiabatic ZQF shaped pulse 

;OTHER
;in0 : time evolution for t1-TOCSY
;td1 : number of t1-TOCSY increments
;td2 : number of DOSY increments
;l1 : number of DIPSI-2 loops
;PARMOD = 3D
;NS: 8 * n, total number of scans: NS * TD0
;DS: 16