nimare.meta.cbma.mkda.MKDAChi2
- class MKDAChi2(kernel_transformer=<class 'nimare.meta.kernel.MKDAKernel'>, prior=0.5, fwe_null_method='label-permutation', memory=Memory(location=None), memory_level=0, **kwargs)[source]
Bases:
PairwiseCBMAEstimatorMultilevel kernel density analysis- Chi-square analysis.
The MKDA chi-square method was originally introduced in Wager et al.[1].
Changed in version 0.2.1:
- Make prior parameter default to None, which controls if posterior probabilities
pFgA, pAgF_prior and pFgA_prior are calculated. This is useful because probability maps are difficult to interpret and for speeding up the algorithm.
Rename
consistencytouniformityandspecificitytoassociationto match Neurosynth’s terminologyNew parameters:
memoryandmemory_levelfor memory caching.
Changed in version 0.0.12:
Use a 4D sparse array for modeled activation maps.
Changed in version 0.0.8:
[REF] Use saved MA maps, when available.
- Parameters:
kernel_transformer (
KernelTransformer, optional) – Kernel with which to convolve coordinates from dataset. Default isMKDAKernel.prior (float, default=0.5) – Uniform prior probability of each feature being active in a map in the absence of evidence from the map. Default: 0.5
memory (instance of
joblib.Memory,str, orpathlib.Path) – Used to cache the output of a function. By default, no caching is done. If astris given, it is the path to the caching directory.memory_level (
int, default=0) – Rough estimator of the amount of memory used by caching. Higher value means more memory for caching. Zero means no caching.**kwargs – Keyword arguments. Arguments for the kernel_transformer can be assigned here, with the prefix ‘kernel__’ in the variable name.
- Variables:
masker (
NiftiMaskeror similar) – Masker object.inputs (
dict) – Inputs to the Estimator. For CBMA estimators, there is only one key: coordinates. This is an edited version of the dataset’s coordinates DataFrame.null_distributions (
dictofnumpy.ndarray) –Null distributions for any multiple-comparisons correction methods.
Important
MKDAChi2 does not retain uncorrected summary-statistic-to-p null distributions, since the summary statistic in this case is the chi-squared value, which has an established null distribution.
Entries are added to this attribute if and when the corresponding method is applied.
If
correct_fwe_montecarlo()is applied:values_desc-pAgF_level-voxel_corr-fwe_method-montecarlo: The maximum chi-squared value from the p(A|F) one-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pAgFsize_level-cluster_corr-fwe_method-montecarlo: The maximum cluster size value from the p(A|F) one-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pAgFmass_level-cluster_corr-fwe_method-montecarlo: The maximum cluster mass value from the p(A|F) one-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pFgA_level-voxel_corr-fwe_method-montecarlo: The maximum chi-squared value from the p(F|A) two-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pFgAsize_level-cluster_corr-fwe_method-montecarlo: The maximum cluster size value from the p(F|A) two-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pFgAmass_level-cluster_corr-fwe_method-montecarlo: The maximum cluster mass value from the p(F|A) two-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).
Notes
The MKDA Chi-square algorithm was originally implemented as part of the Neurosynth Python library (https://github.com/neurosynth/neurosynth).
Available correction methods:
MKDAChi2.correct_fwe_montecarlo(),MKDAChi2.correct_fdr_indep().References
Methods
correct_fdr_indep(result[, alpha])Perform FDR correction using the Benjamini-Hochberg method.
correct_fwe_montecarlo(result[, ...])Perform FWE correction using the max-value permutation method.
fit(dataset1, dataset2[, drop_invalid, ...])Fit Estimator to two collections.
get_params([deep])Get parameters for this estimator.
load(filename[, compressed])Load a pickled class instance from file.
save(filename[, compress])Pickle the class instance to the provided file.
set_params(**params)Set the parameters of this estimator.
- correct_fdr_indep(result, alpha=0.05)[source]
Perform FDR correction using the Benjamini-Hochberg method.
Only call this method from within a Corrector.
Changed in version 0.0.12: Renamed from
correct_fdr_bhtocorrect_fdr_indep.- Parameters:
result (
MetaResult) – Result object from a KDA meta-analysis.alpha (
float, optional) – Alpha. Default is 0.05.
- Returns:
maps – Dictionary of 1D arrays corresponding to masked maps generated by the correction procedure. The following arrays are generated by this method: ‘z_desc-uniformity_level-voxel’ and ‘z_desc-association_level-voxel’.
- Return type:
See also
nimare.correct.FDRCorrectorThe Corrector from which to call this method.
Examples
>>> meta = MKDAChi2() >>> result = meta.fit(dset) >>> corrector = FDRCorrector(method='indep', alpha=0.05) >>> cresult = corrector.transform(result)
- correct_fwe_montecarlo(result, voxel_thresh=0.001, n_iters=1000, n_cores=1)[source]
Perform FWE correction using the max-value permutation method.
Only call this method from within a Corrector.
Changed in version 0.0.13: Change cluster neighborhood from faces+edges to faces, to match Nilearn.
Changed in version 0.0.12: Include cluster level-corrected results in Monte Carlo null method.
- Parameters:
result (
MetaResult) – Result object from a KDA meta-analysis.voxel_thresh (
float, default=0.001) – Voxel-level threshold. Default is 0.001.n_iters (
int, default=1000) – Number of iterations to build the vFWE null distribution. Default is 1000.n_cores (
int, default=1) – Number of cores to use for parallelization. If <=0, defaults to using all available cores. Default is 1.
- Returns:
maps – Dictionary of 1D arrays corresponding to masked maps generated by the correction procedure. The following arrays are generated by this method:
p_desc-uniformity_level-voxel: Voxel-level FWE-corrected p-values from the uniformity/forward inference analysis.z_desc-uniformity_level-voxel: Voxel-level FWE-corrected z-values from the uniformity/forward inference analysis.logp_desc-uniformity_level-voxel: Voxel-level FWE-corrected -log10 p-values from the uniformity/forward inference analysis.p_desc-uniformityMass_level-cluster: Cluster-level FWE-corrected p-values from the uniformity/forward inference analysis, using cluster mass.z_desc-uniformityMass_level-cluster: Cluster-level FWE-corrected z-values from the uniformity/forward inference analysis, using cluster mass.logp_desc-uniformityMass_level-cluster: Cluster-level FWE-corrected -log10 p-values from the uniformity/forward inference analysis, using cluster mass.p_desc-uniformitySize_level-cluster: Cluster-level FWE-corrected p-values from the uniformity/forward inference analysis, using cluster size.z_desc-uniformitySize_level-cluster: Cluster-level FWE-corrected z-values from the uniformity/forward inference analysis, using cluster size.logp_desc-uniformitySize_level-cluster: Cluster-level FWE-corrected -log10 p-values from the uniformity/forward inference analysis, using cluster size.p_desc-association_level-voxel: Voxel-level FWE-corrected p-values from the association/reverse inference analysis.z_desc-association_level-voxel: Voxel-level FWE-corrected z-values from the association/reverse inference analysis.logp_desc-association_level-voxel: Voxel-level FWE-corrected -log10 p-values from the association/reverse inference analysis.p_desc-associationMass_level-cluster: Cluster-level FWE-corrected p-values from the association/reverse inference analysis, using cluster mass.z_desc-associationMass_level-cluster: Cluster-level FWE-corrected z-values from the association/reverse inference analysis, using cluster mass.logp_desc-associationMass_level-cluster: Cluster-level FWE-corrected -log10 p-values from the association/reverse inference analysis, using cluster mass.p_desc-associationSize_level-cluster: Cluster-level FWE-corrected p-values from the association/reverse inference analysis, using cluster size.z_desc-associationSize_level-cluster: Cluster-level FWE-corrected z-values from the association/reverse inference analysis, using cluster size.logp_desc-associationSize_level-cluster: Cluster-level FWE-corrected -log10 p-values from the association/reverse inference analysis, using cluster size.
- Return type:
Notes
This method adds six new keys to the
null_distributions_attribute:values_desc-pAgF_level-voxel_corr-fwe_method-montecarlo: The maximum chi-squared value from the p(A|F) one-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pAgFsize_level-cluster_corr-fwe_method-montecarlo: The maximum cluster size value from the p(A|F) one-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pAgFmass_level-cluster_corr-fwe_method-montecarlo: The maximum cluster mass value from the p(A|F) one-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pFgA_level-voxel_corr-fwe_method-montecarlo: The maximum chi-squared value from the p(F|A) two-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pFgAsize_level-cluster_corr-fwe_method-montecarlo: The maximum cluster size value from the p(F|A) two-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).values_desc-pFgAmass_level-cluster_corr-fwe_method-montecarlo: The maximum cluster mass value from the p(F|A) two-way chi-squared test from each Monte Carlo iteration. An array of shape (n_iters,).
See also
nimare.correct.FWECorrectorThe Corrector from which to call this method.
Examples
>>> meta = MKDAChi2() >>> result = meta.fit(dset) >>> corrector = FWECorrector(method='montecarlo', n_iters=5, n_cores=1) >>> cresult = corrector.transform(result)
- fit(dataset1, dataset2, drop_invalid=True, ma_maps1=None, ma_maps2=None, inference_map1=None, inference_map2=None)[source]
Fit Estimator to two collections.
- Parameters:
dataset1/dataset2 (
StudysetorDataset) – Collection objects to analyze.ma_maps1/ma_maps2 (scipy sparse matrix or sparse array, optional) – Precomputed study-wise MA maps aligned to
dataset1anddataset2, respectively. When provided, the estimator will reuse these maps instead of recomputing them from coordinates. These are typically 2D study-by-masked-voxel sparse matrices.inference_map1/inference_map2 (array_like or Niimg-like, optional) – Optional directional inference maps aligned to the common masked voxel space. Positive pairwise effects are only evaluated where
inference_map1 > 0, and negative pairwise effects are only evaluated whereinference_map2 > 0.
- Returns:
MetaResult– Results of Estimator fitting... warning:: – Support for
Datasetinputs is deprecated and will be removed in a future release. PreferStudyset.The
fitmethod is a light wrapper that runs input validation andpreprocessing before fitting the actual model. Estimators’ individual
”fitting” methods are implemented as
_fit, although users shouldcall
fit.
- classmethod load(filename, compressed=True)[source]
Load a pickled class instance from file.
- Parameters:
- Returns:
obj – Loaded class object.
- Return type:
class object
- set_params(**params)[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>so that it’s possible to update each component of a nested object.- Return type:
self