Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow for choosing between FDR, FWE and uncorrected threshold
The variable use_fwe_correction has been replaced with a multitest_correction
variable which can be equal to 'none' for uncorrected threshold,
'FWE' for FWE correction adn 'FDR' for FDR correction
  • Loading branch information
Lorenzo De Angelis committed May 3, 2021
commit d78ba2491ba3ceec391bcb5a067670db42b2fc2f
36 changes: 24 additions & 12 deletions nipype/interfaces/spm/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,13 +522,22 @@ class ThresholdInputSpec(SPMCommandInputSpec):
exists=True, desc='stat image', copyfile=False, mandatory=True)
contrast_index = traits.Int(
mandatory=True, desc='which contrast in the SPM.mat to use')
use_fwe_correction = traits.Bool(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to keep the old options around so that we don't break existing workflows. You can deprecate it though (see https://nipype.readthedocs.io/en/latest/devel/interface_specs.html).

True,
# use_fwe_correction = traits.Bool(
# True,
# usedefault=True,
# desc=('whether to use FWE (Bonferroni) '
# 'correction for initial threshold '
# '(height_threshold_type has to be '
# 'set to p-value)'))
multitest_correction = traits.Enum(
'none',
'FWE',
'FDR',
usedefault=True,
desc=('whether to use FWE (Bonferroni) '
'correction for initial threshold '
'(height_threshold_type has to be '
'set to p-value)'))
desc=('Whether to use a correction '
'for multiple test. '
'Possible choices are FWE, FDR '
'or none'))
use_topo_fdr = traits.Bool(
True,
usedefault=True,
Expand Down Expand Up @@ -578,7 +587,6 @@ class Threshold(SPMCommand):

Examples
--------

>>> thresh = Threshold()
>>> thresh.inputs.spm_mat_file = 'SPM.mat'
>>> thresh.inputs.stat_image = 'spmT_0001.img'
Expand All @@ -600,11 +608,11 @@ def _gen_pre_topo_map_filename(self):
def _make_matlab_command(self, _):
script = "con_index = %d;\n" % self.inputs.contrast_index
script += "cluster_forming_thr = %f;\n" % self.inputs.height_threshold
if self.inputs.use_fwe_correction:
script += "thresDesc = 'FWE';\n"
else:
script += "thresDesc = 'none';\n"

script += "thresDesc = '%s';\n" % self.inputs.multitest_correction
# if self.inputs.use_fwe_correction:
# script += "thresDesc = 'FWE';\n"
# else:
# script += "thresDesc = 'none';\n"
if self.inputs.use_topo_fdr:
script += "use_topo_fdr = 1;\n"
else:
Expand All @@ -629,11 +637,15 @@ def _make_matlab_command(self, _):
R = SPM.xVol.R;
S = SPM.xVol.S;
n = 1;
VspmSv = cat(1,SPM.xCon(con_index).Vspm);

switch thresDesc
case 'FWE'
cluster_forming_thr = spm_uc(cluster_forming_thr,df,STAT,R,n,S);

case 'FDR'
cluster_forming_thr = spm_uc_FDR(cluster_forming_thr,df,STAT,n,VspmSv,0);

case 'none'
if strcmp(height_threshold_type, 'p-value')
cluster_forming_thr = spm_u(cluster_forming_thr^(1/n),df,STAT);
Expand Down