⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 applyfdr.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function th = applyfdr(stats, stype, levels, df1, df2, lnmeth)
% applyfdr  - apply FDR thresholding to given statistic
%
% FORMAT:       th = applyfdr(stats, stype, levels, df1 [, df2 [, lnmeth]])
%
% Input fields:
%
%       stats       statistical values (p/r/t/F)
%       stype       either of {'p'}, 'r', 't', 'F'
%       levels      q(FDR) levels
%       df1         d.f. 1
%       df2         d.f. 2
%       lnmeth      if given and true (boolean!), use
%                   c(V) = ln(V) + E  instead of  c(V) = 1 approximation
%
% Output fields:
%
%       th          thresholds in original statistic
%
% See also fdr_thresholds

% Version:  v0.7b
% Build:    7090608
% Date:     Sep-06 2007, 8:14 AM CEST
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin < 3 || ...
   (~isa(stats, 'double') && ...
    ~isa(stats, 'single')) || ...
   ~ischar(stype) || ...
    numel(stype) ~= 1 || ...
   ~any('fprt' == lower(stype)) || ...
   (~isa(levels, 'double') && ...
    ~isa(levels, 'single')) || ...
    isempty(levels) || ...
    any(isinf(levels(:)) | isnan(levels(:)) | levels(:) <= 0 | levels(:) >= 1) || ...
   (lower(stype) ~= 'p' && ...
    ((~isa(df1, 'double') && ...
      ~isa(df1, 'single')) || ...
      numel(df1) ~= 1 || ...
      isnan(df1) || ...
      df1 < 2 || ...
     (lower(stype) == 'f' && ...
      (nargin < 5 || ...
       (~isa(df2, 'double') && ...
        ~isa(df2, 'single')) || ...
       numel(df2) ~= 1 || ...
       isnan(df2) || ...
       df2 < 1))))
    error( ...
        'BVQXtools:BadArgument', ...
        'Bad or missing argument.' ...
    );
end
if nargin < 6 || ...
   ~islogical(lnmeth) || ...
    isempty(lnmeth)
    lnmeth = false;
else
    lnmeth = lnmeth(1);
end
nstats = numel(stats);
levels = levels(:);
stats = stats(:);
stats(isnan(stats) | stats == 0) = [];

% for empty stats, set to Bonferroni level - eps
if isempty(stats)
    
    blevels = (1 / nstats) * levels - eps;
    
    % depends on type
    switch (lower(stype))
        case {'f'}
            th = custom_finv(1 - blevels, df1, df2);
        case {'p'}
            th = blevels;
        case {'r'}
            th = correlinvtstat( ...
                custom_tinv(1 - 0.5 * blevels, df1 - 1), df1 + 1);
        case {'t'}
            th = custom_tinv(1 - 0.5 * blevels, df1);
    end
    return;
end

% depends on type
switch (lower(stype))
        
    % F stats
    case {'f'}
        th = custom_finv(1 - fdr_thresholds( ...
            1 - custom_tcdf(abs(double(stats(:))), df1, df2), ...
            levels(:), lnmeth), df1, df2);
    
    % already p values
    case {'p'}
        th = fdr_thresholds(stats(:), levels(:), lnmeth);
        
    % correlation r
    case {'r'}
        th = correlinvtstat(custom_tinv(1 - fdr_thresholds( ...
            1 - custom_tcdf(abs(correltstat(stats(:), df1 + 1)), df1 - 1), ...
            levels(:) / 2, lnmeth), df1 - 1), df1 + 1);
        
    % t stats
    case {'t'}
        th = custom_tinv(1 - fdr_thresholds( ...
            1 - custom_tcdf(abs(double(stats(:))), df1), ...
            levels(:) / 2, lnmeth), df1);
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -