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

[RTM] Code revision: confounds, utilities, etc. #641

Merged
merged 32 commits into from
Aug 4, 2017

Conversation

oesteban
Copy link
Member

@oesteban oesteban commented Aug 3, 2017

#225, depends on #640

@oesteban oesteban changed the title [ENH] Code revision: confounds, utilities, etc. [WIP] Code revision: confounds, utilities, etc. Aug 3, 2017
Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

Some preliminary comments. Can go through in finer detail once #640 is in.

acompcor = File(exists=True, mandatory=True, desc='input aCompCorr')
cos_basis = File(exists=True, mandatory=True, desc='input cosine basis')
motion = File(exists=True, mandatory=True, desc='input motion parameters')
aroma = File(exists=True, mandatory=True, desc='input ICA-AROMA')
Copy link
Member

Choose a reason for hiding this comment

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

These are not mandatory as presently written. I believe the idea is that the individual inputs can fail or (in the case of aroma, at least) not be run, and the interface will still work.

@@ -5,7 +5,6 @@
fMRI preprocessing workflow
=====
"""
from __future__ import absolute_import, division, print_function, unicode_literals
Copy link
Member

Choose a reason for hiding this comment

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

Is the plan to completely discontinue Py2 support? At least a couple months ago, we were accepting patches from users who needed Py2, as long as they didn't complicate the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would discontinue py2 for good at this point, simplify our lives. But you are right, we haven't talked about this. WDYT @chrisfilo @rwblair ?

mask_erode_mm = traits.Float(0.0, usedefault=True,
desc='erode input mask (kernel width in mm)')
erode_mm = traits.Float(0.0, usedefault=True,
desc='erode output mask (kernel width in mm)')
Copy link
Member

Choose a reason for hiding this comment

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

While we're making this interface, let's put in a probability threshold parameter (default 0.95).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -2,52 +2,39 @@
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
from __future__ import print_function, division, absolute_import, unicode_literals
"""
Miscelaneous utilities
Copy link
Member

Choose a reason for hiding this comment

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

Miscellaneous

... '/path/to/sub-045_ses-retest_T1w.nii.gz'], 'test')
'sub-045_ses-test_T1w_test.nii.gz'

"""
import os.path as op
from niworkflows.nipype.utils.filemanip import fname_presuffix, filename_to_list
return op.basename(fname_presuffix(filename_to_list(in_files)[0],
Copy link
Member

Choose a reason for hiding this comment

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

To get the behavior described in your docstring: suffix='_' + suffix

Or update the docstring to pass '_test'.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@oesteban oesteban changed the title [WIP] Code revision: confounds, utilities, etc. [RTM] Code revision: confounds, utilities, etc. Aug 4, 2017
Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

A few more comments.

Beyond that, looks good, assuming everyone's okay with killing Py2.

for i in range(data2d.shape[0]):
for j in range(data2d.shape[1]):
for i in list(range(data2d.shape[0])):
for j in list(range(data2d.shape[1])):
Copy link
Member

Choose a reason for hiding this comment

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

Why list? You can iterate over range.

self._results['out_avg'] = genfname(self.inputs.in_files[0],
suffix='avg')
self._results['out_avg'] = fname_presuffix(self.inputs.in_files[0],
suffix='avg', newpath=os.getcwd())
Copy link
Member

Choose a reason for hiding this comment

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

suffix='_avg', newpath=runtime.cwd

@@ -93,7 +91,8 @@ def _run_interface(self, runtime):
if sqdata.ndim == 5:
raise RuntimeError('Input image (%s) is 5D' % in_files[0])
else:
in_files = [genfname(in_files[0], suffix='squeezed')]
in_files = [fname_presuffix(in_files[0], suffix='squeezed',
newpath=os.getcwd())]
Copy link
Member

Choose a reason for hiding this comment

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

suffix='_squeezed', newpath=runtime.cwd

self._results['out_file'] = genfname(
self.inputs.in_file, suffix='antswarp')
self._results['out_file'] = fname_presuffix(
self.inputs.in_file, suffix='antswarp', newpath=os.getcwd())
Copy link
Member

Choose a reason for hiding this comment

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

etc.

erode_mm = traits.Float(0.0, usedefault=True,
desc='erode output mask (kernel width in mm)')
pthres = traits.Float(0.95, usedefault=True,
desc='threshold for the tissue probability maps')
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer this be something like probability_threshold, or prob_thresh or something a little more explicit. The main place we'll be reading it is

node = pe.Node(TPM2ROI(probability_threshold=0.95), ...)

RuntimeError: Some participants were not found: 14



Copy link
Member

Choose a reason for hiding this comment

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

Seems like more newlines than we need?

@oesteban
Copy link
Member Author

oesteban commented Aug 4, 2017

@oesteban
Copy link
Member Author

oesteban commented Aug 4, 2017

Tests are passing here: https://circleci.com/gh/poldracklab/fmriprep/1006 (the circle hook is showing a branch I created to test that it was building on rtd). Merging in...

@oesteban oesteban merged commit 422bfd5 into nipreps:master Aug 4, 2017
@oesteban oesteban deleted the enh/CodeRevision-other branch August 4, 2017 22:44
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.

None yet

2 participants