Hi Edward,
Here is a function that does a numerical fit of CPMG. It uses an explicit
matrix that contains relaxation, exchange and chemical shift terms. It does
the 180deg pulses in the CPMG train with conjugate complex matrices.
It returns calculated R2eff values, so it can be used for numerical fitting
of CPMG.
It is an addition to the functions that I previously sent to you.
The approach of Bloch-McConnell can be found in chapter 3.1 of Palmer, A. G.
Chem Rev 2004, 104, 3623–3640.
I wrote this function (initially in MATLAB) in 2010.
I agree that this code is released under the GPL3 or higher licence.
Paul
def func1(R2E,R2G,fg,kge,keg, cpmgfreq,tcpmg):
kex=kge+keg
Rcalc_array=np.zeros(len(cpmgfreq))
Rr = -1.*np.matrix([[R2G, 0.],[0., R2E]])
Rex = -1.*np.matrix([[kge,-keg],[-kge, keg]])
RCS = complex(0.,-1.)*np.matrix([[0. ,0.],[0.,fg]])
R = Rr + Rex + RCS
cR = np.conj(R)
IGeq=keg/kex; IEeq=kge/kex
M0=np.matrix([[IGeq],[IEeq]])
for k in range(len(cpmgfreq)):
tcp=1./(4.*cpmgfreq[k])
prop_2
=np.dot(np.dot(sci.expm(R*tcp),sci.expm(cR*2.*tcp)),sci.expm(R*tcp))
prop_total =mpower(prop_2,cpmgfreq[k]*tcpmg)
Moft = prop_total*M0
Mgx=Moft[0].real/M0[0]
Rcalc=-(1./tcpmg)*math.log(Mgx);
Rcalc_array[k]=Rcalc
return Rcalc_array