-
Notifications
You must be signed in to change notification settings - Fork 532
enh: multiple masks for compcor #1968
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 #1968 +/- ##
=========================================
+ Coverage 72.6% 72.6% +<.01%
=========================================
Files 1070 1070
Lines 54454 54530 +76
Branches 7868 7892 +24
=========================================
+ Hits 39535 39591 +56
- Misses 13686 13699 +13
- Partials 1233 1240 +7
Continue to review full report at Codecov.
|
nipype/algorithms/confounds.py
Outdated
@@ -434,7 +441,7 @@ class TCompCorInputSpec(CompCorInputSpec): | |||
|
|||
class TCompCorOutputSpec(CompCorInputSpec): | |||
# and all the fields in CompCorInputSpec | |||
high_variance_mask = File(exists=True, desc="voxels excedding the variance threshold") | |||
high_variance_mask = InputMultiPath(File(exists=True, desc="voxels excedding the variance threshold")) |
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.
should this be OutputMultiPath?
nipype/algorithms/confounds.py
Outdated
@@ -302,7 +302,7 @@ def _list_outputs(self): | |||
class CompCorInputSpec(BaseInterfaceInputSpec): | |||
realigned_file = File(exists=True, mandatory=True, | |||
desc='already realigned brain image (4D)') | |||
mask_file = File(exists=True, desc='mask file that determines ROI (3D)') | |||
mask_file = InputMultiPath(File(exists=True, desc='mask file(s) that determines ROI (3D)')) |
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.
how does this work for TCompCor
? i see that only the first one is being used.
nipype/algorithms/confounds.py
Outdated
@@ -464,7 +471,7 @@ def _run_interface(self, runtime): | |||
.format(self.inputs.realigned_file, imgseries.ndim, imgseries.shape)) | |||
|
|||
if isdefined(self.inputs.mask_file): | |||
in_mask_data = nb.load(self.inputs.mask_file, mmap=NUMPY_MMAP).get_data() | |||
in_mask_data = nb.load(self.inputs.mask_file[0], mmap=NUMPY_MMAP).get_data() |
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.
should we consider a union or intersection of masks, and a new Enum trait (for 'union', 'intersect') and xor-ed with an index trait if we want to index just one of the masks.
merge_method = traits.Enum('union', 'intersect', 'none', xor=['mask_index'], ...)
mask_index = traits.Range(0, low=0, xor=['merge_method'], ...)
none
corresponds to per mask.
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 you can make these changes, we can get them in.
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.
@satra maybe you can take a look, there is a failing test I have to figure out first
Still have to add some basic testing but LMKWYT |
nipype/algorithms/confounds.py
Outdated
# save mask | ||
mask_file = os.path.abspath('mask{}.nii'.format(i)) | ||
nb.Nifti1Image(mask_data, nb.load( | ||
self.inputs.realigned_file).affine).to_filename(mask_file) |
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.
this should also have the numpy MMAP
nipype/algorithms/confounds.py
Outdated
# save mask | ||
mask_file = os.path.abspath('mask.nii') | ||
nb.Nifti1Image(mask_data, | ||
nb.load(self.inputs.realigned_file).affine).to_filename(mask_file) |
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.
and here
nipype/algorithms/confounds.py
Outdated
usedefault=True, | ||
desc='filename to store physiological components') | ||
desc='already realigned brain image (4D)') | ||
mask_files = InputMultiPath(File(exists=True, |
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.
this should go through a deprecation cycle. so keep the old name and point to the new name.
e.g.: https://github.com/nipy/nipype/blob/master/nipype/interfaces/spm/preprocess.py#L812
allows multiple masks to be passed in - outputs are stacked in the same components file