PageRenderTime 15ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/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
18function [M0, M0_err, TconstVal, TconstVal_err, R, xval]=paramsCal (M, x, Tconst, data_type, noise)
19
20if strcmp(data_type, 'simple')
21    [b,a,b_err,a_err,R]=simple_WLS(M, x, noise);
22    xval=0;
23else
24    [b,a,b_err,a_err,R, xval]=WLS(M, x, noise);
25end
26
27if strcmp(Tconst,'ADC')
28    TconstVal=-a;
29    TconstVal_err=a_err;
30elseif strcmp(Tconst,'T2')
31    TconstVal=-1./a;
32    TconstVal_err=a_err./a.^2;
33end
34
35M0=exp(b);
36M0_err=M0.*b_err;
37end