Skip to content

ENH: Modify Directory and File traits to get along with pathlib #2959

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8124823
ENH: Modify ``Directory`` and ``File`` traits to get along with pathlib
oesteban Jul 16, 2019
7aee40d
fix(traits): update ``ImageFile`` trait to match new ``File``
oesteban Jul 16, 2019
a2c53fb
fix(traits): set ``usedefault`` metadata to ``True``
oesteban Jul 16, 2019
a8f55bb
fix(traits): ``resolve`` meta was forced to ``True`` for ``File``
oesteban Jul 16, 2019
5f99d93
fix(traits): ``resolve`` of ``ImageFiles``, ``ImageFileSPM`` adapted …
oesteban Jul 16, 2019
addadb3
fix(traits): ensuring backwards compatibility of new traits
oesteban Jul 16, 2019
72f7fed
fix(interfaces): minor amends to SPM and AFNI interfaces
oesteban Jul 16, 2019
c8457e6
maint(specs): make specs
oesteban Jul 16, 2019
281f516
fix(traits): restore old ``usedefault`` behavior of ``File``s
oesteban Jul 16, 2019
6dbd76d
fix(interfaces): revise test that should pass
oesteban Jul 16, 2019
98d8308
fix(deps): add pathlib2 to requirements.txt
oesteban Jul 16, 2019
4b6e390
fix(specs): update specs
oesteban Jul 16, 2019
1134a6b
fix(dipy): resolve issues with dipy versions
oesteban Jul 16, 2019
005f87e
fix(io): repair ``io.S3DataGrabber`` which was not expecting path-lik…
oesteban Jul 16, 2019
d0f4bf5
fix(py<3.6): workaround for ``Path.resolve(strict=value)``
oesteban Jul 16, 2019
eeb53d0
fix(pathlib2): Import pathlib2 if python < 3.
oesteban Jul 16, 2019
398697a
fix(python2): make deepcopy to work with python2
oesteban Jul 16, 2019
08ddc9f
fix(python3): roll patch back to ``DynamicTraitedSpec.__deepcopy__``
oesteban Jul 16, 2019
8069604
fix(py>2,<3.6): fixed workaround for ``Path.resolve(strict=False)``
oesteban Jul 16, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions nipype/algorithms/tests/test_rapidart.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ def test_sc_init():

def test_sc_populate_inputs():
sc = ra.StimulusCorrelation()
inputs = Bunch(
realignment_parameters=None,
intensity_values=None,
spm_mat_file=None,
concatenated_design=None)
assert set(sc.inputs.__dict__.keys()) == set(inputs.__dict__.keys())
expected = [
'concatenated_design',
'intensity_values',
'realignment_parameters',
'spm_mat_file',
]
assert sorted(sc.inputs.get().keys()) == expected


def test_sc_output_filenames():
Expand Down
31 changes: 16 additions & 15 deletions nipype/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,27 @@ def get_nipype_gitversion():
VERSION = __version__
PROVIDES = ['nipype']
REQUIRES = [
'nibabel>=%s' % NIBABEL_MIN_VERSION,
'networkx>=%s,<=%s ; python_version < "3.0"' % (NETWORKX_MIN_VERSION, NETWORKX_MAX_VERSION_27),
'click>=%s' % CLICK_MIN_VERSION,
'configparser; python_version <= "3.4"',
'funcsigs',
'future>=%s' % FUTURE_MIN_VERSION,
'futures; python_version == "2.7"',
'networkx>=%s ; python_version >= "3.0"' % NETWORKX_MIN_VERSION,
'numpy>=%s,!=%s ; python_version == "2.7"' % (NUMPY_MIN_VERSION, NUMPY_BAD_VERSION_27),
'networkx>=%s,<=%s ; python_version < "3.0"' % (NETWORKX_MIN_VERSION, NETWORKX_MAX_VERSION_27),
'neurdflib',
'nibabel>=%s' % NIBABEL_MIN_VERSION,
'numpy>=%s ; python_version > "3.0" and python_version < "3.7"' % NUMPY_MIN_VERSION,
'numpy>=%s ; python_version >= "3.7"' % NUMPY_MIN_VERSION_37,
'numpy>=%s,!=%s ; python_version == "2.7"' % (NUMPY_MIN_VERSION, NUMPY_BAD_VERSION_27),
'packaging',
'pathlib2; python_version <= "3.4"',
'prov>=%s' % PROV_VERSION,
'pydot>=%s' % PYDOT_MIN_VERSION,
'pydotplus',
'python-dateutil>=%s' % DATEUTIL_MIN_VERSION,
'scipy>=%s' % SCIPY_MIN_VERSION,
'traits>=%s,!=5.0' % TRAITS_MIN_VERSION,
'future>=%s' % FUTURE_MIN_VERSION,
'simplejson>=%s' % SIMPLEJSON_MIN_VERSION,
'prov>=%s' % PROV_VERSION,
'neurdflib',
'click>=%s' % CLICK_MIN_VERSION,
'funcsigs',
'pydotplus',
'pydot>=%s' % PYDOT_MIN_VERSION,
'packaging',
'futures; python_version == "2.7"',
'configparser; python_version <= "3.4"',
'traits>=%s,!=5.0' % TRAITS_MIN_VERSION,
]

TESTS_REQUIRES = [
Expand All @@ -170,7 +171,7 @@ def get_nipype_gitversion():
'doc': ['Sphinx>=1.4', 'numpydoc', 'matplotlib', 'pydotplus', 'pydot>=1.2.3'],
'tests': TESTS_REQUIRES,
'specs': ['yapf'],
'nipy': ['nitime', 'nilearn<0.5.0', 'dipy', 'nipy', 'matplotlib'],
'nipy': ['nitime', 'nilearn<0.5.0', 'dipy!=0.15,>=0.14', 'nipy', 'matplotlib'],
'profiler': ['psutil>=5.0'],
'duecredit': ['duecredit'],
'xvfbwrapper': ['xvfbwrapper'],
Expand Down
6 changes: 0 additions & 6 deletions nipype/interfaces/afni/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ class AFNICommandInputSpec(CommandLineInputSpec):
1, usedefault=True, nohash=True, desc='set number of threads')
outputtype = traits.Enum(
'AFNI', list(Info.ftypes.keys()), desc='AFNI output filetype')
out_file = File(
name_template="%s_afni",
desc='output image file name',
argstr='-prefix %s',
name_source=["in_file"])


class AFNICommandOutputSpec(TraitedSpec):
out_file = File(desc='output file', exists=True)
Expand Down
103 changes: 60 additions & 43 deletions nipype/interfaces/afni/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ...utils.filemanip import (load_json, save_json, split_filename,
fname_presuffix)
from ..base import (CommandLineInputSpec, CommandLine, TraitedSpec, traits,
isdefined, File, InputMultiPath, Undefined, Str,
isdefined, File, Directory, InputMultiPath, Undefined, Str,
InputMultiObject)

from .base import (AFNICommandBase, AFNICommand, AFNICommandInputSpec,
Expand Down Expand Up @@ -757,8 +757,7 @@ class BandpassInputSpec(AFNICommandInputSpec):
desc='output file from 3dBandpass',
argstr='-prefix %s',
position=1,
name_source='in_file',
genfile=True)
name_source='in_file')
lowpass = traits.Float(
desc='lowpass', argstr='%f', position=-2, mandatory=True)
highpass = traits.Float(
Expand Down Expand Up @@ -909,6 +908,11 @@ class BlurToFWHMInputSpec(AFNICommandInputSpec):
argstr='-input %s',
mandatory=True,
exists=True)
out_file = File(
name_template='%s_afni',
desc='output image file name',
argstr='-prefix %s',
name_source='in_file')
automask = traits.Bool(
desc='Create an automask from the input dataset.', argstr='-automask')
fwhm = traits.Float(
Expand Down Expand Up @@ -1042,6 +1046,11 @@ class DegreeCentralityInputSpec(CentralityInputSpec):
mandatory=True,
exists=True,
copyfile=False)
out_file = File(
name_template='%s_afni',
desc='output image file name',
argstr='-prefix %s',
name_source='in_file')
sparsity = traits.Float(
desc='only take the top percent of connections', argstr='-sparsity %f')
oned_file = Str(
Expand Down Expand Up @@ -1188,6 +1197,11 @@ class ECMInputSpec(CentralityInputSpec):
mandatory=True,
exists=True,
copyfile=False)
out_file = File(
name_template='%s_afni',
desc='output image file name',
argstr='-prefix %s',
name_source='in_file')
sparsity = traits.Float(
desc='only take the top percent of connections', argstr='-sparsity %f')
full = traits.Bool(
Expand Down Expand Up @@ -1453,6 +1467,11 @@ class LFCDInputSpec(CentralityInputSpec):
mandatory=True,
exists=True,
copyfile=False)
out_file = File(
name_template='%s_afni',
desc='output image file name',
argstr='-prefix %s',
name_source='in_file')


class LFCD(AFNICommand):
Expand Down Expand Up @@ -3072,58 +3091,56 @@ def _list_outputs(self):

class QwarpInputSpec(AFNICommandInputSpec):
in_file = File(
desc=
'Source image (opposite phase encoding direction than base image).',
desc='Source image (opposite phase encoding direction than base image).',
argstr='-source %s',
mandatory=True,
exists=True,
copyfile=False)
base_file = File(
desc=
'Base image (opposite phase encoding direction than source image).',
desc='Base image (opposite phase encoding direction than source image).',
argstr='-base %s',
mandatory=True,
exists=True,
copyfile=False)
out_file = File(
argstr='-prefix %s',
name_template='%s_QW',
name_source=['in_file'],
genfile=True,
desc='out_file ppp'
'Sets the prefix for the output datasets.'
'* The source dataset is warped to match the base'
'and gets prefix \'ppp\'. (Except if \'-plusminus\' is used.)'
'* The final interpolation to this output dataset is'
'done using the \'wsinc5\' method. See the output of'
' 3dAllineate -HELP'
'(in the "Modifying \'-final wsinc5\'" section) for'
'the lengthy technical details.'
'* The 3D warp used is saved in a dataset with'
'prefix \'ppp_WARP\' -- this dataset can be used'
'with 3dNwarpApply and 3dNwarpCat, for example.'
'* To be clear, this is the warp from source dataset'
' coordinates to base dataset coordinates, where the'
' values at each base grid point are the xyz displacments'
' needed to move that grid point\'s xyz values to the'
' corresponding xyz values in the source dataset:'
' base( (x,y,z) + WARP(x,y,z) ) matches source(x,y,z)'
' Another way to think of this warp is that it \'pulls\''
' values back from source space to base space.'
'* 3dNwarpApply would use \'ppp_WARP\' to transform datasets'
'aligned with the source dataset to be aligned with the'
'base dataset.'
'** If you do NOT want this warp saved, use the option \'-nowarp\'.'
'-->> (However, this warp is usually the most valuable possible output!)'
'* If you want to calculate and save the inverse 3D warp,'
'use the option \'-iwarp\'. This inverse warp will then be'
'saved in a dataset with prefix \'ppp_WARPINV\'.'
'* This inverse warp could be used to transform data from base'
'space to source space, if you need to do such an operation.'
'* You can easily compute the inverse later, say by a command like'
' 3dNwarpCat -prefix Z_WARPINV \'INV(Z_WARP+tlrc)\''
'or the inverse can be computed as needed in 3dNwarpApply, like'
' 3dNwarpApply -nwarp \'INV(Z_WARP+tlrc)\' -source Dataset.nii ...')
name_source='in_file',
desc="""\
out_file ppp\
Sets the prefix for the output datasets.\
* The source dataset is warped to match the base\
and gets prefix \'ppp\'. (Except if \'-plusminus\' is used.)\
* The final interpolation to this output dataset is\
done using the \'wsinc5\' method. See the output of\
3dAllineate -HELP\
(in the "Modifying \'-final wsinc5\'" section) for\
the lengthy technical details.\
* The 3D warp used is saved in a dataset with\
prefix \'ppp_WARP\' -- this dataset can be used\
with 3dNwarpApply and 3dNwarpCat, for example.\
* To be clear, this is the warp from source dataset\
coordinates to base dataset coordinates, where the\
values at each base grid point are the xyz displacments\
needed to move that grid point\'s xyz values to the\
corresponding xyz values in the source dataset:\
base( (x,y,z) + WARP(x,y,z) ) matches source(x,y,z)\
Another way to think of this warp is that it \'pulls\'\
values back from source space to base space.\
* 3dNwarpApply would use \'ppp_WARP\' to transform datasets\
aligned with the source dataset to be aligned with the\
base dataset.\
** If you do NOT want this warp saved, use the option \'-nowarp\'.\
-->> (However, this warp is usually the most valuable possible output!)\
* If you want to calculate and save the inverse 3D warp,\
use the option \'-iwarp\'. This inverse warp will then be\
saved in a dataset with prefix \'ppp_WARPINV\'.\
* This inverse warp could be used to transform data from base\
space to source space, if you need to do such an operation.\
* You can easily compute the inverse later, say by a command like\
3dNwarpCat -prefix Z_WARPINV \'INV(Z_WARP+tlrc)\'\
or the inverse can be computed as needed in 3dNwarpApply, like\
3dNwarpApply -nwarp \'INV(Z_WARP+tlrc)\' -source Dataset.nii ...""")
resample = traits.Bool(
desc='This option simply resamples the source dataset to match the'
'base dataset grid. You can use this if the two datasets'
Expand Down
5 changes: 0 additions & 5 deletions nipype/interfaces/afni/tests/test_auto_AFNICommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ def test_AFNICommand_inputs():
nohash=True,
usedefault=True,
),
out_file=dict(
argstr='-prefix %s',
name_source=['in_file'],
name_template='%s_afni',
),
outputtype=dict(),
)
inputs = AFNICommand.input_spec()
Expand Down
5 changes: 0 additions & 5 deletions nipype/interfaces/afni/tests/test_auto_AFNIPythonCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ def test_AFNIPythonCommand_inputs():
nohash=True,
usedefault=True,
),
out_file=dict(
argstr='-prefix %s',
name_source=['in_file'],
name_template='%s_afni',
),
outputtype=dict(),
)
inputs = AFNIPythonCommand.input_spec()
Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/afni/tests/test_auto_Bandpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def test_Bandpass_inputs():
orthogonalize_file=dict(argstr='-ort %s', ),
out_file=dict(
argstr='-prefix %s',
genfile=True,
name_source='in_file',
name_template='%s_bp',
position=1,
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/afni/tests/test_auto_BlurToFWHM.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_BlurToFWHM_inputs():
),
out_file=dict(
argstr='-prefix %s',
name_source=['in_file'],
name_source='in_file',
name_template='%s_afni',
),
outputtype=dict(),
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/afni/tests/test_auto_DegreeCentrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_DegreeCentrality_inputs():
oned_file=dict(argstr='-out1D %s', ),
out_file=dict(
argstr='-prefix %s',
name_source=['in_file'],
name_source='in_file',
name_template='%s_afni',
),
outputtype=dict(),
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/afni/tests/test_auto_ECM.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_ECM_inputs():
),
out_file=dict(
argstr='-prefix %s',
name_source=['in_file'],
name_source='in_file',
name_template='%s_afni',
),
outputtype=dict(),
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/afni/tests/test_auto_LFCD.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_LFCD_inputs():
),
out_file=dict(
argstr='-prefix %s',
name_source=['in_file'],
name_source='in_file',
name_template='%s_afni',
),
outputtype=dict(),
Expand Down
3 changes: 1 addition & 2 deletions nipype/interfaces/afni/tests/test_auto_Qwarp.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ def test_Qwarp_inputs():
),
out_file=dict(
argstr='-prefix %s',
genfile=True,
name_source=['in_file'],
name_source='in_file',
name_template='%s_QW',
),
out_weight_file=dict(argstr='-wtprefix %s', ),
Expand Down
5 changes: 0 additions & 5 deletions nipype/interfaces/afni/tests/test_auto_TCorrMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ def test_TCorrMap_inputs():
nohash=True,
usedefault=True,
),
out_file=dict(
argstr='-prefix %s',
name_source=['in_file'],
name_template='%s_afni',
),
outputtype=dict(),
pmean=dict(
argstr='-Pmean %s',
Expand Down
Loading