source:misclib/tdist.m

Last change on this file was 71, checked in by tjniskan, 11 years ago
• Added support for VNMRj EPIs (linear and central) with phase

• Added possibility to omit volumes from fMRI analysis

(fmri_analysis.m and plugins/basic_fmri_analysis.m)

• Fixed few minor bugs in aedes.m
• Added misclib/tdist.m which removes Statistics toolbox dependence

from fmri_analysis.m

A misclib/tdist.m
M misclib/fmri_analysis.m
M an2_revision.m
M aedes.m
M plugins/basic_fmri_analysis.m

File size: 1.6 KB
Line
1function p = tdist(x,v)
2% TDIST - Calculates Student's cumulative distribution function.
3%
4% Synopsis:
5%       p = tdist(X,V)
6%
7% Description:
8%       Calculates Student's cumulative distribution function with V
9%       degrees of freedom at the values in X.
10%
11% Examples:
12%
14%        FMRI_ANALYSIS
15
16% This function is a part of Aedes - A graphical tool for analyzing
17% medical images
18%
19% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
20%
21% Department of Physics, Department of Neurobiology
22% University of Kuopio, FINLAND
23%
24% This program may be used under the terms of the GNU General Public
26% and appearing in the file LICENSE.TXT included in the packaging of
27% this program.
28%
29% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
30% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31
32if nargin < 2,
33    error('Too few input arguments.');
34end
35
36if numel(v)==1
37  v = ones(size(x),class(v)).*v;
38end
39
40% Initialize P.
41if isa(x,'single') || isa(v,'single')
42    p = NaN(size(x),'single');
43else
44    p = NaN(size(x));
45end
46
47nans = (isnan(x) | ~(0<v));
48
49% Handle special cases of degrees of freedom
50ind = (v == 1);
51if any(ind(:))
52  p(ind) = 0.5+(1/pi).*atan(x);
53end
54ind = (v == 2);
55if any(ind(:))
56  p(ind) = 0.5*(1+x./sqrt(2+x.^2));
57end
58
59ind = isnan(p);
60if any(ind(:))
61  % When degrees of freedom are other than 1 or 2, the cumulative
62  % distribution function is calculated as an incomplete beta function
63  p(ind) = betainc((x(ind)+sqrt(x(ind).^2+v(ind)))./(2*sqrt(x(ind).^2+v(ind))),v(ind)/2,v(ind)/2);
64end
65p(x == 0 & ~nans) = 0.5;
Note: See TracBrowser for help on using the repository browser.