/code/paramsCal.m

http://ne-proj.googlecode.com/ · Objective C · 37 lines · 33 code · 4 blank · 0 comment · 2 complexity · 570d9308bdb4d517de8dd2652ed7f0c4 MD5 · raw file

  1. %********************************************************************************************************
  2. % "paramsCal.m" calculates Tconst(ADC or T2) and M0.
  3. % inputs:
  4. % M- The 3D image which was acquired or a set of points.
  5. % x- vector with the 'x' value of the signal (b value or TE, respectively).
  6. % Tconst- The name of the time constant that the user wishs to find: ADC or T2.
  7. % data_type- 3D matrix (=3D) or set of points (=simple).
  8. % outputs:
  9. % M0 - The signal in t=0.
  10. % M0_err- The error in M0.
  11. % TconstVal- The value of the time constant (ADC or T2).
  12. % TconstVal_err- The error in TconstVal.
  13. % R- The R square measurement.
  14. % xval- A matrix which describes how mush points were used to compute
  15. % the T. const in each voxel.
  16. %*********************************************************************************************************
  17. function [M0, M0_err, TconstVal, TconstVal_err, R, xval]=paramsCal (M, x, Tconst, data_type, noise)
  18. if strcmp(data_type, 'simple')
  19. [b,a,b_err,a_err,R]=simple_WLS(M, x, noise);
  20. xval=0;
  21. else
  22. [b,a,b_err,a_err,R, xval]=WLS(M, x, noise);
  23. end
  24. if strcmp(Tconst,'ADC')
  25. TconstVal=-a;
  26. TconstVal_err=a_err;
  27. elseif strcmp(Tconst,'T2')
  28. TconstVal=-1./a;
  29. TconstVal_err=a_err./a.^2;
  30. end
  31. M0=exp(b);
  32. M0_err=M0.*b_err;
  33. end