Skip to content

fix: some lgtm errors #2478

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 5 commits into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions doc/users/nipypecmd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is especially useful when running Interfaces wrapping code that does not ha
command line equivalents (nipy or SPM). Being able to run Nipype interfaces opens new
possibilities such as inclusion of SPM processing steps in bash scripts.

To run Nipype Interafces you need to use the nipype_cmd tool that should already be installed.
To run Nipype Interfaces you need to use the nipype_cmd tool that should already be installed.
The tool allows you to list Interfaces available in a certain package:

.. testcode::
Expand All @@ -24,7 +24,6 @@ The tool allows you to list Interfaces available in a certain package:
ComputeMask
FitGLM
EstimateContrast
FmriRealign4d

After selecting a particular Interface you can learn what inputs it requires:

Expand Down
4 changes: 0 additions & 4 deletions doc/users/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ machinery.

.. note::

We provide backward compatibility with IPython_ versions earlier than
0.10.1 using the IPythonX plugin. This plugin will be deprecated as of
version 0.13 of Nipype.

Please read the IPython_ documentation to determine how to setup your cluster
for distributed processing. This typically involves calling ipcluster.

Expand Down
5 changes: 4 additions & 1 deletion nipype/algorithms/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ def _list_outputs(self):
return outputs


def normalize_tpms(in_files, in_mask=None, out_files=[]):
def normalize_tpms(in_files, in_mask=None, out_files=None):
"""
Returns the input tissue probability maps (tpms, aka volume fractions)
normalized to sum up 1.0 at each voxel within the mask.
Expand All @@ -1195,6 +1195,9 @@ def normalize_tpms(in_files, in_mask=None, out_files=[]):

in_files = np.atleast_1d(in_files).tolist()

if out_files is None:
out_files = []

if len(out_files) != len(in_files):
for i, finname in enumerate(in_files):
fname, fext = op.splitext(op.basename(finname))
Expand Down
1 change: 0 additions & 1 deletion nipype/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def get_nipype_gitversion():
URL = 'http://nipy.org/nipype'
DOWNLOAD_URL = 'http://github.com/nipy/nipype/archives/master'
LICENSE = 'Apache License, 2.0'
CLASSIFIERS = CLASSIFIERS
AUTHOR = 'nipype developers'
AUTHOR_EMAIL = 'neuroimaging@python.org'
PLATFORMS = 'OS Independent'
Expand Down
4 changes: 0 additions & 4 deletions nipype/interfaces/ants/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,17 +1112,13 @@ def _get_outputfilenames(self, inverse=False):
output_filename = self.inputs.output_warped_image
if isinstance(output_filename, bool):
output_filename = '%s_Warped.nii.gz' % self.inputs.output_transform_prefix
else:
output_filename = output_filename
return output_filename
inv_output_filename = None
if isdefined(self.inputs.output_inverse_warped_image) and \
self.inputs.output_inverse_warped_image:
inv_output_filename = self.inputs.output_inverse_warped_image
if isinstance(inv_output_filename, bool):
inv_output_filename = '%s_InverseWarped.nii.gz' % self.inputs.output_transform_prefix
else:
inv_output_filename = inv_output_filename
return inv_output_filename

def _format_convergence(self, ii):
Expand Down
18 changes: 3 additions & 15 deletions nipype/interfaces/ants/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _format_arg(self, opt, spec, val):
if isdefined(self.inputs.save_posteriors):
retval += ",%s" % self.inputs.output_posteriors_name_template
return retval + "]"
return super(ANTSCommand, self)._format_arg(opt, spec, val)
return super(Atropos, self)._format_arg(opt, spec, val)

def _run_interface(self, runtime, correct_return_codes=[0]):
if self.inputs.initialization == "PriorProbabilityImages":
Expand Down Expand Up @@ -633,7 +633,7 @@ def _format_arg(self, opt, spec, val):
_, _, ext = split_filename(self.inputs.segmentation_priors[0])
retval = "-p nipype_priors/BrainSegmentationPrior%02d" + ext
return retval
return super(ANTSCommand, self)._format_arg(opt, spec, val)
return super(CorticalThickness, self)._format_arg(opt, spec, val)

def _run_interface(self, runtime, correct_return_codes=[0]):
priors_directory = os.path.join(os.getcwd(), "nipype_priors")
Expand Down Expand Up @@ -693,12 +693,6 @@ def _list_outputs(self):
return outputs


class antsCorticalThickness(CorticalThickness):
DeprecationWarning(
'This class has been replaced by CorticalThickness and will be removed in version 0.13'
)


class BrainExtractionInputSpec(ANTSCommandInputSpec):
dimension = traits.Enum(
3, 2, argstr='-d %d', usedefault=True, desc='image dimension (2 or 3)')
Expand Down Expand Up @@ -917,12 +911,6 @@ def _list_outputs(self):
return outputs


class antsBrainExtraction(BrainExtraction):
DeprecationWarning(
'This class has been replaced by BrainExtraction and will be removed in version 0.13'
)


class JointFusionInputSpec(ANTSCommandInputSpec):
dimension = traits.Enum(
3,
Expand Down Expand Up @@ -1059,7 +1047,7 @@ def _format_arg(self, opt, spec, val):
assert len(val) == self.inputs.modalities * len(self.inputs.warped_label_images), \
"Number of intensity images and label maps must be the same {0}!={1}".format(
len(val), len(self.inputs.warped_label_images))
return super(ANTSCommand, self)._format_arg(opt, spec, val)
return super(JointFusion, self)._format_arg(opt, spec, val)
return retval

def _list_outputs(self):
Expand Down
87 changes: 0 additions & 87 deletions nipype/interfaces/ants/tests/test_auto_antsBrainExtraction.py

This file was deleted.

97 changes: 0 additions & 97 deletions nipype/interfaces/ants/tests/test_auto_antsCorticalThickness.py

This file was deleted.

2 changes: 2 additions & 0 deletions nipype/interfaces/base/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def _clean_container(self, objekt, undefinedval=None, skipundefined=False):
if isinstance(objekt, tuple):
out = tuple(out)
else:
out = None
if isdefined(objekt):
out = objekt
else:
Expand Down Expand Up @@ -283,6 +284,7 @@ def _get_sorteddict(self,
if isinstance(objekt, tuple):
out = tuple(out)
else:
out = None
if isdefined(objekt):
if (hash_files and isinstance(objekt, (str, bytes))
and os.path.isfile(objekt)):
Expand Down
3 changes: 2 additions & 1 deletion nipype/interfaces/cmtk/cmtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ def cmat(track_file,
gp = nx.read_gpickle(resolution_network_file)
elif ext == '.graphml':
gp = nx.read_graphml(resolution_network_file)

else:
raise TypeError("Unable to read file:", resolution_network_file)
nROIs = len(gp.nodes())

# add node information from parcellation
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/cmtk/nx.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def average_networks(in_files, ntwk_res_file, group_id):
current = ntwk.edge[edge[0]][edge[1]]
data = add_dicts_by_key(current, data)
ntwk.add_edge(edge[0], edge[1], **data)
nodes = list(nodes())
nodes = list(tmp.nodes())
for node in nodes:
data = {}
data = ntwk.nodes[node]
Expand Down
6 changes: 3 additions & 3 deletions nipype/interfaces/fsl/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@ def _list_outputs(self):
outputs['bvars'] = self._gen_mesh_names('bvars', structures)
return outputs

def _gen_fname(self, name):
def _gen_fname(self, basename):
path, outname, ext = split_filename(self.inputs.out_file)

method = 'none'
Expand All @@ -2033,9 +2033,9 @@ def _gen_fname(self, name):
thres = '%.4f' % self.inputs.method_as_numerical_threshold
method = thres.replace('.', '')

if name == 'original_segmentations':
if basename == 'original_segmentations':
return op.abspath('%s_all_%s_origsegs.nii.gz' % (outname, method))
if name == 'segmentation_file':
if basename == 'segmentation_file':
return op.abspath('%s_all_%s_firstseg.nii.gz' % (outname, method))

return None
Expand Down
6 changes: 3 additions & 3 deletions nipype/interfaces/fsl/tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,15 +615,15 @@ def test_first_genfname():
first.inputs.out_file = 'segment.nii'
first.inputs.output_type = "NIFTI_GZ"

value = first._gen_fname(name='original_segmentations')
value = first._gen_fname(basename='original_segmentations')
expected_value = os.path.abspath('segment_all_fast_origsegs.nii.gz')
assert value == expected_value
first.inputs.method = 'none'
value = first._gen_fname(name='original_segmentations')
value = first._gen_fname(basename='original_segmentations')
expected_value = os.path.abspath('segment_all_none_origsegs.nii.gz')
assert value == expected_value
first.inputs.method = 'auto'
first.inputs.list_of_specific_structures = ['L_Hipp', 'R_Hipp']
value = first._gen_fname(name='original_segmentations')
value = first._gen_fname(basename='original_segmentations')
expected_value = os.path.abspath('segment_all_none_origsegs.nii.gz')
assert value == expected_value
2 changes: 1 addition & 1 deletion nipype/interfaces/nipy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
from .model import FitGLM, EstimateContrast
from .preprocess import ComputeMask, FmriRealign4d, SpaceTimeRealigner
from .preprocess import ComputeMask, SpaceTimeRealigner
from .utils import Similarity
Loading