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

[ENH] New diagnostics module, with post-meta-analysis Jackknife method #592

Merged
merged 28 commits into from
Nov 4, 2021

Conversation

tsalo
Copy link
Member

@tsalo tsalo commented Nov 2, 2021

Closes #590.

Changes proposed in this pull request:

  • Create new diagnostics module.
  • Create new Jackknife method, which loops through experiments in a meta-analysis, calculates the summary stat value (e.g., ALE) for the full dataset sans each experiment, and then calculates the reduction of the mean stat value for each cluster caused by dropping the experiment.
  • Fix bug in MetaResult in which a reference to the original Estimator was used instead of a copy. This could cause problems when an Estimator was fitted multiple times to different Datasets. The resulting MetaResults would have references to the Dataset and inputs_ from the last Estimator call. This might have been causing problems with Correctors (I'm not sure... 🤔), but shouldn't have been an issue for anything else.
  • Overhaul the examples page... I got a little excited and let this PR sprawl a bit too much. Oh well!
    • The fonts and colors are prettier thanks to some CSS magic inspired by nilearn.
    • I renamed the example files and used a different sorting approach in the sphinx-gallery settings so that they appear in the order we want.
    • Also the example titles are shorter so that there isn't that ugly "text falling outside the box" situation.
  • Drop build_docs job (closes Fix RTD/GitHub configuration so PR RTD builds are reported on GitHub #573).

To do:

  • Make it work on IBMAs
    • It currently works for all one-sample tests except PermutedOLS. The two-sample tests will take more work, as will supporting non-NiftiMasker maskers, such as are recommended for the likelihood-based IBMAs.
    • It now works with NiftiLabelsMaskers, and there is a meaningful error raised when a two-sample test is used. PermutedOLS probably still doesn't work though, since it doesn't use a masker.
  • Allow use of multiple cores
    - [ ] Convert into a proper Transformer? E.g., return an updated MetaResult object, with the labeled cluster map and the associated experiment contribution table. I don't want to tackle this in this PR. I'll do it in another one, I guess.
  • Tests
    • There is now a smoke test.
  • Documentation
    • Added to an example and to the API.

@tsalo
Copy link
Member Author

tsalo commented Nov 2, 2021

Here's an example output, based on the ALE done in the manuscript, here.

Cluster ID 1 2
Center of Mass (13, 7, 4) (1, 16, 51)
(10) Nestor, et al. (2010)-Lose Outcome, Cannabis > Controls 0.0 0.0
(10) Nestor, et al. (2010)-Neutral Cue, Cannabis > Controls 0.0 0.0
(10) Nestor, et al. (2010)-Neutral Lose Outcome, Cannabis > Controlss 0.2963552807733698 0.0
(10) Nestor, et al. (2010)-Neutral Win Outcome, Cannabis > Controls 0.0 0.0
(10) Nestor, et al. (2010)-Win Cue + Loss Cue, Cannabis > Controls 0.0 0.0
(10) Nestor, et al. (2010)-Win Cue, Cannabis > Controls 0.0005402339127975566 0.0
(10) Nestor, et al. (2010)-Win Outcome, Controls > Cannabis 0.0 0.0
(11) Chang, et al. (2006)-Tracking, THC+ > Controls 0.0 0.0
(11) Chang, et al. (2006)-Tracking, THC- > Controls 0.0 0.0
(12) Van Hell, et al. (2012)-Anticipation, Cannabis > Controls 0.0 0.0
(12) Van Hell, et al. (2012)-Evaluation, Cannabis > Controls 0.31927791677416867 0.0
(13) Fibey, et al. (2013)-Gain vs. Loss, Cannabis > Controls 0.0 0.0
(16) Tapert, et al. (2007)-Go, Cannabis > Controls 0.0 0.0
(16) Tapert, et al. (2007)-No-Go, Cannabis > Controls 0.0 0.09830522995583477
(17) Bolla, et al. (2005)-Iowa Gambling, Cannabis > Controls 0.0 0.0
(18) Yip, et al. (2014)-Evaluation, Cannabis > Controls 0.0 0.0
(19) Kanayama, et al. (2004)-Memory, Cannabis > Controls 0.0018282622449965708 3.1441375982744917e-07
(20) Abdullaeva, et al. (2010)-Attention, Cannabis > Controls 0.0 0.0
(20) Abdullaeva, et al. (2010)-Hard Word Generation, Cannabis > Control 2.230522934037457e-05 0.0
(20) Abdullaeva, et al. (2010)-Word Generation, Cannabis > Controls 1.6413045950837175e-09 0.0
(21) Smith, et al. (2010)-Memory, Cannabis > Controls 0.0 0.0
(22) Block, et al. (2002)-Memory, Cannabis > Controls 0.0 0.0
(23) Eldrith, et al. (2004)-Stroop, Cannabis > Controls 0.0 0.0
(24) Vaidya, et al. (2012)-Reward, Cannabis > Controls 0.0 0.0
(26) Hester, et al. (2009)-No-Go, Cannabis > Controls 0.03822828471307354 0.0
(27) Rosner, et al. (2012)-ToM, Cannabis > Controls 0.0 9.559916286267689e-10
(29) Acheson, et al. (2015)-Losses, Cannabis > Controls 2.6588488736467003e-06 0.0
(29) Acheson, et al. (2015)-Wins, Cannabis > Controls 0.33975581139861244 0.0
(3) , Gruber, et al. (2009)-Angry Faces, Cannabis > Controls 0.0 0.0
(3) , Gruber, et al. (2009)-Happy Faces, Cannabis > Controls 0.0 0.0
(31) Enzi, et al. (2015)-Reward Feedback, Cannabis > Controls 0.0 0.0
(34) Heitzeg et al. (2015)-Emotion Elicitation, Cannabis > Controls 0.0 0.0
(4) Schweinsburg, et al. (2008)-Memory, Cannabis > Controls 0.0 0.0
(5) Padula, et al. (2007)-n-back, Cannabis > Controls 0.0 0.0
(6) King, et al. (2011)-2 Hz Condition (Male) Cannabis > Controls 0.0 0.32498007945925583
(6) King, et al. (2011)-2 Hz Condition, Cannabis > Controls 0.0 0.32498007945925583
(6) King, et al. (2011)-4 Hz Condition (Female) Cannabis > Controls 0.0 0.0
(6) King, et al. (2011)-4 Hz Condition (Male) Cannabis > Controls 0.0 0.2474621792604293
(6) King, et al. (2011)-4 Hz Condition, Cannabis > Controls 0.0 0.0
(7) Lopez-Larson, et al. (2012)-Tapping, Controls > Cannabis 0.0 0.0
(9) Cousijn, et al. (2012)-Wins > Losses, Cannabis > Controls 0.0 0.0

@tsalo
Copy link
Member Author

tsalo commented Nov 3, 2021

Just came across a potential bug in the updated example. There are some negative values in the table, which shouldn't be possible with ALE metas, since ALEs only have positive values.

EDIT: The issue was that the Jackknife in that example was called twice- on different MetaResults. Those MetaResults contained references to the original ALEs, which was one object called twice on different Datasets, meaning that the MetaResults had the most recent version of the ALE (including the dataset and inputs_ attributes). This should be fixed in 4529cca.

@tsalo
Copy link
Member Author

tsalo commented Nov 4, 2021

Now there's a problem with the peaks2maps test...

EDIT: And now it seems fine 🤷

@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #592 (61fb674) into main (b1d7b74) will decrease coverage by 0.12%.
The diff coverage is 82.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #592      +/-   ##
==========================================
- Coverage   85.84%   85.72%   -0.13%     
==========================================
  Files          39       40       +1     
  Lines        4288     4384      +96     
==========================================
+ Hits         3681     3758      +77     
- Misses        607      626      +19     
Impacted Files Coverage Δ
nimare/base.py 88.18% <ø> (ø)
nimare/diagnostics.py 78.16% <78.16%> (ø)
nimare/meta/ibma.py 100.00% <100.00%> (ø)
nimare/results.py 91.89% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1d7b74...61fb674. Read the comment docs.

Comment on lines +177 to +191
# For the private method that does the work of the analysis, we have a lot of constant
# parameters, and only one that varies (the ID of the study being removed),
# so we use functools.partial.
transform_method = partial(
self._transform,
all_ids=meta_ids,
dset=dset,
estimator=estimator,
target_value_map=target_value_map,
stat_values=stat_values,
original_masker=original_masker,
cluster_masker=cluster_masker,
)
with Pool(self.n_cores) as p:
jackknife_results = list(tqdm(p.imap(transform_method, meta_ids), total=len(meta_ids)))
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems like a much cleaner approach than what I've been doing for Monte Carlo FWE correction in the CBMA classes. However, one thing I'm not sure about is if using Pool with one process is the same as running the same function without multiprocessing at all. @jdkent do you know?

@tsalo tsalo marked this pull request as ready for review November 4, 2021 19:00
@tsalo tsalo merged commit e9d55da into neurostuff:main Nov 4, 2021
@tsalo tsalo deleted the jackknife branch November 4, 2021 19:01
@tsalo tsalo added the enhancement New feature or request label Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jackknife post-meta-analysis method Fix RTD/GitHub configuration so PR RTD builds are reported on GitHub
1 participant