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] Update Figure Generation Code #236

Merged
merged 35 commits into from
Mar 20, 2019
Merged

Conversation

dowdlelt
Copy link
Collaborator

@dowdlelt dowdlelt commented Mar 18, 2019

Closes #232 .

Changes proposed in this pull request:

  • Adds more details to title of plots, including clearly labeling component decision and rationale(s), if rejected or ignored
  • trims away all zero slices prior to plotting brains, so that every figure slice contains data, rather than producing completely empty blank spaces
  • Replaces bar plot with more informative pie chart
  • pie chart shows total variance (outer ring) as well as individual component variance (inner ring) along with number of components in each category.
  • if some variance is unexplained, pie chart will show as well, though calculation is not perfectly accurate at this time
  • a number of fixes regarding matplotlib debugging/usage mentioned by @tsalo added
  • Time series and fft plots no longer have yticks - not that useful
  • fft now completely fills plot
  • custom color map can be requested, ex. --png-cmap 'bone. If not used or specified incorrectly, code will use use default
  • 'figure' folder creation moved to tedana workflow, figures now written using out_dir variable
  • get_spectrum moved to utils

Example of pie chart:
image

Example of new timeseries plots, with titles.
image

tedana/workflows/tedana.py Outdated Show resolved Hide resolved
tedana/workflows/tedana.py Outdated Show resolved Hide resolved
@dowdlelt
Copy link
Collaborator Author

@tsalo just noticed that I've duplicated your work - I looked through your viz_update branch and it seems like I wasn't too far off the mark on my fixes but would still appreciate a close look.

tedana/viz.py Outdated Show resolved Hide resolved
tedana/viz.py Outdated Show resolved Hide resolved
tedana/viz.py Outdated Show resolved Hide resolved
tedana/viz.py Outdated Show resolved Hide resolved
comp_rho = "{0:.2f}".format(comptable.iloc[compnum][2])
plt_title = 'Comp. {}: variance: {}%, kappa: {}, rho: {}'.format(compnum, comp_var,
comp_kappa, comp_rho)
comp_var = "{0:.2f}".format(comptable.iloc[compnum]["variance explained"])
Copy link
Member

Choose a reason for hiding this comment

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

Should we use "variance explained" or "normalized variance explained" here and elsewhere?
@emdupre Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thinking more on this, both of these sum up to be close to 100, even in cases where the PCs entered into in the ICA step explain <100% of the variance, right, because ICs are not orthogonal? I'm looking at an older run of the meica tedana, where the comp_table says 76.7% of the variance was explained, but summing the Variance and Variance norm columns gives me 100.03 and 96.78% respectively.

Means that 100 - sum(variance_expl) that calculates the unexplained variance is never going to work quite right.

Nor would calculating the variance explained (as is done in io.py, around line 202) and adding that in give the right number - because then the pie chart would be relative to the total (ie ~100 variance from ICA + unexplained = some_number >100). Perhaps some scaling would be needed for the values, prior to giving them to that part of figure creation.

Copy link
Member

Choose a reason for hiding this comment

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

👍 for postponing the discussion until #223 !

@codecov
Copy link

codecov bot commented Mar 18, 2019

Codecov Report

Merging #236 into master will decrease coverage by 0.84%.
The diff coverage is 12.34%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #236      +/-   ##
==========================================
- Coverage   47.19%   46.34%   -0.85%     
==========================================
  Files          32       32              
  Lines        1977     2026      +49     
==========================================
+ Hits          933      939       +6     
- Misses       1044     1087      +43
Impacted Files Coverage Δ
tedana/workflows/tedana.py 13.66% <0%> (-0.26%) ⬇️
tedana/viz.py 9.86% <12.67%> (+0.85%) ⬆️
tedana/utils.py 94.02% <20%> (-5.98%) ⬇️

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 2d99a0b...fe05678. Read the comment docs.

Co-Authored-By: dowdlelt <logan.dowdle@gmail.com>
@tsalo
Copy link
Member

tsalo commented Mar 18, 2019

@tsalo just noticed that I've duplicated your work - I looked through your viz_update branch and it seems like I wasn't too far off the mark on my fixes but would still appreciate a close look.

I did play around a bit in via-update, but went a little too far with refactoring your code, which is why I don't plan to open a PR or anything. It did help me understand what was happening though.

tedana/workflows/tedana.py Outdated Show resolved Hide resolved
tedana/workflows/tedana.py Outdated Show resolved Hide resolved
@dowdlelt
Copy link
Collaborator Author

Travis really doesn't like 3 long lines, so I'll think on that. Otherwise, I've dealt with everything but the trailing semicolons.

@dowdlelt
Copy link
Collaborator Author

This now seems to work great without complaints. Pending further review and general acceptance of this pull request, I am curious if we would want to save the variance explained question for another round...

@tsalo
Copy link
Member

tsalo commented Mar 18, 2019

It looks great to me. I'm happy to hold off on discussing variance explained. In fact, my concerns regarding the variance explained calculated within fitmodels_direct are already outlined in #223, and we can circle back to the values used in the plots once that's figured out.

@tsalo tsalo requested a review from emdupre March 18, 2019 21:11
@dowdlelt
Copy link
Collaborator Author

I've been meaning to dig into #223 more - guess we all have a bit more time with the call delayed. Thanks for all the help with this!

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.

This looks great. Had a few small comments but I think this is basically ready 🚀

tedana/viz.py Outdated Show resolved Hide resolved
tedana/utils.py Outdated Show resolved Hide resolved
tedana/viz.py Show resolved Hide resolved
tedana/viz.py Outdated Show resolved Hide resolved
tedana/viz.py Show resolved Hide resolved
tedana/viz.py Outdated Show resolved Hide resolved
comp_rho = "{0:.2f}".format(comptable.iloc[compnum][2])
plt_title = 'Comp. {}: variance: {}%, kappa: {}, rho: {}'.format(compnum, comp_var,
comp_kappa, comp_rho)
comp_var = "{0:.2f}".format(comptable.iloc[compnum]["variance explained"])
Copy link
Member

Choose a reason for hiding this comment

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

👍 for postponing the discussion until #223 !

tedana/viz.py Show resolved Hide resolved
tedana/viz.py Show resolved Hide resolved
emdupre and others added 5 commits March 19, 2019 08:31
Co-Authored-By: dowdlelt <logan.dowdle@gmail.com>
Co-Authored-By: dowdlelt <logan.dowdle@gmail.com>
Co-Authored-By: dowdlelt <logan.dowdle@gmail.com>
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.

LGTM ! Thanks 🎉 🎉

@dowdlelt
Copy link
Collaborator Author

Awesome Awesome. Thanks for all the feedback folks

@tsalo
Copy link
Member

tsalo commented Mar 20, 2019

Since everyone's happy with the current version, are we ready to merge?

@emdupre
Copy link
Member

emdupre commented Mar 20, 2019

Push the button whenever you're ready, @tsalo 👍

@tsalo tsalo merged commit e39d1f0 into ME-ICA:master Mar 20, 2019
@dowdlelt dowdlelt deleted the trim_zeros branch November 3, 2019 22:55
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.

Improve generated figures
3 participants