Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TFCE thresholding in CBMA algorithms #655

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4e6668a
Use scipy function to define edge-connectivity.
tsalo Mar 9, 2022
3a29590
Add TFCE function.
tsalo Mar 9, 2022
b2b2aff
Start adding TFCE into the CBMAEstimator.
tsalo Mar 9, 2022
653a5de
Update base.py
tsalo Mar 9, 2022
7b00875
Fix import.
tsalo Mar 9, 2022
ea194ba
Fix import again.
tsalo Mar 9, 2022
be723c5
Split up tests.
tsalo Mar 10, 2022
e17e91f
Fix TFCE.
tsalo Mar 10, 2022
b05f1fb
Fix vfwe_only.
tsalo Mar 10, 2022
0f875ae
Convert some CBMAEstimator methods to functions.
tsalo Mar 10, 2022
5b283de
Add information about TFCE to the CBMA docs.
tsalo Mar 14, 2022
2594c08
Merge branch 'main' into tfce
tsalo Mar 15, 2022
55f8ef4
Remove duplicate function.
tsalo Mar 15, 2022
9405ded
Update 05_plot_correctors.py
tsalo Mar 15, 2022
4ab1f78
Update 05_plot_correctors.py
tsalo Mar 15, 2022
05b8a9b
Merge remote-tracking branch 'upstream/main' into tfce
tsalo Mar 21, 2022
1c48653
Remove outdated test.
tsalo Mar 21, 2022
cafe89e
Update 05_plot_correctors.py
tsalo Mar 21, 2022
ba53f55
Use fslmaths' dh and add two_sided TFCE support.
tsalo Apr 1, 2022
148f00b
Update 05_plot_correctors.py
tsalo Apr 1, 2022
d95b301
Update base.py
tsalo Apr 12, 2022
42b7a48
Enhance TFCE docstring.
tsalo Apr 21, 2022
31c4a6b
Add test.
tsalo Apr 21, 2022
097a05f
Merge branch 'main' into tfce
tsalo Apr 21, 2022
ea4440d
Fix linting issues.
tsalo Apr 21, 2022
80a275a
Implement TFCE with MKDAChi2.
tsalo Apr 21, 2022
d6e1af6
Add utils module to API docs.
tsalo Apr 22, 2022
cb7fcfc
Merge branch 'main' into tfce
tsalo Apr 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ For more information about the components of coordinate-based meta-analysis in N
meta.cbma.mkda
meta.cbma.base
meta.kernel
meta.utils

.. _api_results_ref:

Expand Down
6 changes: 6 additions & 0 deletions docs/cbma.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,9 @@ The Monte Carlo FWE correction approach implemented in NiMARE produces three new
the voxel's summary statistic value lands on this null distribution.
**Voxel-level correction is generally more conservative than cluster-level correction,
so it is only recommended for very large meta-analyses (i.e., hundreds of studies).**
- ``<z|logp>_desc-tfce_level-voxel_corr-FWE_method-montecarlo``:
Voxel-level FWE-corrected map based on threshold-free cluster enhancement values.
`Threshold-free cluster enhancement <TFCE>`_ is a generalization of the cluster mass measure that
eliminates the need for a cluster-defining threshold, by essentially calculating cluster mass
across a range of thresholds, for each voxel, and then summing those masses across thresholds.
**These maps are only produced if ``tfce`` is enabled in the ``FWECorrector``.**
2 changes: 2 additions & 0 deletions docs/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@
.. _Sleuth: http://www.brainmap.org/software.html#Sleuth

.. _SPM: https://www.fil.ion.ucl.ac.uk/spm/

.. _TFCE: https://pubmed.ncbi.nlm.nih.gov/18501637/
13 changes: 9 additions & 4 deletions examples/02_meta-analyses/05_plot_correctors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,28 @@
#
# The "montecarlo" method is a special one that is implemented within the
# Estimator, rather than in the Corrector.
corr = FWECorrector(method="montecarlo", n_iters=50, n_cores=2)
corr = FWECorrector(method="montecarlo", n_iters=25, n_cores=2, tfce=True)
cres = corr.transform(results)

DISTS_TO_PLOT = [
"values_desc-size_level-cluster_corr-fwe_method-montecarlo",
"values_desc-mass_level-cluster_corr-fwe_method-montecarlo",
"values_level-voxel_corr-fwe_method-montecarlo",
"values_desc-tfce_level-voxel_corr-fwe_method-montecarlo",
]
XLABELS = [
"Maximum Cluster Size (Voxels)",
"Maximum Cluster Mass",
"Maximum Summary Statistic (ALE Value)",
"Maximum TFCE Value",
]

fig, axes = plt.subplots(figsize=(8, 8), nrows=3)
fig, axes = plt.subplots(figsize=(8, 8), nrows=len(DISTS_TO_PLOT))
null_dists = cres.estimator.null_distributions_

for i_ax, dist_name in enumerate(DISTS_TO_PLOT):
xlabel = XLABELS[i_ax]
sns.histplot(x=null_dists[dist_name], bins=40, ax=axes[i_ax])
sns.histplot(x=null_dists[dist_name], bins=20, ax=axes[i_ax])
axes[i_ax].set_title(dist_name)
axes[i_ax].set_xlabel(xlabel)
axes[i_ax].set_xlim(0, None)
Expand All @@ -95,15 +97,17 @@
"z_desc-size_level-cluster_corr-FWE_method-montecarlo",
"z_desc-mass_level-cluster_corr-FWE_method-montecarlo",
"z_level-voxel_corr-FWE_method-montecarlo",
"z_desc-tfce_level-voxel_corr-FWE_method-montecarlo",
]
TITLES = [
"Uncorrected z-statistics",
"Cluster-size FWE-corrected z-statistics",
"Cluster-mass FWE-corrected z-statistics",
"Voxel-level FWE-corrected z-statistics",
"TFCE FWE-corrected z-statistics",
]

fig, axes = plt.subplots(figsize=(8, 10), nrows=4)
fig, axes = plt.subplots(figsize=(8, 12), nrows=len(MAPS_TO_PLOT))

for i_ax, map_name in enumerate(MAPS_TO_PLOT):
title = TITLES[i_ax]
Expand All @@ -115,6 +119,7 @@
cut_coords=[0, 0, -8],
figure=fig,
axes=axes[i_ax],
annotate=False,
)
axes[i_ax].set_title(title)

Expand Down
2 changes: 2 additions & 0 deletions nimare/meta/cbma/ale.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class ALE(CBMAEstimator):
size from each Monte Carlo iteration. An array of shape (n_iters,).
- ``values_desc-mass_level-cluster_corr-fwe_method-montecarlo``: The maximum cluster
mass from each Monte Carlo iteration. An array of shape (n_iters,).
- ``values_desc-tfce_level-level_corr-fwe_method-montecarlo``: The maximum TFCE
value from each Monte Carlo iteration. An array of shape (n_iters,).

Notes
-----
Expand Down