-
Notifications
You must be signed in to change notification settings - Fork 3
/
prevalencePtoZ.m
43 lines (39 loc) · 1.34 KB
/
prevalencePtoZ.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function prevalencePtoZ(prefix)
% convert p-value images to z-value images in results of prevalence
%
% prevalencePtoZ(prefix)
%
% prefix: prefix as used in a preceding run of `prevalence`
%
% See also prevalence
%
%
% Copyright (C) 2016 Carsten Allefeld
%
% This program is free software: you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation, either version 3 of the License, or (at your
% option) any later version. This program is distributed in the hope that
% it will be useful, but without any warranty; without even the implied
% warranty of merchantability or fitness for a particular purpose. See the
% GNU General Public License <http://www.gnu.org/licenses/> for more details.
if (nargin == 0) || isempty(prefix)
prefix = 'prevalence_';
end
fprintf('prevalencePtoZ\n')
pattern = [prefix 'p*.nii'];
d = dir(pattern);
if numel(d) == 0
fprintf('no files "%s" found\n', pattern)
end
[pathstr, name, ~] = fileparts(prefix);
for ni = 1 : numel(d)
fprintf(' %s\n', d(ni).name)
ifn = fullfile(pathstr, d(ni).name);
ofn = [prefix 'z' d(ni).name(numel(name) + 2 : end)];
Vi = spm_vol(ifn);
p = spm_read_vols(Vi);
z = sqrt(2) * erfinv(1 - 2 * p);
spmWritemage(z, ofn, Vi.mat, ...
'descrip', ['z' d(ni).name(numel(name) + 2 : end - 4)])
end