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

[REF] CBMA re-organization and improvement #393

Merged
merged 27 commits into from
Nov 14, 2020
Merged

[REF] CBMA re-organization and improvement #393

merged 27 commits into from
Nov 14, 2020

Conversation

tyarkoni
Copy link
Contributor

This PR refactors and standardizes the CBMA hierarchy. Changes include:

  • A new cbma folder containing base, ale, and mkda modules.
  • Individual estimator and kernel transformer classes are now imported into the meta namespace (though importing through the individual submodules will also still work, so code shouldn't break).
  • The ALE and MKDADensity classes have been dramatically stripped down, with most of the common functionality moving into CBMAEstimator.
  • The unified FWE correction procedure is no longer broken for MKDADensity, and should be considerably faster, as it doesn't need to compute p-values in each permutation.
  • Cleaner, vectorized cluster correction routine (should also be slightly faster).
  • More efficient null_to_p; now only processes unique values in array, and then reconstructs the original.
  • New p_to_summarystat() classmethod in CBMAEstimator that looks up a critical summary stat value based on the passed p-value.

With this done, we're in a good position to refactor some of the paired test classes, which could also in theory use a lot of the same machinery. But let's keep that for a separate PR.

@tyarkoni tyarkoni changed the title [REF] CBMA [REF] CBMA re-organization and improvement Nov 12, 2020
@tyarkoni tyarkoni requested a review from tsalo November 12, 2020 05:00
nimare/meta/cbma/base.py Outdated Show resolved Hide resolved
nimare/meta/cbma/base.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 12, 2020

Codecov Report

Merging #393 (4a99542) into master (7778493) will decrease coverage by 0.24%.
The diff coverage is 95.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #393      +/-   ##
==========================================
- Coverage   82.57%   82.32%   -0.25%     
==========================================
  Files          38       40       +2     
  Lines        3913     3848      -65     
==========================================
- Hits         3231     3168      -63     
+ Misses        682      680       -2     
Impacted Files Coverage Δ
nimare/base.py 85.71% <ø> (-1.27%) ⬇️
nimare/meta/cbma/base.py 94.31% <94.31%> (ø)
nimare/decode/continuous.py 93.61% <100.00%> (ø)
nimare/meta/__init__.py 100.00% <100.00%> (ø)
nimare/meta/cbma/__init__.py 100.00% <100.00%> (ø)
nimare/meta/cbma/ale.py 96.27% <100.00%> (ø)
nimare/meta/cbma/mkda.py 94.04% <100.00%> (ø)
nimare/stats.py 90.16% <100.00%> (+1.27%) ⬆️
nimare/workflows/ale.py 92.42% <100.00%> (ø)
nimare/workflows/macm.py 25.71% <100.00%> (ø)
... and 4 more

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 7778493...4a99542. Read the comment docs.

Copy link
Member

@tsalo tsalo left a comment

Choose a reason for hiding this comment

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

I think the code itself looks good, although there are a few docstrings that I'd like to fill out with an eye toward explaining the inheritance structure.

One thing that I think needs to be done before this is merged is updating the API section of the documentation and checking the docs build. If you'd rather not do that, I can handle it in a follow-up PR.

@tsalo
Copy link
Member

tsalo commented Nov 13, 2020

I've opened #395 targeting the refactor-cbma branch to handle the API update.

Comment on lines 99 to 100
def _compute_weights(self, ma_values):
return None
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this if it isn't an abstract method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because it serves as a dummy method for subclasses that don't take weights (e.g., ALE). It just allows us to avoid having different _fit() methods.

Comment on lines 172 to 173
def _compute_summarystat(self, ma_values):
pass
Copy link
Member

Choose a reason for hiding this comment

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

Should this be an abstract method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be, but only once we've refactored MKDAChi2 to have the same general architecture, which I'm planning to do separately. Otherwise it will break that class. (I suppose we could define a placeholder method in MKDAChi2 if you like.)

LGR = logging.getLogger(__name__)


class CBMAEstimator(MetaEstimator):
Copy link
Member

@tsalo tsalo Nov 14, 2020

Choose a reason for hiding this comment

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

This probably shouldn't happen now, but I'm thinking that we may want to further divide this into a DensityBasedEstimator and something else, so separate density-based approaches like ALE and MKDA from dramatically different ones like SDM-PSI.

Copy link
Contributor Author

@tyarkoni tyarkoni Nov 14, 2020

Choose a reason for hiding this comment

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

Agreed. I initially wanted to do it that way (i.e., to put all the abstracted methods into a DensityCBMAEstimator class), but figured we should see how far we can get by consolidating everything, instead of multiplying classes in advance. If we can't re-use everything in there right now for the pairwise estimators, we may also need to define a separate OneSample class (to parallel the Pairwise subclass).

@tyarkoni
Copy link
Contributor Author

@tsalo I added some docstrings. Assuming this looks good, I think we're okay to merge, unless you have other comments.

Copy link
Member

@tsalo tsalo left a comment

Choose a reason for hiding this comment

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

LGTM. I'll fix the conflicts on the other PR and change the target branch once this is merged.

@tyarkoni tyarkoni merged commit e1d6876 into master Nov 14, 2020
@tsalo tsalo deleted the refactor-cbma branch December 16, 2021 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants