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] Reorganize selcomps and fitmodels_direct #266

Merged
merged 19 commits into from
May 23, 2019

Conversation

tsalo
Copy link
Member

@tsalo tsalo commented Apr 21, 2019

Closes #16. This was originally part of #247, but has been split off because it is self-contained and should be merged separately.

Changes proposed in this pull request:

  • Rename fitmodels_direct to dependence_metrics
  • Split sel_comps into manual_selection, kundu_selection_v2, and kundu_metrics
  • Move kundu_metrics into model.fit
  • Rename selcomps to tedica
  • Rename PCA-derived variance explained column in PCA component table. This will no longer overwrite the one from fitmodels_direct
  • Add reorder_dataframe function to selection._utils
  • Update website documentation to match API changes
  • Add relevant tests

tsalo added 2 commits April 21, 2019 16:05
- Rename fitmodels_direct to dependence_metrics
- Split sel_comps into manual_selection, kundu_selection_v2, and
kundu_metrics
- Move kundu_metrics into model.fit
- Rename selcomps to tedica
- Rename PCA-derived variance explained column in PCA component table.
This will no longer overwrite the one from fitmodels_direct
- Add reorder_dataframe function to selection._utils
@ME-ICA ME-ICA deleted a comment from codecov bot Apr 22, 2019
@codecov
Copy link

codecov bot commented Apr 22, 2019

Codecov Report

Merging #266 into master will increase coverage by 2.93%.
The diff coverage is 78.42%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #266      +/-   ##
=========================================
+ Coverage   46.16%   49.1%   +2.93%     
=========================================
  Files          35      37       +2     
  Lines        2060    2122      +62     
=========================================
+ Hits          951    1042      +91     
+ Misses       1109    1080      -29
Impacted Files Coverage Δ
tedana/model/__init__.py 100% <ø> (ø) ⬆️
tedana/decomposition/pca.py 15.49% <0%> (ø) ⬆️
tedana/workflows/tedana.py 12.43% <0%> (-0.72%) ⬇️
tedana/tests/test_selection.py 100% <100%> (ø)
tedana/tests/test_model_fit_dependence_metrics.py 100% <100%> (ø)
tedana/selection/__init__.py 100% <100%> (ø) ⬆️
tedana/selection/_utils.py 25% <100%> (+10.71%) ⬆️
tedana/tests/test_model_kundu_metrics.py 100% <100%> (ø)
tedana/selection/tedpca.py 11.47% <33.33%> (+0.36%) ⬆️
tedana/model/fit.py 38.81% <69.81%> (+8.37%) ⬆️
... and 5 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 a11275d...540d302. Read the comment docs.

@ME-ICA ME-ICA deleted a comment from codecov bot Apr 22, 2019
@tsalo tsalo requested a review from emdupre April 22, 2019 16:16
# Conflicts:
#	tedana/selection/select_comps.py
#	tedana/workflows/tedana.py
Copy link
Member

@emdupre emdupre left a comment

Choose a reason for hiding this comment

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

Thanks for doing this, @tsalo ! I did a first pass review. Still have a few questions that it'd be great to confirm !

docs/api.rst Show resolved Hide resolved
docs/api.rst Show resolved Hide resolved

tedana.model.fit

:mod:`tedana.combine`: Combining time series across echoes
Copy link
Member

Choose a reason for hiding this comment

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

Here you have combine, but below you've replaced it with model. We should harmonize.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just reordered them based on when they occur in the workflow. It's possible that I missed some changes though, so I apologize if that's adding to the confusion.


:template: module.rst

tedana.combine
tedana.model.fit
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that we want to call this a .fit, since it could be easily confused with the sklearn convention.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've never liked fit either. We can change tedana.model to tedana.metrics (as you suggested above), but we'll still need a file below that in order to keep model/metrics as a subfolder-organized submodule. I fully expect us to expand our sets of metrics (e.g., with AROMA-like motion- and artifact-based ones), which is why I don't think we should just put it in one top-level file (i.e., tedana/metrics.py), but that still leaves us with the issue of what to name the file.

Copy link
Member

Choose a reason for hiding this comment

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

Since we're not quite there yet (e.g., adding motion based metrics), though, I think we should just keep it in a top-level file for now -- we can expand when we add more. WDYT ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, #273 moves the two remaining functions (get_coeffs and computefeats2) in model.fit into a new stats module, so the only things in model.fit will be the metrics (dependence_metrics and kundu_metrics).

Copy link
Member Author

Choose a reason for hiding this comment

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

I can move it there then. So, tedana/model/fit.py will become tedana/model.py and the tedana/model/ folder will be removed. Does that sound good?

reindex=False, mmixN=vTmixN, full_sel=False,
comptable, _, _, _ = model.dependence_metrics(
data_cat, data_oc, comp_ts, eimum, t2s, tes, ref_img,
reindex=False, mmixN=vTmixN, method=None,
Copy link
Member

Choose a reason for hiding this comment

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

method is a little too ambiguous of an argument, here.

Whether to sort components in descending order by Kappa. Default: False
mmixN : (T x C) array_like, optional
Z-scored mixing matrix. Default: None
method : {'kundu_v2', 'kundu_v3', None}, optional
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could call this decision ?

Copy link
Member

Choose a reason for hiding this comment

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

Does None make sense as the default argument ? What behavior do we expect when we return an empty seldict ?

Copy link
Member

Choose a reason for hiding this comment

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

I'm also still really unsure that we should have kundu_v3 here, since it's not reintegrated, and we don't know when it will be.

Copy link
Member Author

@tsalo tsalo Apr 30, 2019

Choose a reason for hiding this comment

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

None is the PCA decision tree-compatible version, which doesn't return metric maps and only gives back the component table. I could change that to pca or kundu_pca?

kundu_v3 requires certain metric maps in seldict (e.g., PSC, WTS, and tsoc_B) that kundu_v2 does not. I didn't want to remove those metric maps from the overall function, because it would be annoying to re-implement them later, but also didn't want to output an oversized version of seldict when it's not necessary. I can drop it from the arguments and docstring, but I'd like to keep it in the if/else statement below.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think decision is right, since that implies that actual decisions are made in this function. It really just determines which outputs will be generated. PCA requires just the component table, while Kundu ICA v2 requires that and several metric maps, and Kundu ICA v3 requires the component table and even more metric maps.

What about algorithm?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like to vote for algorithm; it's wide open for adding other, well, algorithms.

from tedana.model import fit


def test_break_dependence_metrics():
Copy link
Member

Choose a reason for hiding this comment

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

😍

Copy link
Collaborator

@jbteves jbteves left a comment

Choose a reason for hiding this comment

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

This is altogether fantastic work. I've left some comments indicating where I think some documentation could be shored up, but I don't think it's anything major. Thanks @tsalo !

Whether to sort components in descending order by Kappa. Default: False
mmixN : (T x C) array_like, optional
Z-scored mixing matrix. Default: None
method : {'kundu_v2', 'kundu_v3', None}, optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like to vote for algorithm; it's wide open for adding other, well, algorithms.

tedana/selection/_utils.py Outdated Show resolved Hide resolved
tedana/selection/_utils.py Outdated Show resolved Hide resolved
tedana/selection/tedica.py Show resolved Hide resolved
tedana/tests/test_model_kundu_metrics.py Outdated Show resolved Hide resolved
tedana/tests/test_model_kundu_metrics.py Outdated Show resolved Hide resolved
tedana/tests/test_selection.py Show resolved Hide resolved
tedana/workflows/tedana.py Show resolved Hide resolved
jbteves
jbteves previously approved these changes May 23, 2019
Copy link
Collaborator

@jbteves jbteves left a comment

Choose a reason for hiding this comment

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

With your latest commit everything looks good. Awesome, thanks @tsalo !

Copy link
Collaborator

@jbteves jbteves left a comment

Choose a reason for hiding this comment

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

I can't believe I missed that in my review; oopsie.

@tsalo
Copy link
Member Author

tsalo commented May 23, 2019

@jbteves Thanks! Would you mind changing your review status?

@jbteves
Copy link
Collaborator

jbteves commented May 23, 2019

@tsalo done! Awesome.

@tsalo
Copy link
Member Author

tsalo commented May 23, 2019

Yay, merging now.

@tsalo tsalo merged commit 1030a69 into ME-ICA:master May 23, 2019
@tsalo tsalo deleted the reorg-metrics branch May 23, 2019 16:28
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.

Break selcomps into functions
3 participants