Skip to content

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

Merged
merged 12 commits into from
Apr 28, 2017
Merged

enh: multiple masks for compcor #1968

merged 12 commits into from
Apr 28, 2017

Conversation

mgxd
Copy link
Member

@mgxd mgxd commented Apr 24, 2017

allows multiple masks to be passed in - outputs are stacked in the same components file

@mgxd mgxd requested a review from satra April 24, 2017 16:51
@codecov-io
Copy link

codecov-io commented Apr 25, 2017

Codecov Report

Merging #1968 into master will increase coverage by <.01%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#smoketests 72.6% <77.77%> (ø) ⬆️
#unittests 70.16% <77.77%> (ø) ⬆️
Impacted Files Coverage Δ
nipype/workflows/rsfmri/fsl/resting.py 85.48% <ø> (ø) ⬆️
nipype/pipeline/plugins/slurm.py 14.66% <ø> (ø) ⬆️
nipype/algorithms/tests/test_compcor.py 100% <100%> (ø) ⬆️
nipype/algorithms/confounds.py 74.65% <71.73%> (-1.3%) ⬇️

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 ca30015...668cf8a. Read the comment docs.

@@ -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"))
Copy link
Member

Choose a reason for hiding this comment

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

should this be OutputMultiPath?

@@ -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)'))
Copy link
Member

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.

@@ -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()
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 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.

Copy link
Member

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.

Copy link
Member Author

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

@mgxd
Copy link
Member Author

mgxd commented Apr 27, 2017

Still have to add some basic testing but LMKWYT

# 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)
Copy link
Member

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

# save mask
mask_file = os.path.abspath('mask.nii')
nb.Nifti1Image(mask_data,
nb.load(self.inputs.realigned_file).affine).to_filename(mask_file)
Copy link
Member

Choose a reason for hiding this comment

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

and here

usedefault=True,
desc='filename to store physiological components')
desc='already realigned brain image (4D)')
mask_files = InputMultiPath(File(exists=True,
Copy link
Member

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

@mgxd mgxd removed the in-progress label Apr 28, 2017
@satra satra merged commit 38fa3d5 into nipy:master Apr 28, 2017
@chrisgorgo chrisgorgo mentioned this pull request Apr 30, 2017
@mgxd mgxd deleted the fix/compcor branch May 18, 2017 21:19
@mgxd mgxd removed the needs-review label May 18, 2017
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.

3 participants