Skip to content

Commit f414999

Browse files
authored
Clarify FWECorrector arguments (#865)
* Set default n_iters to 1,000, and add args to FWECorrector * Set variable n_iters based on estimator * Change more n_iters to 5000 * Run black * Remove voxel thresh from defaults * Set n_cores to 1
1 parent 4f687a8 commit f414999

6 files changed

Lines changed: 29 additions & 21 deletions

File tree

nimare/annotate/gclda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def __init__(
353353
self.topics["total_n_word_tokens_by_topic"][0, topic] += 1
354354
self.topics["n_word_tokens_doc_by_topic"][doc, topic] += 1
355355

356-
def fit(self, n_iters=10000, loglikely_freq=10):
356+
def fit(self, n_iters=5000, loglikely_freq=10):
357357
"""Run multiple iterations.
358358
359359
.. versionchanged:: 0.0.8

nimare/correct.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,25 +261,31 @@ class FWECorrector(Corrector):
261261
262262
Parameters
263263
----------
264-
method : :obj:`str`
265-
The FWE correction to use. Available internal methods are 'bonferroni'.
266-
Additional methods may be implemented within the provided Estimator.
264+
method : {'bonferoni', 'montecarlo'}
265+
The FWE correction to use. Note that the 'montecarlo' method is only available for
266+
a subset of Estimators. To determine what methods are available for the Estimator you're
267+
using, use :meth:`inspect`.
268+
voxel_thresh : :obj:`float`, optional
269+
Only used if ``method='montecarlo'``. The uncorrected voxel-level threshold to use.
270+
n_iters : :obj:`int`, optional
271+
Number of iterations to use for Monte Carlo correction.
272+
Default varies by Estimator.
273+
For publication-quality results, 5000 or more iterations are recommended.
274+
n_cores : :obj:`int`, optional
275+
Number of cores to use for Monte Carlo correction. Default is 1.
267276
**kwargs
268277
Keyword arguments to be used by the FWE correction implementation.
269-
270-
Notes
271-
-----
272-
This corrector supports a small number of internal FWE correction methods, but can also use
273-
special methods implemented within individual Estimators.
274-
To determine what methods are available for the Estimator you're using, use :meth:`inspect`.
275-
Estimators have special methods following the naming convention
276-
``correct_[correction-type]_[method]``
277-
(e.g., :func:`~nimare.meta.cbma.ale.ALE.correct_fwe_montecarlo`).
278278
"""
279279

280280
_correction_method = "fwe"
281281

282-
def __init__(self, method="bonferroni", **kwargs):
282+
def __init__(self, method="bonferroni", n_iters=None, n_cores=1, **kwargs):
283+
if method not in ("bonferroni", "montecarlo"):
284+
raise ValueError(f"Unsupported FWE correction method '{method}'")
285+
286+
if method == "montecarlo":
287+
kwargs.update({"n_iters": n_iters, "n_cores": n_cores})
288+
283289
self.method = method
284290
self.parameters = kwargs
285291

nimare/meta/cbma/ale.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __init__(
156156
**kwargs,
157157
)
158158
self.null_method = null_method
159-
self.n_iters = None if null_method == "approximate" else n_iters or 10000
159+
self.n_iters = None if null_method == "approximate" else n_iters or 5000
160160
self.n_cores = _check_ncores(n_cores)
161161
self.dataset = None
162162

@@ -403,7 +403,7 @@ class ALESubtraction(PairwiseCBMAEstimator):
403403
def __init__(
404404
self,
405405
kernel_transformer=ALEKernel,
406-
n_iters=10000,
406+
n_iters=5000,
407407
memory=Memory(location=None, verbose=0),
408408
memory_level=0,
409409
n_cores=1,
@@ -698,7 +698,7 @@ class SCALE(CBMAEstimator):
698698
def __init__(
699699
self,
700700
xyz,
701-
n_iters=10000,
701+
n_iters=5000,
702702
n_cores=1,
703703
kernel_transformer=ALEKernel,
704704
memory=Memory(location=None, verbose=0),

nimare/meta/cbma/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ def correct_fwe_montecarlo(
590590
self,
591591
result,
592592
voxel_thresh=0.001,
593-
n_iters=10000,
593+
n_iters=5000,
594594
n_cores=1,
595595
vfwe_only=False,
596596
):

nimare/meta/cbma/mkda.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def _apply_correction(self, stat_values, voxel_thresh, vfwe_null, csfwe_null, cm
715715

716716
return p_vfwe_values, p_csfwe_values, p_cmfwe_values
717717

718-
def correct_fwe_montecarlo(self, result, voxel_thresh=0.001, n_iters=5000, n_cores=1):
718+
def correct_fwe_montecarlo(self, result, voxel_thresh=0.001, n_iters=1000, n_cores=1):
719719
"""Perform FWE correction using the max-value permutation method.
720720
721721
Only call this method from within a Corrector.
@@ -732,6 +732,8 @@ def correct_fwe_montecarlo(self, result, voxel_thresh=0.001, n_iters=5000, n_cor
732732
----------
733733
result : :obj:`~nimare.results.MetaResult`
734734
Result object from a KDA meta-analysis.
735+
voxel_thresh : :obj:`float`, optional
736+
Voxel-level threshold. Default is 0.001.
735737
n_iters : :obj:`int`, optional
736738
Number of iterations to build the vFWE null distribution.
737739
Default is 5000.
@@ -1164,7 +1166,7 @@ def __init__(
11641166
**kwargs,
11651167
)
11661168
self.null_method = null_method
1167-
self.n_iters = None if null_method == "approximate" else n_iters or 10000
1169+
self.n_iters = None if null_method == "approximate" else n_iters or 5000
11681170
self.n_cores = _check_ncores(n_cores)
11691171
self.dataset = None
11701172

nimare/meta/ibma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ def _fit(self, dataset):
13211321

13221322
return maps, {}, description
13231323

1324-
def correct_fwe_montecarlo(self, result, n_iters=10000, n_cores=1):
1324+
def correct_fwe_montecarlo(self, result, n_iters=1000, n_cores=1):
13251325
"""Perform FWE correction using the max-value permutation method.
13261326
13271327
.. versionchanged:: 0.0.8

0 commit comments

Comments
 (0)