;doneshot_2d_jy
;
;download from: https://git.io/JUHOX
;
;Jonathan Yong - University of Oxford - 26 Aug 2020
;minor modifications to original oneshot DOSY sequence to make it play better with TopSpin.
;
;modified from:
;Ralph Adams, Juan Aguilar, Robert Evans, Mathias Nilsson and Gareth Morris
;University of Manchester
;Release 1.0c (27Mar2012)
;Source citation:
;M.D. Pelta, G.A. Morris, M.J. Stchedroff, S.J. Hammond, Magn. Reson. Chem. 40 (2002) S147-S152.
;
;Other relevant papers that could be of use include:
;A. Botana, J.A. Aguilar, M. Nilsson, G.A. Morris, J. Magn. Reson. 208 (2011) 270-278.
; 
;MN 30Nov11 Changed CTP gradients to gp2 and neatened up the comments  
;MN 21Mar12 Sorted out the magnitude of cnst17 and cnst18
;MN 21Mar12 Added instruction to comment out acqt0 line if Topspin < 2.0
;MN 27Mar12 Changed phase cycling syntax to simple table. Not confident parser does what we hope for the compact version
;
;2D Doneshot DOSY pulse sequence
;$CLASS=HighRes
;$DIM=2D
;$TYPE=
;$SUBTYPE=
;$COMMENT=

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

define list<gradient> diff=<Difframp>

;JY - alpha is hardcoded as 0.2
"cnst14=0.2"

"cnst17=(2*p1+d16+p30)*0.000001"; Dtau
;Assuming square gradient pulses
;"cnst18=0.000001*p30*2*0.000001*p30*2*(d20+(0.000001*p30/3)*(cnst14*cnst14-2)+((cnst17)/2)*(cnst14*cnst14-1))" ; Dosytimecubed
;Assuming half-sine gradient pulses [most common on Bruker systems]
"cnst18=0.000001*p30*2*0.000001*p30*2*(d20 - (2*0.000001*p30*(5-3*cnst14*cnst14)/16) - (cnst17*(1-cnst14*cnst14)/2) )" ; Dosytimecubed

"cnst15=1+cnst14"  ; 1 + alpha
"cnst16=1-cnst14"  ; 1 - alpha
"p2=p1*2"
"DELTA1=d20-4.0*p1-4.0*p30-5.0*d16-p19"
"acqt0 = -p1*2/3.1416"

1 ze
2 d1
3 50u UNBLKGRAD
  p19:gp2*-1               ;Spoiler gradient balancing pulse
  d16
  p1 ph1                   ;1st 90
  p30:gp1*diff*cnst16      ;1 - alpha
  d16
  p2 ph2                   ;First 180
  p30:gp1*diff*cnst15*-1   ;1 + alpha
  d16
  p1 ph3                   ;2nd 90
  p30:gp1*diff*cnst14*2    ;Lock refocusing pulse pulse
  d16
  p19:gp2                  ;Spoiler gradient balancing pulse
  d16
  DELTA1
  p30:gp1*diff*cnst14*2    ;Lock refocusing pulse pulse
  d16
  p1 ph4                   ;3rd 90
  p30:gp1*diff*cnst16      ;1 - alpha
  d16
  p2 ph5
  p30:gp1*diff*cnst15*-1   ;1 + alpha
  d16
  4u BLKGRAD
  go=2 ph31
  d1 mc #0 to 2 F1QF(calgrad(diff))
exit

ph1 = 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3 0 2 0 2 1 3 1 3
ph2 = 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 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 0 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 3 1 3 1 1 3 0 2 2 0 2 0 0 2 3 1 1 3 1 3 3 1 2 0 0 2 0 2 2 0 1 3 3 1 3 1 1 3 0 2 2 0 0 2 2 0 1 3 3 1 3 1 1 3 0 2 2 0 2 0 0 2 3 1 1 3 1 3 3 1 2 0 0 2 0 2 2 0 1 3 3 1 3 1 1 3 0 2 2 0 2 0 0 2 3 1 1 3 1 3 3 1 2 0 0 2 2 0 0 2 3 1 1 3 1 3 3 1 2 0 0 2 0 2 2 0 1 3 3 1 3 1 1 3 0 2 2 0 2 0 0 2 3 1 1 3 1 3 3 1 2 0 0 2 0 2 2 0 1 3 3 1 3 1 1 3 0 2 2 0 0 2 2 0 1 3 3 1 3 1 1 3 0 2 2 0 2 0 0 2 3 1 1 3 1 3 3 1 2 0 0 2

;pl1 : f1 channel - power level for pulse (default)
;p1  : f1 channel -  90 degree high power pulse
;p19 : gradient pulse 2 (spoil gradient)
;p30 : gradient pulse (little DELTA*0.5)
;d1  : relaxation delay; 1-5 * T1
;d16 : delay for gradient recovery
;d20 : diffusion time (big DELTA)
;gpnam1: SMSQ10.100
;gpnam2: SMSQ10.100
;gpz1 : diffusion encoding gradient (100%)
;gpz2 : Oneshot CTP gradients

;cnst14 : alpha, typically 0.2
;cnst15 : 1+alpha
;cnst16 : 1-alpha
;cnst17 : Dtau
;cnst18 : dosytimecubed

;NS : 1 * n
;DS : 1 * m
;td1: number of experiments
;FnMODE: QF

;use AU-program dosy to calculate gradient ramp-file Difframp
;        use xf2 and DOSY processing
;        use "setdiffparmUoM" if 'setdiffparm' does not work
;    or  use "setdiffparm STEbp" but this gives slighly distorted diffusion coefficients 
