forked from NeuroStats/lme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fs_write_fstats.m
executable file
·39 lines (37 loc) · 1.25 KB
/
fs_write_fstats.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
function fs_write_fstats(fstats,mri,fname,data_type)
% fs_write_fstats(fstats,mri,fname,data_type)
%
% Writes F-statistic or p-value or Freesurfer significance maps to Freesurfer's
% .mgh or .mgz data file. This can be useful for visualization and post-processing
% in Freesurfer.
%
% Input
% fstats: Structure obtained from lme_mass_F.
% mri: Mri structure (read with fs_read_Y).
% fname: Output file name.
% data_type: Determines what is going to be written. This input can be one
% of three strings: 'fval' (signed F-statistic map), 'pval' (signed p-value map)
% or 'sig' (Freesurfer significance map -log10(pval).*sgn).
%
% $Revision: 1.1.1.1 $ $Date: 2012/07/19 11:25:52 $
% Original Author: Jorge Luis Bernal Rusiel
% CVS Revision Info:
% $Author: jbernal$
% $Date: 2012/07/19 11:25:52 $
% $Revision: 1.1 $
%
if nargin < 4
error('Too few inputs');
end;
mri.volsz(4) = 1;
if strcmpi(data_type,'fval')
fs_write_Y(fstats.F.*fstats.sgn,mri,fname);
elseif strcmpi(data_type,'pval')
pval = fstats.pval.*fstats.sgn;
pval(pval==1) = 1;
fs_write_Y(pval,mri,fname);
elseif strcmpi(data_type,'sig')
fs_write_Y(-log10(fstats.pval).*fstats.sgn,mri,fname);
else
error('Valid strings for data_type are ''fval'' or ''pval'' or ''sig''');
end;