-
Notifications
You must be signed in to change notification settings - Fork 95
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
[FIX] Calculate Kappa and Rho on full F-statistic maps #714
Conversation
Codecov Report
@@ Coverage Diff @@
## main #714 +/- ##
=======================================
Coverage 93.09% 93.09%
=======================================
Files 25 25
Lines 1782 1782
=======================================
Hits 1659 1659
Misses 123 123
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for fixing @tsalo !
This generally looks good, but could you line it up with the current |
Also, we've been lax on using it, but since this will change the output, shouldn't the PR title also include the [BRK] tag? There fixes that wouldn't change the output. This probably does change the output. |
It seems reasonable to identify any PR that changes outputs, although I think a label would be better than a prefix. I will create a new EDIT: Never mind, the |
To clarify an earlier comment by @handwerkerd: it's because the parent commit is holding the outdated version and there were no new commits since the merge. When we merge, it will be lined up properly with the current |
I just locally ran tedana looked at the outputs for the 5 echo test data set. They are non-trivially different. Others should run and look at this on their own to confirm that I didn't just mess something up. If you're seeing this as well, my suspicion is that this specific change might be ok, but the changing scaling may be interacting with decision tree thresholding that was tuned for the older, flawed code. Another possibility is, with the recent adaptive mask changes, the voxel-wise scaling of weights for kappa & rho values wasn't done correctly. |
@handwerkerd thanks for testing the changes. Given that this fixes a bug introduced in #358, I think this may merit a separate issue about the validity of the current thresholds in the decision tree post-#358. |
@tsalo, The trouble is if, in fixing a bug, it's creating a seriously bad misclassified component, we can't just merge this. I'm not sure I have time today but I may want to go back to older versions of the code to see if the scaling was this different before adding adaptive masking. If it's this PR specifically that's causing a big scaling change, that makes me think there might be another bug we need to catch before merging. |
I would argue that the introduction of a bad misclassification is an issue that must be resolved before a release, but the scope of this PR is fixing a bug in the code, rather than an overarching problem in the decision tree. We definitely can't release 0.0.10 before the decision tree has been investigated, but I don't think that should block this.
If there are as many 3- and 4-echo voxels (together) as 5-echo voxels, and the F-statistics are roughly the same, then that seems like a reasonable scaling. To reproduce: import numpy as np
# 3 voxels for each value in adaptive_mask
adaptive_mask = np.array([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5])
# voxels with >= 3 echoes have actual values in the averaging
arr_3andup = np.array([0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5])
np.mean(arr_3andup) # 3.0
# voxels with only 5 echoes have actual values in the averaging
# other voxels are incorrectly set to zero
arr_5only = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5])
np.mean(arr_5only) # 1.0 |
I'm trying to figure out what's going on. ~23000 voxels have 5 good echoes vs ~900 voxels having only 3 or 4 good echoes. There's no way a 2X scaling can happen from missing just those 900 voxels. I've been digging into this section of code line-by-line and, as far as I can tell, this 2X scaling difference does not occur in the area where you've changed the code (i.e. through line 203). The kappa values are different, but more like 117.1 vs 117.3. |
I've been looking into this a bit and couldn't figure out where the big change in kappa & rho values came from. I reran on this PR and don't see the same badly scaled result. My best guess is I somehow ran a non-updated up version of this PR last time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks again @tsalo !
* Initial work on a class. * Clean up. * More work. * Revert mistake. * [FIX] Adds f_max to right place (#712) Moves f_max thresholding to the step where the R2/S0 maps are written out, rather than just before kappa/rho calculation. * [FIX] Calculate Kappa and Rho on full F-statistic maps (#714) * Calculate rho and kappa on full maps. * Add missing test outputs. * Revert changes to outputs. * Fill out docstrings for file-writing class. * More work. * [MAINT] Drop 3.5 support and begin 3.8 and 3.9 support (#721) * Drop 3.5 support and add 3.8/3.9 support. * Drop 3.5 tests and add 3.8/3.9 tests. * Update installation instructions. * Progress on refactor * Fix some errors * Fix style * Switch to fstrings where possible * Update tedana/io.py Co-authored-by: Taylor Salo <tsalo006@fiu.edu> * Update tedana/io.py Co-authored-by: Taylor Salo <tsalo006@fiu.edu> * Address @handwerkerd docstring review * Replace generator with io_generator Co-authored-by: Joshua Teves <jbtevespro@gmail.com> Co-authored-by: Joshua Teves <joshua.teves@nih.gov>
Closes #713, which was probably introduced in #358.
Changes proposed in this pull request: