-
Notifications
You must be signed in to change notification settings - Fork 532
[ENH] CompCor enhancement #2859
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2859 +/- ##
==========================================
+ Coverage 67.46% 67.48% +0.01%
==========================================
Files 341 341
Lines 43392 43713 +321
Branches 5383 5508 +125
==========================================
+ Hits 29276 29498 +222
- Misses 13419 13499 +80
- Partials 697 716 +19
Continue to review full report at Codecov.
|
I think it's reasonable to put this here. I have a couple overall comments about the approach, though:
I would rather not overload this, as it's not an intuitive interpretation of "num_components". I would rather have a separate input like
What about num_components = traits.Either('all', traits.Int, ...) |
Thank you for the review — I’ve now updated the PR. In the update, I automatically instantiate the selection criterion equivalently to |
nipype/algorithms/confounds.py
Outdated
@@ -613,13 +663,19 @@ def _list_outputs(self): | |||
save_pre_filter = os.path.abspath('pre_filter.tsv') | |||
outputs['pre_filter_file'] = save_pre_filter | |||
|
|||
save_metadata = self.inputs.save_metadata | |||
if save_metadata: |
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.
if save_metadata: | |
if save_metadata is True: |
nipype/algorithms/confounds.py
Outdated
@@ -613,13 +663,19 @@ def _list_outputs(self): | |||
save_pre_filter = os.path.abspath('pre_filter.tsv') | |||
outputs['pre_filter_file'] = save_pre_filter | |||
|
|||
save_metadata = self.inputs.save_metadata | |||
if save_metadata: | |||
if isinstance(save_metadata, bool): |
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.
remove this line
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.
Hmm, looking at it now, I'm not sure that change would work because the conditional branch should be entered if save_metadata
is either True
or a string (the metadata file path) so as to set the output path.
if save_metadata:
if isinstance(save_metadata, bool):
save_metadata = os.path.abspath('component_metadata.tsv')
outputs['metadata_file'] = save_metadata
Of course, we could circumvent this entirely with a SimpleInterface
as per your earlier suggestion. I'm not sure if there's a good reason for not using SimpleInterface
or fname_presuffix
here (perhaps this function predates their integration into nipype
?), but I mirrored this block structure from the save_pre_filter
block above it. I could definitely try and see if I can refactor into a SimpleInterface
with fname_presuffix
if you think it would be worthwhile.
There are a couple of potential changes here that I think could be worthwhile, both in general and downstream in
|
Summary
As a step toward implementing nipreps/fmriprep#1458, this PR updates the CompCor algorithm to allow greater flexibility.
Given that I would like to incorporate features enabled by these changes into
fmriprep
, does it make sense to propose this separately as a patch inniworkflows
?List of changes proposed in this PR (pull-request)
num_components
encodes the number of components to return if it takes an integer value greater than 1.num_components
isall
, then CompCor returns all component time series.variance_threshold
, allows for automatic selection of components on the basis of their capacity to explain variance in the data.variance_threshold
is mutually exclusive withnum_components
and takes values between 0 and 1. Ifvariance_threshold
is set, CompCor returns the minimum number of components necessary to explain the indicated variance in the data, computed as the cumulative sum of (singular_value^2)/sum(singular_values^2).num_components
norvariance_threshold
is defined, then CompCor executes as thoughnum_components
were set to 6 (the previous default behaviour).Acknowledgment