From c347e822a6fc1e970dab9428f1056d4fa19bf337 Mon Sep 17 00:00:00 2001 From: miykael Date: Fri, 5 Jan 2018 22:58:30 +0100 Subject: [PATCH 01/56] STY: correcting W503 - line break before binary operator --- nipype/algorithms/tests/test_compcor.py | 4 ++-- nipype/pipeline/engine/workflows.py | 4 ++-- nipype/workflows/rsfmri/fsl/tests/test_resting.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nipype/algorithms/tests/test_compcor.py b/nipype/algorithms/tests/test_compcor.py index 9407e6ef0d..455e994f6e 100644 --- a/nipype/algorithms/tests/test_compcor.py +++ b/nipype/algorithms/tests/test_compcor.py @@ -162,8 +162,8 @@ def run_cc(self, ccinterface, expected_components, expected_header='CompCor'): num_got_timepoints = len(components_data) assert num_got_timepoints == self.fake_data.shape[3] for index, timepoint in enumerate(components_data): - assert (len(timepoint) == ccinterface.inputs.num_components - or len(timepoint) == self.fake_data.shape[3]) + assert (len(timepoint) == ccinterface.inputs.num_components or + len(timepoint) == self.fake_data.shape[3]) assert timepoint[:2] == expected_components[index] return ccresult diff --git a/nipype/pipeline/engine/workflows.py b/nipype/pipeline/engine/workflows.py index d58424fcd5..f2ad13cddf 100644 --- a/nipype/pipeline/engine/workflows.py +++ b/nipype/pipeline/engine/workflows.py @@ -209,8 +209,8 @@ def connect(self, *args, **kwargs): if not destnode._check_inputs(dest): not_found.append(['in', destnode.name, dest]) if not (hasattr(srcnode, '_interface') and - ('.io' in str(srcnode._interface.__class__) - or any(['.io' in str(val) for val in + ('.io' in str(srcnode._interface.__class__) or + any(['.io' in str(val) for val in srcnode._interface.__class__.__bases__]))): if isinstance(source, tuple): # handles the case that source is specified diff --git a/nipype/workflows/rsfmri/fsl/tests/test_resting.py b/nipype/workflows/rsfmri/fsl/tests/test_resting.py index 68e62d7ee8..c176d49ed6 100644 --- a/nipype/workflows/rsfmri/fsl/tests/test_resting.py +++ b/nipype/workflows/rsfmri/fsl/tests/test_resting.py @@ -83,8 +83,8 @@ def test_create_resting_preproc(self, mock_node, mock_realign_wf): with open(expected_file, 'r') as components_file: components_data = [line.split() for line in components_file] num_got_components = len(components_data) - assert (num_got_components == self.num_noise_components - or num_got_components == self.fake_data.shape[3]) + assert (num_got_components == self.num_noise_components or + num_got_components == self.fake_data.shape[3]) first_two = [row[:2] for row in components_data[1:]] assert first_two == [['-0.5172356654', '-0.6973053243'], ['0.2574722644', '0.1645270737'], From 862d71792137cbd0727b968cfaa960e808532488 Mon Sep 17 00:00:00 2001 From: miykael Date: Fri, 5 Jan 2018 23:07:31 +0100 Subject: [PATCH 02/56] STY: correcting W191 - indentation contains tabs --- nipype/utils/tests/test_cmd.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nipype/utils/tests/test_cmd.py b/nipype/utils/tests/test_cmd.py index 315d55441f..776c5a5c11 100644 --- a/nipype/utils/tests/test_cmd.py +++ b/nipype/utils/tests/test_cmd.py @@ -84,12 +84,12 @@ def test_list_nipy_interfacesp(self): assert stderr.getvalue() == '' assert stdout.getvalue() == \ """Available Interfaces: - ComputeMask - EstimateContrast - FitGLM - FmriRealign4d - Similarity - SpaceTimeRealigner +\tComputeMask +\tEstimateContrast +\tFitGLM +\tFmriRealign4d +\tSimilarity +\tSpaceTimeRealigner """ def test_run_4d_realign_without_arguments(self): From f9f98b211e039fd8fd52ca76ebf342b62e2071ee Mon Sep 17 00:00:00 2001 From: miykael Date: Fri, 5 Jan 2018 23:57:39 +0100 Subject: [PATCH 03/56] STY: correcting W391 - blank line at end of file --- nipype/algorithms/tests/test_confounds.py | 1 - nipype/algorithms/tests/test_modelgen.py | 1 - nipype/algorithms/tests/test_normalize_tpms.py | 1 - nipype/algorithms/tests/test_overlap.py | 1 - nipype/caching/tests/test_memory.py | 1 - nipype/interfaces/brainsuite/brainsuite.py | 1 - nipype/interfaces/fsl/fix.py | 1 - nipype/interfaces/fsl/tests/test_base.py | 1 - nipype/interfaces/fsl/tests/test_dti.py | 1 - nipype/interfaces/fsl/tests/test_maths.py | 3 --- nipype/interfaces/fsl/tests/test_model.py | 2 -- nipype/interfaces/fsl/tests/test_utils.py | 1 - nipype/interfaces/tests/test_io.py | 3 --- nipype/pipeline/engine/tests/test_join.py | 2 -- nipype/pipeline/plugins/slurm.py | 1 - nipype/pipeline/plugins/tests/test_callback.py | 1 - nipype/scripts/__init__.py | 1 - nipype/utils/draw_gantt_chart.py | 1 - nipype/utils/tests/test_cmd.py | 1 - nipype/workflows/smri/freesurfer/autorecon3.py | 1 - nipype/workflows/smri/freesurfer/recon.py | 4 ---- nipype/workflows/smri/niftyreg/groupwise.py | 1 - 22 files changed, 31 deletions(-) diff --git a/nipype/algorithms/tests/test_confounds.py b/nipype/algorithms/tests/test_confounds.py index 8c2626457e..3f5b21ed55 100644 --- a/nipype/algorithms/tests/test_confounds.py +++ b/nipype/algorithms/tests/test_confounds.py @@ -73,4 +73,3 @@ def test_outliers(): in_data[0] += 10 assert is_outlier(in_data) == 1 - diff --git a/nipype/algorithms/tests/test_modelgen.py b/nipype/algorithms/tests/test_modelgen.py index 3c9ec4096b..f3f7a37aa7 100644 --- a/nipype/algorithms/tests/test_modelgen.py +++ b/nipype/algorithms/tests/test_modelgen.py @@ -153,4 +153,3 @@ def test_modelgen_sparse(tmpdir): assert len(res.outputs.session_info[0]['regress']) == 2 npt.assert_almost_equal(res.outputs.session_info[0]['regress'][0]['val'][0], 0.016675298129743384) npt.assert_almost_equal(res.outputs.session_info[1]['regress'][1]['val'][5], 0.007671459162258378) - diff --git a/nipype/algorithms/tests/test_normalize_tpms.py b/nipype/algorithms/tests/test_normalize_tpms.py index 5d0fc5c47b..a65cc66770 100644 --- a/nipype/algorithms/tests/test_normalize_tpms.py +++ b/nipype/algorithms/tests/test_normalize_tpms.py @@ -51,4 +51,3 @@ def test_normalize_tpms(tmpdir): assert np.allclose(normdata, mapdata[i]) assert np.allclose(sumdata[sumdata > 0.0], 1.0) - diff --git a/nipype/algorithms/tests/test_overlap.py b/nipype/algorithms/tests/test_overlap.py index e0ec5bcfcb..6c2df79bdd 100644 --- a/nipype/algorithms/tests/test_overlap.py +++ b/nipype/algorithms/tests/test_overlap.py @@ -41,4 +41,3 @@ def check_close(val1, val2): check_close(res.outputs.jaccard, 0.99705) check_close(res.outputs.roi_voldiff, np.array([0.0063086, -0.0025506, 0.0])) - diff --git a/nipype/caching/tests/test_memory.py b/nipype/caching/tests/test_memory.py index 50f56d4700..a33cec9491 100644 --- a/nipype/caching/tests/test_memory.py +++ b/nipype/caching/tests/test_memory.py @@ -40,4 +40,3 @@ def test_caching(tmpdir): assert results.outputs.output1 == [1, 1] finally: config.set('execution', 'stop_on_first_rerun', old_rerun) - diff --git a/nipype/interfaces/brainsuite/brainsuite.py b/nipype/interfaces/brainsuite/brainsuite.py index 60141bcb00..75078c8a96 100644 --- a/nipype/interfaces/brainsuite/brainsuite.py +++ b/nipype/interfaces/brainsuite/brainsuite.py @@ -1621,4 +1621,3 @@ def l_outputs(self): outputs[key] = name return outputs - diff --git a/nipype/interfaces/fsl/fix.py b/nipype/interfaces/fsl/fix.py index cd4aacfedb..1840c143de 100644 --- a/nipype/interfaces/fsl/fix.py +++ b/nipype/interfaces/fsl/fix.py @@ -297,4 +297,3 @@ def _list_outputs(self): outputs = self.output_spec().get() outputs['cleaned_functional_file'] = self._get_cleaned_functional_filename(self.inputs.artifacts_list_file) return outputs - diff --git a/nipype/interfaces/fsl/tests/test_base.py b/nipype/interfaces/fsl/tests/test_base.py index 030306e929..916f8e7826 100644 --- a/nipype/interfaces/fsl/tests/test_base.py +++ b/nipype/interfaces/fsl/tests/test_base.py @@ -77,4 +77,3 @@ def test_gen_fname(args, desired_name): else: desired = os.path.join(pth, desired_name["file"]) assert fname == desired - diff --git a/nipype/interfaces/fsl/tests/test_dti.py b/nipype/interfaces/fsl/tests/test_dti.py index dab4d825ae..751340941b 100644 --- a/nipype/interfaces/fsl/tests/test_dti.py +++ b/nipype/interfaces/fsl/tests/test_dti.py @@ -399,4 +399,3 @@ def test_distancemap(create_files_in_directory): mapper.inputs.local_max_file = "max.nii" assert mapper.cmdline == \ "distancemap --out=%s --in=a.nii --localmax=max.nii" % os.path.join(newdir, "a_dstmap.nii") - diff --git a/nipype/interfaces/fsl/tests/test_maths.py b/nipype/interfaces/fsl/tests/test_maths.py index 408a74712f..4d3c6ad03d 100644 --- a/nipype/interfaces/fsl/tests/test_maths.py +++ b/nipype/interfaces/fsl/tests/test_maths.py @@ -438,6 +438,3 @@ def test_tempfilt(create_files_in_directory_plus_output_type): filt = fsl.TemporalFilter(in_file="a.nii", highpass_sigma=64) assert filt.cmdline == \ "fslmaths a.nii -bptf 64.000000 -1.000000 {}".format(os.path.join(testdir, "a_filt{}".format(out_ext))) - - - diff --git a/nipype/interfaces/fsl/tests/test_model.py b/nipype/interfaces/fsl/tests/test_model.py index b2e3f8571c..fbfd3bbb05 100644 --- a/nipype/interfaces/fsl/tests/test_model.py +++ b/nipype/interfaces/fsl/tests/test_model.py @@ -63,5 +63,3 @@ def test_MultipleRegressDesign(tmpdir): """ for ii in ["mat", "con", "fts", "grp"]: assert tmpdir.join('design.'+ii).read() == eval("design_"+ii+"_expected_content") - - diff --git a/nipype/interfaces/fsl/tests/test_utils.py b/nipype/interfaces/fsl/tests/test_utils.py index 66b91cf96f..46a6f4a2f0 100644 --- a/nipype/interfaces/fsl/tests/test_utils.py +++ b/nipype/interfaces/fsl/tests/test_utils.py @@ -302,4 +302,3 @@ def test_swapdims(create_files_in_directory_plus_output_type): # Test that we can set an output name swap.inputs.out_file = "b.nii" assert swap.cmdline == "fslswapdim a.nii x y z b.nii" - diff --git a/nipype/interfaces/tests/test_io.py b/nipype/interfaces/tests/test_io.py index ff56c9ec9d..40420c05c6 100644 --- a/nipype/interfaces/tests/test_io.py +++ b/nipype/interfaces/tests/test_io.py @@ -437,6 +437,3 @@ def test_jsonsink(tmpdir, inputs_attributes): data = simplejson.load(f) assert data == expected_data - - - diff --git a/nipype/pipeline/engine/tests/test_join.py b/nipype/pipeline/engine/tests/test_join.py index a77745eb03..33438cdacf 100644 --- a/nipype/pipeline/engine/tests/test_join.py +++ b/nipype/pipeline/engine/tests/test_join.py @@ -578,5 +578,3 @@ def nested_wf(i, name='smallwf'): # there should be six nodes in total assert len(result.nodes()) == 6, \ "The number of expanded nodes is incorrect." - - diff --git a/nipype/pipeline/plugins/slurm.py b/nipype/pipeline/plugins/slurm.py index e5b797da5d..cd397f8d3b 100644 --- a/nipype/pipeline/plugins/slurm.py +++ b/nipype/pipeline/plugins/slurm.py @@ -131,4 +131,3 @@ def _submit_batchtask(self, scriptfile, node): self._pending[taskid] = node.output_dir() logger.debug('submitted sbatch task: %d for node %s' % (taskid, node._id)) return taskid - diff --git a/nipype/pipeline/plugins/tests/test_callback.py b/nipype/pipeline/plugins/tests/test_callback.py index 7212ff7302..0c1927e619 100644 --- a/nipype/pipeline/plugins/tests/test_callback.py +++ b/nipype/pipeline/plugins/tests/test_callback.py @@ -107,4 +107,3 @@ def test_callback_multiproc_exception(tmpdir): assert n.name == 'f_node' assert so.statuses[0][1] == 'start' assert so.statuses[1][1] == 'exception' - diff --git a/nipype/scripts/__init__.py b/nipype/scripts/__init__.py index 8b13789179..e69de29bb2 100644 --- a/nipype/scripts/__init__.py +++ b/nipype/scripts/__init__.py @@ -1 +0,0 @@ - diff --git a/nipype/utils/draw_gantt_chart.py b/nipype/utils/draw_gantt_chart.py index 8731aa32eb..fc78f49ea5 100644 --- a/nipype/utils/draw_gantt_chart.py +++ b/nipype/utils/draw_gantt_chart.py @@ -545,4 +545,3 @@ def generate_gantt_chart(logfile, cores, minute_scale=10, #save file with open(logfile + '.html', 'w' if PY3 else 'wb') as html_file: html_file.write(html_string) - diff --git a/nipype/utils/tests/test_cmd.py b/nipype/utils/tests/test_cmd.py index 776c5a5c11..d68e10bfa4 100644 --- a/nipype/utils/tests/test_cmd.py +++ b/nipype/utils/tests/test_cmd.py @@ -134,4 +134,3 @@ def test_run_4d_realign_help(self): assert stderr.getvalue() == '' assert "Run FmriRealign4d" in stdout.getvalue() - diff --git a/nipype/workflows/smri/freesurfer/autorecon3.py b/nipype/workflows/smri/freesurfer/autorecon3.py index 651c417f16..25115a8ba0 100644 --- a/nipype/workflows/smri/freesurfer/autorecon3.py +++ b/nipype/workflows/smri/freesurfer/autorecon3.py @@ -954,4 +954,3 @@ def out_aseg(in_aparcaseg, in_aseg, out_file): ar3_wf.connect([(qcache_wf, outputspec, [('outputspec.' + output, output)])]) return ar3_wf, ar3_outputs - diff --git a/nipype/workflows/smri/freesurfer/recon.py b/nipype/workflows/smri/freesurfer/recon.py index 1835f3dfd4..eec6856578 100644 --- a/nipype/workflows/smri/freesurfer/recon.py +++ b/nipype/workflows/smri/freesurfer/recon.py @@ -575,7 +575,3 @@ def completemethod(datasinked_files, subject_id): (completion, postds_outputspec, [('subject_id', 'subject_id')])]) return reconall - - - - diff --git a/nipype/workflows/smri/niftyreg/groupwise.py b/nipype/workflows/smri/niftyreg/groupwise.py index d222395223..0cbd88d304 100644 --- a/nipype/workflows/smri/niftyreg/groupwise.py +++ b/nipype/workflows/smri/niftyreg/groupwise.py @@ -390,4 +390,3 @@ def create_groupwise_average(name="atlas_creation", ]) return workflow - From fba83f104a1fd9196a2a5db25b467437d0eb4ae5 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 00:27:56 +0100 Subject: [PATCH 04/56] STY: correcting F402 - import 'op' from line 52 shadowed by loop variable --- nipype/pipeline/engine/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nipype/pipeline/engine/utils.py b/nipype/pipeline/engine/utils.py index 96ba23cd3d..ddd73e1e8a 100644 --- a/nipype/pipeline/engine/utils.py +++ b/nipype/pipeline/engine/utils.py @@ -296,8 +296,8 @@ def _write_detailed_dot(graph, dotfilename): if outport not in outports: outports.append(outport) outputstr = '{OUT' - for op in sorted(outports): - outputstr += '| %s' % (replacefunk(op), op) + for ops in sorted(outports): + outputstr += '| %s' % (replacefunk(ops), ops) outputstr += '}' srcpackage = '' if hasattr(n, '_interface'): From 8b663956e8ce20e6dbc3e5182a12766604bff620 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 00:50:24 +0100 Subject: [PATCH 05/56] STY: correcting of two F811 (not all) - redefinition of unused 'fsl' / 'open' --- examples/fmri_spm_auditory.py | 1 - nipype/interfaces/fsl/tests/test_preprocess.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/fmri_spm_auditory.py b/examples/fmri_spm_auditory.py index 33c03f8bf0..caf044d47e 100755 --- a/examples/fmri_spm_auditory.py +++ b/examples/fmri_spm_auditory.py @@ -23,7 +23,6 @@ import nipype.interfaces.spm as spm # spm import nipype.interfaces.fsl as fsl # fsl import nipype.interfaces.matlab as mlab # how to run matlab -import nipype.interfaces.fsl as fsl # fsl import nipype.interfaces.utility as util # utility import nipype.pipeline.engine as pe # pypeline engine import nipype.algorithms.modelgen as model # model specification diff --git a/nipype/interfaces/fsl/tests/test_preprocess.py b/nipype/interfaces/fsl/tests/test_preprocess.py index 3d75d514a6..ece8b76c29 100644 --- a/nipype/interfaces/fsl/tests/test_preprocess.py +++ b/nipype/interfaces/fsl/tests/test_preprocess.py @@ -3,7 +3,7 @@ from builtins import str # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: -from builtins import open, open +from builtins import open import os from copy import deepcopy From 920ff31f67bbcbd7fd21f530ec6d48c93e536b30 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 01:48:03 +0100 Subject: [PATCH 06/56] STY: correction of F841 - local variable 'xyz' is assigned to but never used --- doc/sphinxext/ipython_console_highlighting.py | 1 - doc/sphinxext/numpy_ext/docscrape.py | 3 +-- examples/fmri_ants_openfmri.py | 4 ---- nipype/algorithms/metrics.py | 4 +--- nipype/algorithms/misc.py | 6 +++--- nipype/algorithms/tests/test_mesh_ops.py | 1 - nipype/interfaces/cmtk/cmtk.py | 2 -- nipype/interfaces/dipy/reconstruction.py | 2 -- nipype/interfaces/dipy/simulate.py | 2 +- nipype/interfaces/elastix/registration.py | 1 - nipype/interfaces/freesurfer/model.py | 1 - nipype/interfaces/fsl/model.py | 1 - nipype/interfaces/matlab.py | 2 +- nipype/interfaces/mrtrix/convert.py | 3 --- nipype/interfaces/mrtrix/tensors.py | 2 -- nipype/interfaces/nipy/model.py | 1 - nipype/pipeline/engine/tests/test_join.py | 2 -- nipype/pipeline/engine/utils.py | 2 +- nipype/pipeline/plugins/lsf.py | 1 - nipype/pipeline/plugins/pbs.py | 1 - nipype/sphinxext/plot_workflow.py | 2 +- nipype/tests/test_nipype.py | 2 +- nipype/utils/logger.py | 2 +- nipype/utils/tests/test_filemanip.py | 3 +-- nipype/utils/tests/test_provenance.py | 1 - nipype/workflows/dmri/camino/connectivity_mapping.py | 1 - nipype/workflows/dmri/connectivity/group_connectivity.py | 2 +- nipype/workflows/dmri/dipy/denoise.py | 1 - nipype/workflows/dmri/fsl/epi.py | 1 - nipype/workflows/dmri/fsl/utils.py | 1 - tools/checkspecs.py | 3 +-- 31 files changed, 14 insertions(+), 47 deletions(-) diff --git a/doc/sphinxext/ipython_console_highlighting.py b/doc/sphinxext/ipython_console_highlighting.py index 6720056dc8..4960f9fcc3 100644 --- a/doc/sphinxext/ipython_console_highlighting.py +++ b/doc/sphinxext/ipython_console_highlighting.py @@ -59,7 +59,6 @@ class IPythonConsoleLexer(Lexer): def get_tokens_unprocessed(self, text): pylexer = PythonLexer(**self.options) - tblexer = PythonTracebackLexer(**self.options) curcode = '' insertions = [] diff --git a/doc/sphinxext/numpy_ext/docscrape.py b/doc/sphinxext/numpy_ext/docscrape.py index a4ff432715..5f5982b863 100644 --- a/doc/sphinxext/numpy_ext/docscrape.py +++ b/doc/sphinxext/numpy_ext/docscrape.py @@ -443,7 +443,7 @@ def __init__(self, func, role='func', doc=None, config={}): argspec = inspect.formatargspec(*argspec) argspec = argspec.replace('*', '\*') signature = '%s%s' % (func_name, argspec) - except TypeError as e: + except TypeError: signature = '%s()' % func_name self['Signature'] = signature @@ -459,7 +459,6 @@ def __str__(self): out = '' func, func_name = self.get_func() - signature = self['Signature'].replace('*', '\*') roles = {'func': 'function', 'meth': 'method'} diff --git a/examples/fmri_ants_openfmri.py b/examples/fmri_ants_openfmri.py index ee6ddee3f9..c30bc0f00a 100755 --- a/examples/fmri_ants_openfmri.py +++ b/examples/fmri_ants_openfmri.py @@ -203,8 +203,6 @@ def create_reg_workflow(name='registration'): Concatenate the affine and ants transforms into a list """ - pickfirst = lambda x: x[0] - merge = pe.Node(niu.Merge(2), iterfield=['in2'], name='mergexfm') register.connect(convert2itk, 'itk_transform', merge, 'in2') register.connect(reg, 'composite_transform', merge, 'in1') @@ -414,8 +412,6 @@ def create_fs_reg_workflow(name='registration'): Concatenate the affine and ants transforms into a list """ - pickfirst = lambda x: x[0] - merge = Node(Merge(2), iterfield=['in2'], name='mergexfm') register.connect(convert2itk, 'itk_transform', merge, 'in2') register.connect(reg, 'composite_transform', merge, 'in1') diff --git a/nipype/algorithms/metrics.py b/nipype/algorithms/metrics.py index 23963de679..76f37a84f7 100644 --- a/nipype/algorithms/metrics.py +++ b/nipype/algorithms/metrics.py @@ -298,8 +298,6 @@ def _run_interface(self, runtime): data1 = data1.astype(np.min_scalar_type(max1)) data2 = nii2.get_data().astype(np.min_scalar_type(max1)) data2[np.logical_or(data1 < 0, np.isnan(data1))] = 0 - max2 = data2.max() - maxlabel = max(max1, max2) if isdefined(self.inputs.mask_volume): maskdata = nb.load(self.inputs.mask_volume).get_data() @@ -630,7 +628,7 @@ class Similarity(BaseInterface): def __init__(self, **inputs): try: package_check('nipy') - except Exception as e: + except Exception: self._have_nipy = False super(Similarity, self).__init__(**inputs) diff --git a/nipype/algorithms/misc.py b/nipype/algorithms/misc.py index a16507bf36..c6b91b1a7a 100644 --- a/nipype/algorithms/misc.py +++ b/nipype/algorithms/misc.py @@ -410,10 +410,10 @@ def merge_csvs(in_list): for idx, in_file in enumerate(in_list): try: in_array = np.loadtxt(in_file, delimiter=',') - except ValueError as ex: + except ValueError: try: in_array = np.loadtxt(in_file, delimiter=',', skiprows=1) - except ValueError as ex: + except ValueError: with open(in_file, 'r') as first: header_line = first.readline() @@ -424,7 +424,7 @@ def merge_csvs(in_list): in_file, delimiter=',', skiprows=1, usecols=list(range(1, n_cols)) ) - except ValueError as ex: + except ValueError: in_array = np.loadtxt( in_file, delimiter=',', skiprows=1, usecols=list(range(1, n_cols - 1))) if idx == 0: diff --git a/nipype/algorithms/tests/test_mesh_ops.py b/nipype/algorithms/tests/test_mesh_ops.py index d5fbc56825..53eec75b69 100644 --- a/nipype/algorithms/tests/test_mesh_ops.py +++ b/nipype/algorithms/tests/test_mesh_ops.py @@ -32,7 +32,6 @@ def test_ident_distances(tmpdir): @pytest.mark.skipif(VTKInfo.no_tvtk(), reason="tvtk is not installed") def test_trans_distances(tmpdir): - tempdir = tmpdir.strpath from ...interfaces.vtkbase import tvtk in_surf = example_data('surf01.vtk') diff --git a/nipype/interfaces/cmtk/cmtk.py b/nipype/interfaces/cmtk/cmtk.py index 2f29bbb2e2..2da8a3a003 100644 --- a/nipype/interfaces/cmtk/cmtk.py +++ b/nipype/interfaces/cmtk/cmtk.py @@ -146,7 +146,6 @@ def create_endpoints_array(fib, voxelSize): n = len(fib) endpoints = np.zeros((n, 2, 3)) endpointsmm = np.zeros((n, 2, 3)) - pc = -1 # Computation for each fiber for i, fi in enumerate(fib): @@ -756,7 +755,6 @@ def create_nodes(roi_file, resolution_network_file, out_filename): gp = nx.read_graphml(resolution_network_file) roi_image = nb.load(roi_file, mmap=NUMPY_MMAP) roiData = roi_image.get_data() - nROIs = len(gp.nodes()) for u, d in gp.nodes(data=True): G.add_node(int(u), **d) xyz = tuple(np.mean(np.where(np.flipud(roiData) == int(d["dn_correspondence_id"])), axis=1)) diff --git a/nipype/interfaces/dipy/reconstruction.py b/nipype/interfaces/dipy/reconstruction.py index d10e51dede..763de075b6 100644 --- a/nipype/interfaces/dipy/reconstruction.py +++ b/nipype/interfaces/dipy/reconstruction.py @@ -324,7 +324,6 @@ def _run_interface(self, runtime): img = nb.load(self.inputs.in_file) imref = nb.four_to_three(img)[0] - affine = img.affine if isdefined(self.inputs.in_mask): msk = nb.load(self.inputs.in_mask).get_data() @@ -332,7 +331,6 @@ def _run_interface(self, runtime): msk = np.ones(imref.shape) data = img.get_data().astype(np.float32) - hdr = imref.header.copy() gtab = self._get_gradient_table() resp_file = np.loadtxt(self.inputs.response) diff --git a/nipype/interfaces/dipy/simulate.py b/nipype/interfaces/dipy/simulate.py index f008948c97..a2fe7c688b 100644 --- a/nipype/interfaces/dipy/simulate.py +++ b/nipype/interfaces/dipy/simulate.py @@ -287,7 +287,7 @@ def _compute_voxel(args): signal, _ = multi_tensor( gtab, args['mevals'], S0=args['S0'], angles=args['sticks'], fractions=ffs, snr=snr) - except Exception as e: + except Exception: pass return signal.tolist() diff --git a/nipype/interfaces/elastix/registration.py b/nipype/interfaces/elastix/registration.py index 5038447465..aa02b392a7 100644 --- a/nipype/interfaces/elastix/registration.py +++ b/nipype/interfaces/elastix/registration.py @@ -70,7 +70,6 @@ def _list_outputs(self): out_dir = op.abspath(self.inputs.output_path) - opts = ['WriteResultImage', 'ResultImageFormat'] regex = re.compile(r'^\((\w+)\s(.+)\)$') outputs['transform'] = [] diff --git a/nipype/interfaces/freesurfer/model.py b/nipype/interfaces/freesurfer/model.py index e2eba23196..71de48d786 100644 --- a/nipype/interfaces/freesurfer/model.py +++ b/nipype/interfaces/freesurfer/model.py @@ -1311,7 +1311,6 @@ def _gen_filename(self, name): avg_directory = os.path.join(self.inputs.subjects_dir, avg_subject) if not os.path.isdir(avg_directory): fs_home = os.path.abspath(os.environ.get('FREESURFER_HOME')) - avg_home = os.path.join(fs_home, 'subjects', 'fsaverage') return avg_subject elif name == 'out_file': return self._list_outputs()[name] diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py index f130c01679..53f745082e 100644 --- a/nipype/interfaces/fsl/model.py +++ b/nipype/interfaces/fsl/model.py @@ -766,7 +766,6 @@ def _list_outputs(self): varcopes = [] zstats = [] tstats = [] - neffs = [] for i in range(numtcons): copes.append(self._gen_fname( 'cope%d.nii' % (base_contrast + i), cwd=pth)) diff --git a/nipype/interfaces/matlab.py b/nipype/interfaces/matlab.py index 0d8aa29e16..f7d27cf455 100644 --- a/nipype/interfaces/matlab.py +++ b/nipype/interfaces/matlab.py @@ -25,7 +25,7 @@ def get_matlab_command(): resource_monitor=False, terminal_output='allatonce').run() matlab_path = res.runtime.stdout.strip() - except Exception as e: + except Exception: return None return matlab_cmd diff --git a/nipype/interfaces/mrtrix/convert.py b/nipype/interfaces/mrtrix/convert.py index eb34de974e..bbfca852f2 100644 --- a/nipype/interfaces/mrtrix/convert.py +++ b/nipype/interfaces/mrtrix/convert.py @@ -86,8 +86,6 @@ def read_mrtrix_streamlines(in_file, header, as_generator=True): bytesize = pt_cols * 4 def points_per_track(offset): - n_streams = 0 - n_points = 0 track_points = [] iflogger.info('Identifying the number of points per tract...') all_str = fileobj.read() @@ -95,7 +93,6 @@ def points_per_track(offset): pts = np.ndarray(shape=(num_triplets, pt_cols), dtype='f4', buffer=all_str) nonfinite_list = np.where(np.isfinite(pts[:, 2]) == False) nonfinite_list = list(nonfinite_list[0])[0:-1] # Converts numpy array to list, removes the last value - nonfinite_list_bytes = [offset + x * bytesize for x in nonfinite_list] for idx, value in enumerate(nonfinite_list): if idx == 0: track_points.append(nonfinite_list[idx]) diff --git a/nipype/interfaces/mrtrix/tensors.py b/nipype/interfaces/mrtrix/tensors.py index 025d45b2e5..0d493e982d 100644 --- a/nipype/interfaces/mrtrix/tensors.py +++ b/nipype/interfaces/mrtrix/tensors.py @@ -236,9 +236,7 @@ def _gen_outfilename(self): def concat_files(bvec_file, bval_file, invert_x, invert_y, invert_z): bvecs = np.loadtxt(bvec_file) bvals = np.loadtxt(bval_file) - flip = False if np.shape(bvecs)[0] > np.shape(bvecs)[1]: - flip = True bvecs = np.transpose(bvecs) if invert_x: bvecs[0, :] = -bvecs[0, :] diff --git a/nipype/interfaces/nipy/model.py b/nipype/interfaces/nipy/model.py index 58c07b5b95..ca8669faae 100644 --- a/nipype/interfaces/nipy/model.py +++ b/nipype/interfaces/nipy/model.py @@ -285,7 +285,6 @@ def _run_interface(self, runtime): self._z_maps = [] for contrast_def in self.inputs.contrasts: name = contrast_def[0] - _ = contrast_def[1] contrast = np.zeros(len(reg_names)) for i, reg_name in enumerate(reg_names): diff --git a/nipype/pipeline/engine/tests/test_join.py b/nipype/pipeline/engine/tests/test_join.py index 33438cdacf..0dce4307e7 100644 --- a/nipype/pipeline/engine/tests/test_join.py +++ b/nipype/pipeline/engine/tests/test_join.py @@ -198,8 +198,6 @@ def test_node_joinsource(tmpdir): """Test setting the joinsource to a Node.""" tmpdir.chdir() - # Make the workflow. - wf = pe.Workflow(name='test') # the iterated input node inputspec = pe.Node(IdentityInterface(fields=['n']), name='inputspec') inputspec.iterables = [('n', [1, 2])] diff --git a/nipype/pipeline/engine/utils.py b/nipype/pipeline/engine/utils.py index ddd73e1e8a..62fb2a8d73 100644 --- a/nipype/pipeline/engine/utils.py +++ b/nipype/pipeline/engine/utils.py @@ -90,7 +90,7 @@ def _write_inputs(node): if type(val) == str: try: func = create_function_from_source(val) - except RuntimeError as e: + except RuntimeError: lines.append("%s.inputs.%s = '%s'" % (nodename, key, val)) else: funcname = [name for name in func.__globals__ diff --git a/nipype/pipeline/plugins/lsf.py b/nipype/pipeline/plugins/lsf.py index 5ee0483221..dfaacb42d8 100644 --- a/nipype/pipeline/plugins/lsf.py +++ b/nipype/pipeline/plugins/lsf.py @@ -65,7 +65,6 @@ def _submit_batchtask(self, scriptfile, node): cmd = CommandLine('bsub', environ=dict(os.environ), resource_monitor=False, terminal_output='allatonce') - path = os.path.dirname(scriptfile) bsubargs = '' if self._bsub_args: bsubargs = self._bsub_args diff --git a/nipype/pipeline/plugins/pbs.py b/nipype/pipeline/plugins/pbs.py index 6154abad74..fecfba37be 100644 --- a/nipype/pipeline/plugins/pbs.py +++ b/nipype/pipeline/plugins/pbs.py @@ -52,7 +52,6 @@ def _is_pending(self, taskid): terminal_output='allatonce', resource_monitor=False, ignore_exception=True).run() - stderr = result.runtime.stderr errmsg = 'Unknown Job Id' # %s' % taskid success = 'Job has finished' if success in e: # Fix for my PBS diff --git a/nipype/sphinxext/plot_workflow.py b/nipype/sphinxext/plot_workflow.py index 8876a6878d..46ccad7a01 100644 --- a/nipype/sphinxext/plot_workflow.py +++ b/nipype/sphinxext/plot_workflow.py @@ -521,7 +521,7 @@ def render_figures(code, code_path, output_dir, output_base, context, graph2use=graph2use, simple_form=simple_form) shutil.move(src, img_path) - except Exception as err: + except Exception: raise GraphError(traceback.format_exc()) img.formats.append(fmt) diff --git a/nipype/tests/test_nipype.py b/nipype/tests/test_nipype.py index 05aa1abf86..a81910b4d2 100644 --- a/nipype/tests/test_nipype.py +++ b/nipype/tests/test_nipype.py @@ -4,7 +4,7 @@ def test_nipype_info(): exception_not_raised = True try: get_info() - except Exception as e: + except Exception: exception_not_raised = False assert exception_not_raised diff --git a/nipype/utils/logger.py b/nipype/utils/logger.py index 4604cc4145..259eb4f8aa 100644 --- a/nipype/utils/logger.py +++ b/nipype/utils/logger.py @@ -128,7 +128,7 @@ def logdebug_dict_differences(self, dold, dnew, prefix=""): # tuples, we might need to cast them into the same type # as the last resort. And lets try to be more generic same = old.__class__(new) == old - except Exception as e: + except Exception: same = False if not same: msgs += ["%s: %r != %r" diff --git a/nipype/utils/tests/test_filemanip.py b/nipype/utils/tests/test_filemanip.py index d50bef355a..029bfa7320 100644 --- a/nipype/utils/tests/test_filemanip.py +++ b/nipype/utils/tests/test_filemanip.py @@ -165,7 +165,6 @@ def test_recopy(_temp_analyze_files): orig_img, orig_hdr = _temp_analyze_files pth, fname = os.path.split(orig_img) img_link = os.path.join(pth, 'imglink.img') - hdr_link = os.path.join(pth, 'imglink.hdr') new_img = os.path.join(pth, 'newfile.img') new_hdr = os.path.join(pth, 'newfile.hdr') copyfile(orig_img, img_link) @@ -299,7 +298,7 @@ def touch(fname): os.unlink(dependencies[0]) try: check_depends(targets, dependencies) - except OSError as e: + except OSError: pass else: assert False, "Should raise OSError on missing dependency" diff --git a/nipype/utils/tests/test_provenance.py b/nipype/utils/tests/test_provenance.py index ce35a95aac..78ef23f77f 100644 --- a/nipype/utils/tests/test_provenance.py +++ b/nipype/utils/tests/test_provenance.py @@ -17,7 +17,6 @@ def test_provenance(): results = CommandLine('echo hello').run() ps.add_results(results) provn = ps.g.get_provn() - prov_json = ps.g.serialize(format='json') assert 'echo hello' in provn def test_provenance_exists(tmpdir): diff --git a/nipype/workflows/dmri/camino/connectivity_mapping.py b/nipype/workflows/dmri/camino/connectivity_mapping.py index d0d2a1c820..17b9f1d6bc 100644 --- a/nipype/workflows/dmri/camino/connectivity_mapping.py +++ b/nipype/workflows/dmri/camino/connectivity_mapping.py @@ -248,7 +248,6 @@ def create_connectivity_pipeline(name="connectivity"): giftiLabels = pe.Node(interface=util.Merge(2), name="GiftiLabels") niftiVolumes = pe.Node(interface=util.Merge(3), name="NiftiVolumes") fiberDataArrays = pe.Node(interface=util.Merge(4), name="FiberDataArrays") - gpickledNetworks = pe.Node(interface=util.Merge(1), name="NetworkFiles") """ Since we have now created all our nodes, we can define our workflow and start making connections. diff --git a/nipype/workflows/dmri/connectivity/group_connectivity.py b/nipype/workflows/dmri/connectivity/group_connectivity.py index 9efd45bf50..3ecef6c0bc 100644 --- a/nipype/workflows/dmri/connectivity/group_connectivity.py +++ b/nipype/workflows/dmri/connectivity/group_connectivity.py @@ -71,7 +71,7 @@ def concatcsv(in_files): first.close() for in_file in in_files: file_to_read = open(in_file, 'r') - scrap_first_line = file_to_read.readline() + file_to_read.readline() # scrap first line for line in file_to_read: out_file.write(line) return out_name diff --git a/nipype/workflows/dmri/dipy/denoise.py b/nipype/workflows/dmri/dipy/denoise.py index fb0cbc7a8c..a3c83521d4 100644 --- a/nipype/workflows/dmri/dipy/denoise.py +++ b/nipype/workflows/dmri/dipy/denoise.py @@ -113,7 +113,6 @@ def bg_mask(in_file, in_mask, out_file=None): hdr = im.header.copy() hdr.set_data_dtype(np.uint8) hdr.set_xyzt_units('mm') - imdata = im.get_data() msk = nb.load(in_mask, mmap=NUMPY_MMAP).get_data() msk = 1 - binary_dilation(msk, structure=np.ones((20, 20, 20))) nb.Nifti1Image(msk.astype(np.uint8), im.affine, hdr).to_filename(out_file) diff --git a/nipype/workflows/dmri/fsl/epi.py b/nipype/workflows/dmri/fsl/epi.py index 44b0bd9402..5c1be569f8 100644 --- a/nipype/workflows/dmri/fsl/epi.py +++ b/nipype/workflows/dmri/fsl/epi.py @@ -693,7 +693,6 @@ def _cat_logs(in_files): if fext == '.gz': name, _ = os.path.splitext(name) out_file = os.path.abspath('./%s_ecclog.log' % name) - out_str = '' with open(out_file, 'wb') as totallog: for i, fname in enumerate(in_files): totallog.write('\n\npreprocessing %d\n' % i) diff --git a/nipype/workflows/dmri/fsl/utils.py b/nipype/workflows/dmri/fsl/utils.py index d2ea118a9a..90b4ece048 100644 --- a/nipype/workflows/dmri/fsl/utils.py +++ b/nipype/workflows/dmri/fsl/utils.py @@ -370,7 +370,6 @@ def recompose_xfm(in_bval, in_xfms): import os.path as op bvals = np.loadtxt(in_bval) - out_matrix = np.array([np.eye(4)] * len(bvals)) xfms = iter([np.loadtxt(xfm) for xfm in in_xfms]) out_files = [] diff --git a/tools/checkspecs.py b/tools/checkspecs.py index a30c5d0bbb..95c748e52a 100644 --- a/tools/checkspecs.py +++ b/tools/checkspecs.py @@ -190,7 +190,6 @@ def test_specs(self, uri): # Make a shorter version of the uri that omits the package name for # titles - uri_short = re.sub(r'^%s\.' % self.package_name, '', uri) allowed_keys = ['desc', 'genfile', 'xor', 'requires', 'desc', 'nohash', 'argstr', 'position', 'mandatory', 'copyfile', 'usedefault', 'sep', 'hash_files', @@ -206,7 +205,7 @@ def test_specs(self, uri): with warnings.catch_warnings(): warnings.simplefilter("ignore") classinst = sys.modules[uri].__dict__[c] - except Exception as inst: + except Exception: continue if not issubclass(classinst, BaseInterface): From 9adf3109841d89bf0f4417497b01fdf33abcd2ca Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 01:58:24 +0100 Subject: [PATCH 07/56] STY: correction of F999 - xyz be undefined, or defined from star imports: interfaces.freesurfer --- nipype/testing/decorators.py | 2 +- nipype/workflows/smri/freesurfer/ba_maps.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nipype/testing/decorators.py b/nipype/testing/decorators.py index 35de0cbf00..eea15536f7 100644 --- a/nipype/testing/decorators.py +++ b/nipype/testing/decorators.py @@ -5,7 +5,7 @@ Extend numpy's decorators to use nipype's gui and data labels. """ -from numpy.testing.decorators import * +from numpy.testing.decorators import knownfailureif, skipif from nibabel.data import DataError diff --git a/nipype/workflows/smri/freesurfer/ba_maps.py b/nipype/workflows/smri/freesurfer/ba_maps.py index 05f1ec8efe..ef211f49b5 100644 --- a/nipype/workflows/smri/freesurfer/ba_maps.py +++ b/nipype/workflows/smri/freesurfer/ba_maps.py @@ -3,7 +3,7 @@ import os from ....interfaces.utility import Function, IdentityInterface from ....pipeline import engine as pe # pypeline engine -from ....interfaces.freesurfer import * +from ....interfaces.freesurfer import Label2Label, Label2Annot, ParcellationStats from ....interfaces.io import DataGrabber from ....interfaces.utility import Merge From 67b2a0778ef26d2b4d7ba043a187117eea09c9f5 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:06:47 +0100 Subject: [PATCH 08/56] STY: correction of E129 - visually indented line with same indent as next logical line --- nipype/interfaces/spm/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/spm/model.py b/nipype/interfaces/spm/model.py index 8ddc06a9b0..a62d0f8ef8 100644 --- a/nipype/interfaces/spm/model.py +++ b/nipype/interfaces/spm/model.py @@ -259,7 +259,7 @@ def _list_outputs(self): betas = [vbeta.fname[0] for vbeta in spm['SPM'][0, 0].Vbeta[0]] if ('Bayesian' in self.inputs.estimation_method.keys() or - 'Bayesian2' in self.inputs.estimation_method.keys()): + 'Bayesian2' in self.inputs.estimation_method.keys()): outputs['labels'] = os.path.join(pth, 'labels.{}'.format(outtype)) outputs['SDerror'] = glob(os.path.join(pth, 'Sess*_SDerror*')) From ea91c746a36285fcf362e6f99004b25d16424ee2 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:12:19 +0100 Subject: [PATCH 09/56] STY: correction of E266 - too many leading '#' for block comment --- nipype/workflows/smri/freesurfer/autorecon2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/workflows/smri/freesurfer/autorecon2.py b/nipype/workflows/smri/freesurfer/autorecon2.py index 4ef83a835e..8f8ba879f8 100644 --- a/nipype/workflows/smri/freesurfer/autorecon2.py +++ b/nipype/workflows/smri/freesurfer/autorecon2.py @@ -516,7 +516,7 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False, ('brain', 'in_brain')])]) - ## TODO: halt workflow for bad euler number + # TODO: halt workflow for bad euler number euler_number = pe.Node(EulerNumber(), name="Euler_Number") hemi_wf.connect([(fix_topology, euler_number, [('out_file', 'in_file')]), From 149322e6066750a92114e7c4114e6bda19ebbe09 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:13:18 +0100 Subject: [PATCH 10/56] STY: correction of E271 - multiple spaces after keyword --- nipype/pipeline/plugins/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/pipeline/plugins/__init__.py b/nipype/pipeline/plugins/__init__.py index 34d3abdebc..bbe2f3b558 100644 --- a/nipype/pipeline/plugins/__init__.py +++ b/nipype/pipeline/plugins/__init__.py @@ -20,4 +20,4 @@ from .slurm import SLURMPlugin from .slurmgraph import SLURMGraphPlugin -from . import semaphore_singleton +from . import semaphore_singleton From 4123f96e5283edb73620b8a09f5aaccac2192fe4 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:14:38 +0100 Subject: [PATCH 11/56] STY: correction of E714 - test for object identity should be 'is not' --- nipype/interfaces/bids_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/bids_utils.py b/nipype/interfaces/bids_utils.py index 0259a80352..ba6ca3e2c8 100644 --- a/nipype/interfaces/bids_utils.py +++ b/nipype/interfaces/bids_utils.py @@ -98,7 +98,7 @@ def __init__(self, infields=None, **kwargs): "anat": {"modality": "anat"}} # If infields is empty, use all BIDS entities - if not infields is None and have_pybids: + if infields is not None and have_pybids: bids_config = join(dirname(gb.__file__), 'config', 'bids.json') bids_config = json.load(open(bids_config, 'r')) infields = [i['name'] for i in bids_config['entities']] From 2bd5af0d0fbc3af2dbcc866495f0b4941bf8d67e Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:16:46 +0100 Subject: [PATCH 12/56] STY: correction of E125 - continuation line with same indent as next logical line --- nipype/interfaces/spm/preprocess.py | 2 +- nipype/pipeline/engine/nodes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/spm/preprocess.py b/nipype/interfaces/spm/preprocess.py index 0eebf3c6b8..0862e22b7c 100644 --- a/nipype/interfaces/spm/preprocess.py +++ b/nipype/interfaces/spm/preprocess.py @@ -259,7 +259,7 @@ def _list_outputs(self): if resliced_all: outputs['realigned_files'] = [] for idx, imgf in enumerate( - filename_to_list(self.inputs.in_files)): + filename_to_list(self.inputs.in_files)): realigned_run = [] if isinstance(imgf, list): for i, inner_imgf in enumerate(filename_to_list(imgf)): diff --git a/nipype/pipeline/engine/nodes.py b/nipype/pipeline/engine/nodes.py index 5b972a7692..9b101fa61a 100644 --- a/nipype/pipeline/engine/nodes.py +++ b/nipype/pipeline/engine/nodes.py @@ -222,7 +222,7 @@ def n_procs(self): if self._n_procs is not None: return self._n_procs elif hasattr(self._interface.inputs, 'num_threads') and isdefined( - self._interface.inputs.num_threads): + self._interface.inputs.num_threads): return self._interface.inputs.num_threads else: return 1 From 52b7f7f72fadfea46ab2d1b56ad8f5ce2782851f Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:17:59 +0100 Subject: [PATCH 13/56] STY: correction of E222 - multiple spaces after operator --- nipype/interfaces/spm/model.py | 2 +- nipype/workflows/smri/freesurfer/autorecon1.py | 2 +- nipype/workflows/smri/freesurfer/autorecon2.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nipype/interfaces/spm/model.py b/nipype/interfaces/spm/model.py index a62d0f8ef8..4ab96a4693 100644 --- a/nipype/interfaces/spm/model.py +++ b/nipype/interfaces/spm/model.py @@ -273,7 +273,7 @@ def _list_outputs(self): if 'Classical' in self.inputs.estimation_method.keys(): outputs['residual_image'] = os.path.join(pth, 'ResMS.{}'.format(outtype)) - outputs['RPVimage'] = os.path.join(pth, + outputs['RPVimage'] = os.path.join(pth, 'RPV.{}'.format(outtype)) if self.inputs.write_residuals: outputs['residual_images'] = glob(os.path.join(pth, 'Res_*')) diff --git a/nipype/workflows/smri/freesurfer/autorecon1.py b/nipype/workflows/smri/freesurfer/autorecon1.py index 6ced37b1ee..62bd4437df 100644 --- a/nipype/workflows/smri/freesurfer/autorecon1.py +++ b/nipype/workflows/smri/freesurfer/autorecon1.py @@ -244,7 +244,7 @@ def createTemplate(in_files, out_file): if stop: bias_correction.inputs.stop = stop if shrink: - bias_correction.inputs.shrink = shrink + bias_correction.inputs.shrink = shrink bias_correction.inputs.no_rescale = True bias_correction.inputs.out_file = 'orig_nu.mgz' diff --git a/nipype/workflows/smri/freesurfer/autorecon2.py b/nipype/workflows/smri/freesurfer/autorecon2.py index 8f8ba879f8..acd6c6d97f 100644 --- a/nipype/workflows/smri/freesurfer/autorecon2.py +++ b/nipype/workflows/smri/freesurfer/autorecon2.py @@ -69,7 +69,7 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False, if stop: intensity_correction.inputs.stop = stop if shrink: - intensity_correction.inputs.shrink = shrink + intensity_correction.inputs.shrink = shrink intensity_correction.inputs.distance = distance add_to_header_nu = pe.Node(AddXFormToHeader(), name="Add_XForm_to_NU") From 0a754e0725fc31ac54492f2d54bf96211ffab13d Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:19:49 +0100 Subject: [PATCH 14/56] STY: correction of E228 - missing whitespace around modulo operator --- nipype/interfaces/afni/utils.py | 4 ++-- nipype/pipeline/engine/tests/test_join.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index 3e03adda92..922e6fd05c 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -407,7 +407,7 @@ class Bucket(AFNICommand): def _format_arg(self, name, spec, value): if name == 'in_file': - return spec.argstr%(' '.join([i[0]+"'"+i[1]+"'" for i in value])) + return spec.argstr % (' '.join([i[0] + "'" + i[1] + "'" for i in value])) return super(Bucket, self)._format_arg(name, spec, value) class CalcInputSpec(AFNICommandInputSpec): @@ -639,7 +639,7 @@ class CatMatvec(AFNICommand): def _format_arg(self, name, spec, value): if name == 'in_file': - return spec.argstr%(' '.join([i[0]+' -'+i[1] for i in value])) + return spec.argstr % (' '.join([i[0] + ' -' + i[1] for i in value])) return super(CatMatvec, self)._format_arg(name, spec, value) diff --git a/nipype/pipeline/engine/tests/test_join.py b/nipype/pipeline/engine/tests/test_join.py index 0dce4307e7..8b8608b248 100644 --- a/nipype/pipeline/engine/tests/test_join.py +++ b/nipype/pipeline/engine/tests/test_join.py @@ -560,7 +560,7 @@ def nested_wf(i, name='smallwf'): joinfield='n', name='join') #define and connect nested workflow - wf = pe.Workflow(name='wf_%d'%i[0]) + wf = pe.Workflow(name='wf_%d' % i[0]) wf.connect(inputspec, 'n', pre_join, 'input1') wf.connect(pre_join, 'output1', join, 'n') return wf From 41cf6ae6dc366bdb293f57c258b9473c22d3a2b4 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:21:41 +0100 Subject: [PATCH 15/56] STY: correction of E713 - test for membership should be 'not in' --- nipype/interfaces/dcm2nii.py | 2 +- nipype/interfaces/fsl/model.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 22e9375609..88ed4b1f52 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -171,7 +171,7 @@ def _parse_stdout(self, stdout): out_file = val if out_file: - if not out_file in files: + if out_file not in files: files.append(out_file) last_added_file = out_file continue diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py index 53f745082e..9cbee3fd3d 100644 --- a/nipype/interfaces/fsl/model.py +++ b/nipype/interfaces/fsl/model.py @@ -200,9 +200,9 @@ def _create_ev_files( ev_parameters['ev_num'] = num_evs[0] ev_parameters['ev_name'] = name ev_parameters['tempfilt_yn'] = do_tempfilter - if not 'basisorth' in ev_parameters: + if 'basisorth' not in ev_parameters: ev_parameters['basisorth'] = 1 - if not 'basisfnum' in ev_parameters: + if 'basisfnum' not in ev_parameters: ev_parameters['basisfnum'] = 1 try: ev_parameters['fsldir'] = os.environ['FSLDIR'] From 2a7350749d0574884190b17aaa599ea4dca862a2 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:23:54 +0100 Subject: [PATCH 16/56] STY: correction of E202 - whitespace before ')' --- nipype/interfaces/ants/tests/test_resampling.py | 2 +- nipype/interfaces/fsl/aroma.py | 2 +- nipype/workflows/smri/freesurfer/autorecon3.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nipype/interfaces/ants/tests/test_resampling.py b/nipype/interfaces/ants/tests/test_resampling.py index 509ebfe844..a34f138ee5 100644 --- a/nipype/interfaces/ants/tests/test_resampling.py +++ b/nipype/interfaces/ants/tests/test_resampling.py @@ -9,7 +9,7 @@ @pytest.fixture() def change_dir(request): orig_dir = os.getcwd() - filepath = os.path.dirname( os.path.realpath( __file__ ) ) + filepath = os.path.dirname( os.path.realpath( __file__)) datadir = os.path.realpath(os.path.join(filepath, '../../../testing/data')) os.chdir(datadir) diff --git a/nipype/interfaces/fsl/aroma.py b/nipype/interfaces/fsl/aroma.py index fb8dc82bd8..f654e8bdc3 100644 --- a/nipype/interfaces/fsl/aroma.py +++ b/nipype/interfaces/fsl/aroma.py @@ -64,7 +64,7 @@ class ICA_AROMAOutputSpec(TraitedSpec): aggr_denoised_file = File(exists=True, desc='if generated: aggressively denoised volume') nonaggr_denoised_file = File(exists=True, - desc='if generated: non aggressively denoised volume' ) + desc='if generated: non aggressively denoised volume') out_dir = Directory(exists=True, desc='directory contains (in addition to the denoised files): ' 'melodic.ica + classified_motion_components + ' diff --git a/nipype/workflows/smri/freesurfer/autorecon3.py b/nipype/workflows/smri/freesurfer/autorecon3.py index 25115a8ba0..7afaa06469 100644 --- a/nipype/workflows/smri/freesurfer/autorecon3.py +++ b/nipype/workflows/smri/freesurfer/autorecon3.py @@ -339,7 +339,7 @@ def create_AutoRecon3(name="AutoRecon3", qcache=False, plugin_args=None, intrinsic curvature index. """ parcellation_stats_white = pe.Node( - ParcellationStats(), name="Parcellation_Stats_{0}_White".format(hemisphere) ) + ParcellationStats(), name="Parcellation_Stats_{0}_White".format(hemisphere)) parcellation_stats_white.inputs.mgz = True parcellation_stats_white.inputs.th3 = th3 parcellation_stats_white.inputs.tabular_output = True From f74b57fb381307086694b4fb3b54d4c57f882d75 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:27:08 +0100 Subject: [PATCH 17/56] STY: correction of E201 - whitespace after '{' --- .../interfaces/ants/tests/test_resampling.py | 2 +- nipype/interfaces/freesurfer/utils.py | 4 +-- nipype/workflows/smri/freesurfer/utils.py | 26 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/nipype/interfaces/ants/tests/test_resampling.py b/nipype/interfaces/ants/tests/test_resampling.py index a34f138ee5..c51d497794 100644 --- a/nipype/interfaces/ants/tests/test_resampling.py +++ b/nipype/interfaces/ants/tests/test_resampling.py @@ -9,7 +9,7 @@ @pytest.fixture() def change_dir(request): orig_dir = os.getcwd() - filepath = os.path.dirname( os.path.realpath( __file__)) + filepath = os.path.dirname(os.path.realpath(__file__)) datadir = os.path.realpath(os.path.join(filepath, '../../../testing/data')) os.chdir(datadir) diff --git a/nipype/interfaces/freesurfer/utils.py b/nipype/interfaces/freesurfer/utils.py index a5568ebbcb..d3eb7b611d 100644 --- a/nipype/interfaces/freesurfer/utils.py +++ b/nipype/interfaces/freesurfer/utils.py @@ -1743,7 +1743,7 @@ class MRIsInflateInputSpec(FSTraitedSpec): hash_files=False, keep_extension=True, desc="Output file for MRIsInflate") # optional - out_sulc = File( exists=False, + out_sulc = File(exists=False, xor=['no_save_sulc'], desc="Output sulc file") no_save_sulc = traits.Bool(argstr='-no-save-sulc', @@ -1796,7 +1796,7 @@ class SphereInputSpec(FSTraitedSpecOpenMP): desc="Seed for setting random number generator") magic = traits.Bool(argstr="-q", desc="No documentation. Direct questions to analysis-bugs@nmr.mgh.harvard.edu") - in_smoothwm = File( exists=True, copyfile=True, + in_smoothwm = File(exists=True, copyfile=True, desc="Input surface required when -q flag is not selected") diff --git a/nipype/workflows/smri/freesurfer/utils.py b/nipype/workflows/smri/freesurfer/utils.py index 6ee04c9673..838333b093 100644 --- a/nipype/workflows/smri/freesurfer/utils.py +++ b/nipype/workflows/smri/freesurfer/utils.py @@ -422,19 +422,19 @@ def mkdir_p(path): raise def getdefaultconfig(exitonfail=False, rb_date="2014-08-21"): - config = { 'custom_atlas' : None, - 'cw256' : False, - 'field_strength' : '1.5T', - 'fs_home' : checkenv(exitonfail), - 'longitudinal' : False, - 'long_base' : None, - 'openmp' : None, - 'plugin_args' : None, - 'qcache' : False, - 'queue' : None, - 'recoding_file' : None, - 'src_subject_id' : 'fsaverage', - 'th3' : True} + config = {'custom_atlas' : None, + 'cw256' : False, + 'field_strength' : '1.5T', + 'fs_home' : checkenv(exitonfail), + 'longitudinal' : False, + 'long_base' : None, + 'openmp' : None, + 'plugin_args' : None, + 'qcache' : False, + 'queue' : None, + 'recoding_file' : None, + 'src_subject_id' : 'fsaverage', + 'th3' : True} config['src_subject_dir'] = os.path.join(config['fs_home'], 'subjects', config['src_subject_id']) From d0bbf3bb911d8651a14e36f87f607fa39d09a02c Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:29:05 +0100 Subject: [PATCH 18/56] STY: correction of E211 - whitespace before '(' --- nipype/interfaces/fsl/preprocess.py | 2 +- nipype/interfaces/petpvc.py | 6 +++--- nipype/scripts/crash_files.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nipype/interfaces/fsl/preprocess.py b/nipype/interfaces/fsl/preprocess.py index 4ffeead842..4f2e77c698 100644 --- a/nipype/interfaces/fsl/preprocess.py +++ b/nipype/interfaces/fsl/preprocess.py @@ -1023,7 +1023,7 @@ def write_config(self, configfile): try: fid = open(configfile, 'w+') except IOError: - print ('unable to create config_file %s' % (configfile)) + print('unable to create config_file %s' % (configfile)) for item in list(self.inputs.get().items()): fid.write('%s\n' % (item)) diff --git a/nipype/interfaces/petpvc.py b/nipype/interfaces/petpvc.py index dbb3a25d1a..8de4cfd162 100644 --- a/nipype/interfaces/petpvc.py +++ b/nipype/interfaces/petpvc.py @@ -48,9 +48,9 @@ class PETPVCInputSpec(CommandLineInputSpec): fwhm_x = traits.Float(desc="The full-width at half maximum in mm along x-axis", mandatory=True, argstr="-x %.4f") fwhm_y = traits.Float(desc="The full-width at half maximum in mm along y-axis", mandatory=True, argstr="-y %.4f") fwhm_z = traits.Float(desc="The full-width at half maximum in mm along z-axis", mandatory=True, argstr="-z %.4f") - debug = traits.Bool (desc="Prints debug information", usedefault=True, default_value=False, argstr="-d") - n_iter = traits.Int (desc="Number of iterations", default_value=10, argstr="-n %d") - n_deconv = traits.Int (desc="Number of deconvolution iterations", default_value=10, argstr="-k %d") + debug = traits.Bool(desc="Prints debug information", usedefault=True, default_value=False, argstr="-d") + n_iter = traits.Int(desc="Number of iterations", default_value=10, argstr="-n %d") + n_deconv = traits.Int(desc="Number of deconvolution iterations", default_value=10, argstr="-k %d") alpha = traits.Float(desc="Alpha value", default_value=1.5, argstr="-a %.4f") stop_crit = traits.Float(desc="Stopping criterion", default_value=0.01, argstr="-a %.4f") diff --git a/nipype/scripts/crash_files.py b/nipype/scripts/crash_files.py index 363e0abf80..b7b83dff5c 100644 --- a/nipype/scripts/crash_files.py +++ b/nipype/scripts/crash_files.py @@ -68,7 +68,7 @@ def display_crash_file(crashfile, rerun, debug, directory): print("\n") print("Traceback: ") print(''.join(tb)) - print ("\n") + print("\n") if rerun: if node is None: From 57228bc55685e5316b9aac13ee2b3b98277c4d0b Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:30:07 +0100 Subject: [PATCH 19/56] STY: correction of E272 - multiple spaces before keyword --- nipype/interfaces/tests/test_io.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nipype/interfaces/tests/test_io.py b/nipype/interfaces/tests/test_io.py index 40420c05c6..e2eb4e3c09 100644 --- a/nipype/interfaces/tests/test_io.py +++ b/nipype/interfaces/tests/test_io.py @@ -155,11 +155,11 @@ def test_datagrabber_order(tmpdir): res = dg.run() outfiles = res.outputs.outfiles - assert 'sub002_L1_R1' in outfiles[0][0] - assert 'sub002_L1_R2' in outfiles[0][1] - assert 'sub002_L2_R1' in outfiles[1][0] - assert 'sub002_L2_R2' in outfiles[1][1] - assert 'sub002_L3_R2' in outfiles[2][0] + assert 'sub002_L1_R1' in outfiles[0][0] + assert 'sub002_L1_R2' in outfiles[0][1] + assert 'sub002_L2_R1' in outfiles[1][0] + assert 'sub002_L2_R2' in outfiles[1][1] + assert 'sub002_L3_R2' in outfiles[2][0] assert 'sub002_L3_R10' in outfiles[2][1] From 7d673e31270ef9f82341e4b173f9ebc676bf11dd Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:37:01 +0100 Subject: [PATCH 20/56] STY: correction of E301 - expected 1 blank line, found 0 --- nipype/interfaces/afni/preprocess.py | 1 + nipype/interfaces/ants/registration.py | 1 + nipype/pipeline/engine/tests/test_engine.py | 1 + nipype/sphinxext/plot_workflow.py | 2 ++ 4 files changed, 5 insertions(+) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index c96616273d..27849486e7 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -745,6 +745,7 @@ class AutoTLRC(AFNICommand): _cmd = '@auto_tlrc' input_spec = AutoTLRCInputSpec output_spec = AFNICommandOutputSpec + def _list_outputs(self): outputs = self.output_spec().get() ext = '.HEAD' diff --git a/nipype/interfaces/ants/registration.py b/nipype/interfaces/ants/registration.py index a5fd0e63da..9f528b6144 100644 --- a/nipype/interfaces/ants/registration.py +++ b/nipype/interfaces/ants/registration.py @@ -1031,6 +1031,7 @@ def _format_winsorize_image_intensities(self): self._quantilesDone = True return '--winsorize-image-intensities [ %s, %s ]' % (self.inputs.winsorize_lower_quantile, self.inputs.winsorize_upper_quantile) + def _get_initial_transform_filenames(self): n_transforms = len(self.inputs.initial_moving_transform) diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py index 8b4d559ec0..1726c2004a 100644 --- a/nipype/pipeline/engine/tests/test_engine.py +++ b/nipype/pipeline/engine/tests/test_engine.py @@ -463,6 +463,7 @@ def test_mapnode_iterfield_check(): ]) def test_mapnode_iterfield_type(x_inp, f_exp): from nipype import MapNode, Function + def double_func(x): return 2 * x double = Function(["x"], ["f_x"], double_func) diff --git a/nipype/sphinxext/plot_workflow.py b/nipype/sphinxext/plot_workflow.py index 46ccad7a01..fab49976d8 100644 --- a/nipype/sphinxext/plot_workflow.py +++ b/nipype/sphinxext/plot_workflow.py @@ -124,12 +124,14 @@ try: # Sphinx depends on either Jinja or Jinja2 import jinja2 + def format_template(template, **kw): return jinja2.Template(template).render(**kw) except ImportError as e: missing_imports.append(str(e)) try: import jinja + def format_template(template, **kw): return jinja.from_string(template, **kw) missing_imports.pop() From dad9539b484263ded7a79cd425e027412d34b79d Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:38:54 +0100 Subject: [PATCH 21/56] STY: correction of E401 - multiple imports on one line --- nipype/conftest.py | 3 ++- nipype/interfaces/freesurfer/tests/test_utils.py | 3 ++- nipype/interfaces/fsl/tests/test_preprocess.py | 3 ++- nipype/pipeline/engine/tests/test_engine.py | 3 ++- nipype/pipeline/engine/tests/test_utils.py | 3 ++- nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py | 3 ++- nipype/sphinxext/plot_workflow.py | 7 ++++++- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/nipype/conftest.py b/nipype/conftest.py index 27a3789ea4..e9faf69075 100644 --- a/nipype/conftest.py +++ b/nipype/conftest.py @@ -1,5 +1,6 @@ import pytest -import numpy, os +import numpy +import os @pytest.fixture(autouse=True) def add_np(doctest_namespace): diff --git a/nipype/interfaces/freesurfer/tests/test_utils.py b/nipype/interfaces/freesurfer/tests/test_utils.py index c033a1e346..054aeb276e 100644 --- a/nipype/interfaces/freesurfer/tests/test_utils.py +++ b/nipype/interfaces/freesurfer/tests/test_utils.py @@ -3,7 +3,8 @@ # vi: set ft=python sts=4 ts=4 sw=4 et: from __future__ import print_function, division, unicode_literals, absolute_import from builtins import open -import os, os.path as op +import os +import os.path as op import pytest from nipype.testing.fixtures import (create_files_in_directory_plus_dummy_file, create_surf_file_in_directory) diff --git a/nipype/interfaces/fsl/tests/test_preprocess.py b/nipype/interfaces/fsl/tests/test_preprocess.py index ece8b76c29..ae3ec612c7 100644 --- a/nipype/interfaces/fsl/tests/test_preprocess.py +++ b/nipype/interfaces/fsl/tests/test_preprocess.py @@ -8,7 +8,8 @@ import os from copy import deepcopy -import pytest, pdb +import pytest +import pdb from nipype.utils.filemanip import split_filename, filename_to_list from .. import preprocess as fsl from nipype.interfaces.fsl import Info diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py index 1726c2004a..f0c8e150a8 100644 --- a/nipype/pipeline/engine/tests/test_engine.py +++ b/nipype/pipeline/engine/tests/test_engine.py @@ -10,7 +10,8 @@ from builtins import open from copy import deepcopy from glob import glob -import os, sys +import os +import sys import networkx as nx diff --git a/nipype/pipeline/engine/tests/test_utils.py b/nipype/pipeline/engine/tests/test_utils.py index 23c7a16fc6..7435bccc85 100644 --- a/nipype/pipeline/engine/tests/test_utils.py +++ b/nipype/pipeline/engine/tests/test_utils.py @@ -6,7 +6,8 @@ from __future__ import print_function, division, unicode_literals, absolute_import from builtins import range, open -import os, sys +import os +import sys from copy import deepcopy from shutil import rmtree import pytest diff --git a/nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py b/nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py index 7112aa2448..e5150d8c20 100644 --- a/nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py +++ b/nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py @@ -7,7 +7,8 @@ from builtins import range, open # Import packages -import os, sys +import os +import sys from tempfile import mkdtemp from shutil import rmtree import pytest diff --git a/nipype/sphinxext/plot_workflow.py b/nipype/sphinxext/plot_workflow.py index fab49976d8..47f369ef75 100644 --- a/nipype/sphinxext/plot_workflow.py +++ b/nipype/sphinxext/plot_workflow.py @@ -108,7 +108,12 @@ """ from __future__ import print_function, division, absolute_import, unicode_literals -import sys, os, shutil, io, re, textwrap +import sys +import os +import shutil +import io +import re +import textwrap from os.path import relpath from errno import EEXIST import traceback From 997c06e3e0385fa54c59a55a2d4bab95abb57a76 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:41:53 +0100 Subject: [PATCH 22/56] STY: correction of E711 - comparison to None should be 'if cond is None:' --- nipype/interfaces/freesurfer/utils.py | 4 ++-- nipype/interfaces/spm/tests/test_base.py | 6 +++--- nipype/utils/tests/test_filemanip.py | 2 +- nipype/workflows/smri/freesurfer/autorecon1.py | 2 +- nipype/workflows/smri/freesurfer/utils.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nipype/interfaces/freesurfer/utils.py b/nipype/interfaces/freesurfer/utils.py index d3eb7b611d..527ed3b972 100644 --- a/nipype/interfaces/freesurfer/utils.py +++ b/nipype/interfaces/freesurfer/utils.py @@ -57,10 +57,10 @@ def copy2subjdir(cls, in_file, folder=None, basename=None, subject_id=None): else: subject_id = 'subject_id' #default # check for basename - if basename == None: + if basename is None: basename = os.path.basename(in_file) # check which folder to put the file in - if folder != None: + if folder is not None: out_dir = os.path.join(subjects_dir, subject_id, folder) else: out_dir = os.path.join(subjects_dir, subject_id) diff --git a/nipype/interfaces/spm/tests/test_base.py b/nipype/interfaces/spm/tests/test_base.py index d1c517a0d3..90aad6cdd2 100644 --- a/nipype/interfaces/spm/tests/test_base.py +++ b/nipype/interfaces/spm/tests/test_base.py @@ -60,13 +60,13 @@ class TestClass(spm.SPMCommand): except KeyError: pass dc = TestClass() - assert dc._use_mcr == None - assert dc._matlab_cmd == None + assert dc._use_mcr is None + assert dc._matlab_cmd is None # test with only FORCE_SPMMCR set os.environ['FORCE_SPMMCR'] = '1' dc = TestClass() assert dc._use_mcr == True - assert dc._matlab_cmd == None + assert dc._matlab_cmd is None # test with both, FORCE_SPMMCR and SPMMCRCMD set os.environ['SPMMCRCMD'] = 'spmcmd' dc = TestClass() diff --git a/nipype/utils/tests/test_filemanip.py b/nipype/utils/tests/test_filemanip.py index 029bfa7320..b83a176ad5 100644 --- a/nipype/utils/tests/test_filemanip.py +++ b/nipype/utils/tests/test_filemanip.py @@ -72,7 +72,7 @@ def test_check_forhash(): assert hash == [orig_hash] result, hash = check_forhash('foobar.nii') assert not result - assert hash == None + assert hash is None @pytest.fixture() def _temp_analyze_files(tmpdir): diff --git a/nipype/workflows/smri/freesurfer/autorecon1.py b/nipype/workflows/smri/freesurfer/autorecon1.py index 62bd4437df..2c9d81d92f 100644 --- a/nipype/workflows/smri/freesurfer/autorecon1.py +++ b/nipype/workflows/smri/freesurfer/autorecon1.py @@ -254,7 +254,7 @@ def createTemplate(in_files, out_file): if not longitudinal: # single session processing talairach_avi = pe.Node(TalairachAVI(), name="Compute_Transform") - if custom_atlas != None: + if custom_atlas is not None: # allows to specify a custom atlas talairach_avi.inputs.atlas = custom_atlas talairach_avi.inputs.out_file = 'talairach.auto.xfm' diff --git a/nipype/workflows/smri/freesurfer/utils.py b/nipype/workflows/smri/freesurfer/utils.py index 838333b093..06c85d0bd0 100644 --- a/nipype/workflows/smri/freesurfer/utils.py +++ b/nipype/workflows/smri/freesurfer/utils.py @@ -400,7 +400,7 @@ def copy_file(in_file, out_file=None): """ import os import shutil - if out_file == None: + if out_file is None: out_file = os.path.join(os.getcwd(), os.path.basename(in_file)) if type(in_file) is list and len(in_file) == 1: in_file = in_file[0] @@ -470,7 +470,7 @@ def checkenv(exitonfail=False): fs_home = os.environ.get('FREESURFER_HOME') path = os.environ.get('PATH') print("FREESURFER_HOME: {0}".format(fs_home)) - if fs_home == None: + if fs_home is None: msg = "please set FREESURFER_HOME before running the workflow" elif not os.path.isdir(fs_home): msg = "FREESURFER_HOME must be set to a valid directory before running this workflow" From f92c36c5ff84f31d9b6dbae55e6eb14b910c154f Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:48:34 +0100 Subject: [PATCH 23/56] STY: correction of E712 - comparison to False should be 'if cond is False:' or 'if not cond:' --- nipype/interfaces/fsl/tests/test_dti.py | 2 +- nipype/interfaces/fsl/tests/test_preprocess.py | 2 +- nipype/interfaces/spm/tests/test_base.py | 4 ++-- nipype/interfaces/spm/tests/test_utils.py | 4 ++-- nipype/pipeline/plugins/sgegraph.py | 2 +- nipype/pipeline/plugins/slurmgraph.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nipype/interfaces/fsl/tests/test_dti.py b/nipype/interfaces/fsl/tests/test_dti.py index 751340941b..a07083ca1c 100644 --- a/nipype/interfaces/fsl/tests/test_dti.py +++ b/nipype/interfaces/fsl/tests/test_dti.py @@ -223,7 +223,7 @@ def test_Proj_thresh(): results = proj3.run(volumes=['inp1', 'inp3', 'inp2'], threshold=2) assert results.runtime.cmdline == 'proj_thresh inp1 inp3 inp2 2' assert results.runtime.returncode != 0 - assert isinstance(results.interface.inputs.volumes, list) == True + assert isinstance(results.interface.inputs.volumes, list) assert results.interface.inputs.threshold == 2 # test arguments for opt_map diff --git a/nipype/interfaces/fsl/tests/test_preprocess.py b/nipype/interfaces/fsl/tests/test_preprocess.py index ae3ec612c7..e404177e87 100644 --- a/nipype/interfaces/fsl/tests/test_preprocess.py +++ b/nipype/interfaces/fsl/tests/test_preprocess.py @@ -102,7 +102,7 @@ def test_fast(setup_infile): fasted2 = fsl.FAST(in_files=[tmp_infile, tmp_infile], verbose=True) assert faster.cmd == 'fast' - assert faster.inputs.verbose == True + assert faster.inputs.verbose assert faster.inputs.manual_seg == Undefined assert faster.inputs != fasted.inputs assert fasted.cmdline == 'fast -v -S 1 %s' % (tmp_infile) diff --git a/nipype/interfaces/spm/tests/test_base.py b/nipype/interfaces/spm/tests/test_base.py index 90aad6cdd2..f52f072854 100644 --- a/nipype/interfaces/spm/tests/test_base.py +++ b/nipype/interfaces/spm/tests/test_base.py @@ -65,12 +65,12 @@ class TestClass(spm.SPMCommand): # test with only FORCE_SPMMCR set os.environ['FORCE_SPMMCR'] = '1' dc = TestClass() - assert dc._use_mcr == True + assert dc._use_mcr assert dc._matlab_cmd is None # test with both, FORCE_SPMMCR and SPMMCRCMD set os.environ['SPMMCRCMD'] = 'spmcmd' dc = TestClass() - assert dc._use_mcr == True + assert dc._use_mcr assert dc._matlab_cmd == 'spmcmd' # restore environment os.environ.clear() diff --git a/nipype/interfaces/spm/tests/test_utils.py b/nipype/interfaces/spm/tests/test_utils.py index 7d8106f80c..43b759717e 100644 --- a/nipype/interfaces/spm/tests/test_utils.py +++ b/nipype/interfaces/spm/tests/test_utils.py @@ -18,7 +18,7 @@ def test_coreg(): coreg.inputs.target = target assert coreg.inputs.matlab_cmd == 'mymatlab' coreg.inputs.moving = moving - assert isdefined(coreg.inputs.mat) == False + assert not isdefined(coreg.inputs.mat) pth, mov, _ = split_filename(moving) _, tgt, _ = split_filename(target) mat = os.path.join(pth, '%s_to_%s.mat' % (mov, tgt)) @@ -70,7 +70,7 @@ def test_dicom_import(): assert di.inputs.output_dir_struct == 'flat' assert di.inputs.output_dir == './converted_dicom' assert di.inputs.format == 'nii' - assert di.inputs.icedims == False + assert not di.inputs.icedims with pytest.raises(TraitError): di.inputs.trait_set(output_dir_struct='wrong') with pytest.raises(TraitError): di.inputs.trait_set(format='FAT') with pytest.raises(TraitError): di.inputs.trait_set(in_files=['does_sfd_not_32fn_exist.dcm']) diff --git a/nipype/pipeline/plugins/sgegraph.py b/nipype/pipeline/plugins/sgegraph.py index 882c455450..21033bf4e5 100644 --- a/nipype/pipeline/plugins/sgegraph.py +++ b/nipype/pipeline/plugins/sgegraph.py @@ -123,7 +123,7 @@ def make_job_name(jobnumber, nodeslist): values = ' ' for jobid in dependencies[idx]: # Avoid dependancies of done jobs - if not self._dont_resubmit_completed_jobs or cache_doneness_per_node[jobid] == False: + if not self._dont_resubmit_completed_jobs or not cache_doneness_per_node[jobid]: values += "${{{0}}},".format(make_job_name(jobid, nodes)) if values != ' ': # i.e. if some jobs were added to dependency list values = values.rstrip(',') diff --git a/nipype/pipeline/plugins/slurmgraph.py b/nipype/pipeline/plugins/slurmgraph.py index ed571ecffe..090df2a50b 100644 --- a/nipype/pipeline/plugins/slurmgraph.py +++ b/nipype/pipeline/plugins/slurmgraph.py @@ -122,7 +122,7 @@ def make_job_name(jobnumber, nodeslist): values = '' for jobid in dependencies[idx]: # Avoid dependancies of done jobs - if not self._dont_resubmit_completed_jobs or cache_doneness_per_node[jobid] == False: + if not self._dont_resubmit_completed_jobs or not cache_doneness_per_node[jobid]: values += "${{{0}}}:".format(make_job_name(jobid, nodes)) if values != '': # i.e. if some jobs were added to dependency list values = values.rstrip(':') From d594e732ba56390752d48ba895e6758e8422a4a3 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:53:47 +0100 Subject: [PATCH 24/56] STY: correction of E131 - continuation line unaligned for hanging indent --- nipype/interfaces/afni/preprocess.py | 122 +++++++++--------- nipype/interfaces/afni/utils.py | 92 ++++++------- .../interfaces/freesurfer/tests/test_model.py | 2 +- nipype/pipeline/engine/tests/test_engine.py | 2 +- 4 files changed, 109 insertions(+), 109 deletions(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index 27849486e7..c94e4d0d5a 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -666,62 +666,62 @@ class AutoTLRCInputSpec(CommandLineInputSpec): copyfile=False) base = traits.Str( desc = ' Reference anatomical volume' - ' Usually this volume is in some standard space like' - ' TLRC or MNI space and with afni dataset view of' - ' (+tlrc).' - ' Preferably, this reference volume should have had' - ' the skull removed but that is not mandatory.' - ' AFNI\'s distribution contains several templates.' - ' For a longer list, use "whereami -show_templates"' - 'TT_N27+tlrc --> Single subject, skull stripped volume.' - ' This volume is also known as ' - ' N27_SurfVol_NoSkull+tlrc elsewhere in ' - ' AFNI and SUMA land.' - ' (www.loni.ucla.edu, www.bic.mni.mcgill.ca)' - ' This template has a full set of FreeSurfer' - ' (surfer.nmr.mgh.harvard.edu)' - ' surface models that can be used in SUMA. ' - ' For details, see Talairach-related link:' - ' https://afni.nimh.nih.gov/afni/suma' - 'TT_icbm452+tlrc --> Average volume of 452 normal brains.' - ' Skull Stripped. (www.loni.ucla.edu)' - 'TT_avg152T1+tlrc --> Average volume of 152 normal brains.' - ' Skull Stripped.(www.bic.mni.mcgill.ca)' - 'TT_EPI+tlrc --> EPI template from spm2, masked as TT_avg152T1' - ' TT_avg152 and TT_EPI volume sources are from' - ' SPM\'s distribution. (www.fil.ion.ucl.ac.uk/spm/)' - 'If you do not specify a path for the template, the script' - 'will attempt to locate the template AFNI\'s binaries directory.' - 'NOTE: These datasets have been slightly modified from' - ' their original size to match the standard TLRC' - ' dimensions (Jean Talairach and Pierre Tournoux' - ' Co-Planar Stereotaxic Atlas of the Human Brain' - ' Thieme Medical Publishers, New York, 1988). ' - ' That was done for internal consistency in AFNI.' - ' You may use the original form of these' - ' volumes if you choose but your TLRC coordinates' - ' will not be consistent with AFNI\'s TLRC database' - ' (San Antonio Talairach Daemon database), for example.', + ' Usually this volume is in some standard space like' + ' TLRC or MNI space and with afni dataset view of' + ' (+tlrc).' + ' Preferably, this reference volume should have had' + ' the skull removed but that is not mandatory.' + ' AFNI\'s distribution contains several templates.' + ' For a longer list, use "whereami -show_templates"' + 'TT_N27+tlrc --> Single subject, skull stripped volume.' + ' This volume is also known as ' + ' N27_SurfVol_NoSkull+tlrc elsewhere in ' + ' AFNI and SUMA land.' + ' (www.loni.ucla.edu, www.bic.mni.mcgill.ca)' + ' This template has a full set of FreeSurfer' + ' (surfer.nmr.mgh.harvard.edu)' + ' surface models that can be used in SUMA. ' + ' For details, see Talairach-related link:' + ' https://afni.nimh.nih.gov/afni/suma' + 'TT_icbm452+tlrc --> Average volume of 452 normal brains.' + ' Skull Stripped. (www.loni.ucla.edu)' + 'TT_avg152T1+tlrc --> Average volume of 152 normal brains.' + ' Skull Stripped.(www.bic.mni.mcgill.ca)' + 'TT_EPI+tlrc --> EPI template from spm2, masked as TT_avg152T1' + ' TT_avg152 and TT_EPI volume sources are from' + ' SPM\'s distribution. (www.fil.ion.ucl.ac.uk/spm/)' + 'If you do not specify a path for the template, the script' + 'will attempt to locate the template AFNI\'s binaries directory.' + 'NOTE: These datasets have been slightly modified from' + ' their original size to match the standard TLRC' + ' dimensions (Jean Talairach and Pierre Tournoux' + ' Co-Planar Stereotaxic Atlas of the Human Brain' + ' Thieme Medical Publishers, New York, 1988). ' + ' That was done for internal consistency in AFNI.' + ' You may use the original form of these' + ' volumes if you choose but your TLRC coordinates' + ' will not be consistent with AFNI\'s TLRC database' + ' (San Antonio Talairach Daemon database), for example.', mandatory = True, argstr='-base %s') no_ss = traits.Bool( desc='Do not strip skull of input data set' - '(because skull has already been removed' - 'or because template still has the skull)' - 'NOTE: The -no_ss option is not all that optional.' - ' Here is a table of when you should and should not use -no_ss' - ' Template Template' - ' WITH skull WITHOUT skull' - ' Dset.' - ' WITH skull -no_ss xxx ' - ' ' - ' WITHOUT skull No Cigar -no_ss' - ' ' - ' Template means: Your template of choice' - ' Dset. means: Your anatomical dataset' - ' -no_ss means: Skull stripping should not be attempted on Dset' - ' xxx means: Don\'t put anything, the script will strip Dset' - ' No Cigar means: Don\'t try that combination, it makes no sense.', + '(because skull has already been removed' + 'or because template still has the skull)' + 'NOTE: The -no_ss option is not all that optional.' + ' Here is a table of when you should and should not use -no_ss' + ' Template Template' + ' WITH skull WITHOUT skull' + ' Dset.' + ' WITH skull -no_ss xxx ' + ' ' + ' WITHOUT skull No Cigar -no_ss' + ' ' + ' Template means: Your template of choice' + ' Dset. means: Your anatomical dataset' + ' -no_ss means: Skull stripping should not be attempted on Dset' + ' xxx means: Don\'t put anything, the script will strip Dset' + ' No Cigar means: Don\'t try that combination, it makes no sense.', argstr='-no_ss') class AutoTLRC(AFNICommand): @@ -2798,15 +2798,15 @@ class QwarpPlusMinusInputSpec(CommandLineInputSpec): blur = traits.List( traits.Float(), desc="Gaussian blur the input images by (FWHM) voxels " - "before doing the alignment (the output dataset " - "will not be blurred). The default is 2.345 (for " - "no good reason). Optionally, you can provide 2 " - "values, and then the first one is applied to the " - "base volume, the second to the source volume. A " - "negative blur radius means to use 3D median " - "filtering, rather than Gaussian blurring. This " - "type of filtering will better preserve edges, " - "which can be important in alignment.", + "before doing the alignment (the output dataset " + "will not be blurred). The default is 2.345 (for " + "no good reason). Optionally, you can provide 2 " + "values, and then the first one is applied to the " + "base volume, the second to the source volume. A " + "negative blur radius means to use 3D median " + "filtering, rather than Gaussian blurring. This " + "type of filtering will better preserve edges, " + "which can be important in alignment.", argstr='-blur %s', minlen=1, maxlen=2) diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index 922e6fd05c..01e9a44bce 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -337,45 +337,45 @@ class BucketInputSpec(AFNICommandInputSpec): mandatory=True, argstr="%s", desc='List of tuples of input datasets and subbrick selection strings' - 'as described in more detail in the following afni help string' - 'Input dataset specified using one of these forms:' - ' \'prefix+view\', \'prefix+view.HEAD\', or \'prefix+view.BRIK\'.' - 'You can also add a sub-brick selection list after the end of the' - 'dataset name. This allows only a subset of the sub-bricks to be' - 'included into the output (by default, all of the input dataset' - 'is copied into the output). A sub-brick selection list looks like' - 'one of the following forms:' - ' fred+orig[5] ==> use only sub-brick #5' - ' fred+orig[5,9,17] ==> use #5, #9, and #17' - ' fred+orig[5..8] or [5-8] ==> use #5, #6, #7, and #8' - ' fred+orig[5..13(2)] or [5-13(2)] ==> use #5, #7, #9, #11, and #13' - 'Sub-brick indexes start at 0. You can use the character \'$\'' - 'to indicate the last sub-brick in a dataset; for example, you' - 'can select every third sub-brick by using the selection list' - ' fred+orig[0..$(3)]' - 'N.B.: The sub-bricks are output in the order specified, which may' - ' not be the order in the original datasets. For example, using' - ' fred+orig[0..$(2),1..$(2)]' - ' will cause the sub-bricks in fred+orig to be output into the' - ' new dataset in an interleaved fashion. Using' - ' fred+orig[$..0]' - ' will reverse the order of the sub-bricks in the output.' - 'N.B.: Bucket datasets have multiple sub-bricks, but do NOT have' - ' a time dimension. You can input sub-bricks from a 3D+time dataset' - ' into a bucket dataset. You can use the \'3dinfo\' program to see' - ' how many sub-bricks a 3D+time or a bucket dataset contains.' - 'N.B.: In non-bucket functional datasets (like the \'fico\' datasets' - ' output by FIM, or the \'fitt\' datasets output by 3dttest), sub-brick' - ' [0] is the \'intensity\' and sub-brick [1] is the statistical parameter' - ' used as a threshold. Thus, to create a bucket dataset using the' - ' intensity from dataset A and the threshold from dataset B, and' - ' calling the output dataset C, you would type' - ' 3dbucket -prefix C -fbuc \'A+orig[0]\' -fbuc \'B+orig[1]\'' - 'WARNING: using this program, it is possible to create a dataset that' - ' has different basic datum types for different sub-bricks' - ' (e.g., shorts for brick 0, floats for brick 1).' - ' Do NOT do this! Very few AFNI programs will work correctly' - ' with such datasets!') + 'as described in more detail in the following afni help string' + 'Input dataset specified using one of these forms:' + ' \'prefix+view\', \'prefix+view.HEAD\', or \'prefix+view.BRIK\'.' + 'You can also add a sub-brick selection list after the end of the' + 'dataset name. This allows only a subset of the sub-bricks to be' + 'included into the output (by default, all of the input dataset' + 'is copied into the output). A sub-brick selection list looks like' + 'one of the following forms:' + ' fred+orig[5] ==> use only sub-brick #5' + ' fred+orig[5,9,17] ==> use #5, #9, and #17' + ' fred+orig[5..8] or [5-8] ==> use #5, #6, #7, and #8' + ' fred+orig[5..13(2)] or [5-13(2)] ==> use #5, #7, #9, #11, and #13' + 'Sub-brick indexes start at 0. You can use the character \'$\'' + 'to indicate the last sub-brick in a dataset; for example, you' + 'can select every third sub-brick by using the selection list' + ' fred+orig[0..$(3)]' + 'N.B.: The sub-bricks are output in the order specified, which may' + ' not be the order in the original datasets. For example, using' + ' fred+orig[0..$(2),1..$(2)]' + ' will cause the sub-bricks in fred+orig to be output into the' + ' new dataset in an interleaved fashion. Using' + ' fred+orig[$..0]' + ' will reverse the order of the sub-bricks in the output.' + 'N.B.: Bucket datasets have multiple sub-bricks, but do NOT have' + ' a time dimension. You can input sub-bricks from a 3D+time dataset' + ' into a bucket dataset. You can use the \'3dinfo\' program to see' + ' how many sub-bricks a 3D+time or a bucket dataset contains.' + 'N.B.: In non-bucket functional datasets (like the \'fico\' datasets' + ' output by FIM, or the \'fitt\' datasets output by 3dttest), sub-brick' + ' [0] is the \'intensity\' and sub-brick [1] is the statistical parameter' + ' used as a threshold. Thus, to create a bucket dataset using the' + ' intensity from dataset A and the threshold from dataset B, and' + ' calling the output dataset C, you would type' + ' 3dbucket -prefix C -fbuc \'A+orig[0]\' -fbuc \'B+orig[1]\'' + 'WARNING: using this program, it is possible to create a dataset that' + ' has different basic datum types for different sub-bricks' + ' (e.g., shorts for brick 0, floats for brick 1).' + ' Do NOT do this! Very few AFNI programs will work correctly' + ' with such datasets!') out_file = File( argstr='-prefix %s', name_template='buck') @@ -535,7 +535,7 @@ class CatInputSpec(AFNICommandInputSpec): argstr='-stack') sel = traits.Str( desc='Apply the same column/row selection string to all filenames ' - 'on the command line.', + 'on the command line.', argstr='-sel %s') out_int = traits.Bool( desc='specifiy int data type for output', @@ -598,9 +598,9 @@ class CatMatvecInputSpec(AFNICommandInputSpec): mandatory=True) matrix = traits.Bool( descr="indicates that the resulting matrix will" - "be written to outfile in the 'MATRIX(...)' format (FORM 3)." - "This feature could be used, with clever scripting, to input" - "a matrix directly on the command line to program 3dWarp.", + "be written to outfile in the 'MATRIX(...)' format (FORM 3)." + "This feature could be used, with clever scripting, to input" + "a matrix directly on the command line to program 3dWarp.", argstr="-MATRIX", xor=['oneline', 'fourxfour']) oneline = traits.Bool( @@ -838,7 +838,7 @@ class DotInputSpec(AFNICommandInputSpec): argstr='-full') show_labels = traits.Bool( desc='Print sub-brick labels to help identify what is being correlated. This option is useful when' - 'you have more than 2 sub-bricks at input.', + 'you have more than 2 sub-bricks at input.', argstr='-show_labels') upper = traits.Bool( desc='Compute upper triangular matrix', @@ -1551,7 +1551,7 @@ class NwarpApplyInputSpec(CommandLineInputSpec): name_source='in_file') short = traits.Bool( desc='Write output dataset using 16-bit short integers, rather than ' - 'the usual 32-bit floats.', + 'the usual 32-bit floats.', argstr='-short') quiet = traits.Bool( desc='don\'t be verbose :(', @@ -1727,7 +1727,7 @@ class OneDToolPyInputSpec(AFNIPythonCommandInputSpec): show_censor_count = traits.Bool( desc='display the total number of censored TRs Note : if input is a valid xmat.1D dataset,' 'then the count will come from the header. Otherwise the input is assumed to be a binary censor' - 'file, and zeros are simply counted.', + 'file, and zeros are simply counted.', argstr="-show_censor_count") censor_motion = traits.Tuple( (traits.Float(),File()), diff --git a/nipype/interfaces/freesurfer/tests/test_model.py b/nipype/interfaces/freesurfer/tests/test_model.py index a30a29b0ac..dd956ce708 100644 --- a/nipype/interfaces/freesurfer/tests/test_model.py +++ b/nipype/interfaces/freesurfer/tests/test_model.py @@ -48,7 +48,7 @@ def test_concatenate(tmpdir): wf.run() assert np.allclose(nb.load(tmpdir.join( 'test_concatenate', - 'concat', out).strpath).get_data(), + 'concat', out).strpath).get_data(), out_data) # Test a simple statistic diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py index f0c8e150a8..bdb42f15a7 100644 --- a/nipype/pipeline/engine/tests/test_engine.py +++ b/nipype/pipeline/engine/tests/test_engine.py @@ -460,7 +460,7 @@ def test_mapnode_iterfield_check(): @pytest.mark.parametrize("x_inp, f_exp", [ (3, [6]), ([2, 3], [4, 6]), ((2, 3), [4, 6]), (range(3), [0, 2, 4]), - ("Str", ["StrStr"]), (["Str1", "Str2"], ["Str1Str1", "Str2Str2"]) + ("Str", ["StrStr"]), (["Str1", "Str2"], ["Str1Str1", "Str2Str2"]) ]) def test_mapnode_iterfield_type(x_inp, f_exp): from nipype import MapNode, Function From 22d37d3dbad1ad4050950e284b88f4004cffb969 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 02:59:07 +0100 Subject: [PATCH 25/56] STY: correction of E262 - inline comment should start with '# ' --- nipype/interfaces/afni/utils.py | 2 +- nipype/interfaces/freesurfer/utils.py | 4 ++-- nipype/pipeline/engine/tests/test_engine.py | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index 01e9a44bce..e9c94b53fd 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -1311,7 +1311,7 @@ def _list_outputs(self): else: outputs['out_detrend'] = Undefined - sout = np.loadtxt(outputs['out_file']) #pylint: disable=E1101 + sout = np.loadtxt(outputs['out_file']) # pylint: disable=E1101 if self._acf: outputs['acf_param'] = tuple(sout[1]) sout = tuple(sout[0]) diff --git a/nipype/interfaces/freesurfer/utils.py b/nipype/interfaces/freesurfer/utils.py index 527ed3b972..ca9130122e 100644 --- a/nipype/interfaces/freesurfer/utils.py +++ b/nipype/interfaces/freesurfer/utils.py @@ -49,13 +49,13 @@ def copy2subjdir(cls, in_file, folder=None, basename=None, subject_id=None): if isdefined(cls.inputs.subjects_dir): subjects_dir = cls.inputs.subjects_dir else: - subjects_dir = os.getcwd() #if not use cwd + subjects_dir = os.getcwd() # if not use cwd # check for subject_id if not subject_id: if isdefined(cls.inputs.subject_id): subject_id = cls.inputs.subject_id else: - subject_id = 'subject_id' #default + subject_id = 'subject_id' # default # check for basename if basename is None: basename = os.path.basename(in_file) diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py index bdb42f15a7..c7b6c2f35a 100644 --- a/nipype/pipeline/engine/tests/test_engine.py +++ b/nipype/pipeline/engine/tests/test_engine.py @@ -75,8 +75,8 @@ def test_add_nodes(): # ensure that all connections are tested later @pytest.mark.parametrize("iterables, expected", [ - ({"1": None}, (1,0)), #test1 - ({"1": dict(input1=lambda: [1, 2], input2=lambda: [1, 2])}, (4,0)) #test2 + ({"1": None}, (1,0)), # test1 + ({"1": dict(input1=lambda: [1, 2], input2=lambda: [1, 2])}, (4,0)) # test2 ]) def test_1mod(iterables, expected): pipe = pe.Workflow(name='pipe') @@ -90,9 +90,9 @@ def test_1mod(iterables, expected): @pytest.mark.parametrize("iterables, expected", [ - ({"1": {}, "2": dict(input1=lambda: [1, 2])}, (3,2)), #test3 - ({"1": dict(input1=lambda: [1, 2]), "2": {}}, (4,2)), #test4 - ({"1": dict(input1=lambda: [1, 2]), "2": dict(input1=lambda: [1, 2])}, (6,4)) #test5 + ({"1": {}, "2": dict(input1=lambda: [1, 2])}, (3,2)), # test3 + ({"1": dict(input1=lambda: [1, 2]), "2": {}}, (4,2)), # test4 + ({"1": dict(input1=lambda: [1, 2]), "2": dict(input1=lambda: [1, 2])}, (6,4)) # test5 ]) def test_2mods(iterables, expected): pipe = pe.Workflow(name='pipe') @@ -108,10 +108,10 @@ def test_2mods(iterables, expected): @pytest.mark.parametrize("iterables, expected, connect", [ - ({"1": {}, "2": dict(input1=lambda: [1, 2]), "3": {}}, (5,4), ("1-2","2-3")), #test6 - ({"1": dict(input1=lambda: [1, 2]), "2": {}, "3": {}}, (5,4), ("1-3","2-3")), #test7 + ({"1": {}, "2": dict(input1=lambda: [1, 2]), "3": {}}, (5,4), ("1-2","2-3")), # test6 + ({"1": dict(input1=lambda: [1, 2]), "2": {}, "3": {}}, (5,4), ("1-3","2-3")), # test7 ({"1": dict(input1=lambda: [1, 2]), "2": dict(input1=lambda: [1, 2]), "3": {}}, - (8,8), ("1-3","2-3")), #test8 + (8,8), ("1-3","2-3")), # test8 ]) def test_3mods(iterables, expected, connect): pipe = pe.Workflow(name='pipe') From f21518e6c4c83689adfaf6d763624ed539b3c8db Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 03:04:21 +0100 Subject: [PATCH 26/56] STY: deletion of pylint info --- nipype/interfaces/afni/utils.py | 4 ++-- nipype/interfaces/base/core.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index e9c94b53fd..805d3c092c 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -732,7 +732,7 @@ def _list_outputs(self): outputs = super(CenterMass, self)._list_outputs() outputs['out_file'] = os.path.abspath(self.inputs.in_file) outputs['cm_file'] = os.path.abspath(self.inputs.cm_file) - sout = np.loadtxt(outputs['cm_file'], ndmin=2) # pylint: disable=E1101 + sout = np.loadtxt(outputs['cm_file'], ndmin=2) outputs['cm'] = [tuple(s) for s in sout] return outputs @@ -1311,7 +1311,7 @@ def _list_outputs(self): else: outputs['out_detrend'] = Undefined - sout = np.loadtxt(outputs['out_file']) # pylint: disable=E1101 + sout = np.loadtxt(outputs['out_file']) if self._acf: outputs['acf_param'] = tuple(sout[1]) sout = tuple(sout[0]) diff --git a/nipype/interfaces/base/core.py b/nipype/interfaces/base/core.py index bcf2656620..6fce67d40d 100644 --- a/nipype/interfaces/base/core.py +++ b/nipype/interfaces/base/core.py @@ -307,7 +307,7 @@ def _outputs_help(cls): """ helpstr = ['Outputs::', ''] if cls.output_spec: - outputs = cls.output_spec() # pylint: disable=E1102 + outputs = cls.output_spec() for name, spec in sorted(outputs.traits(transient=None).items()): helpstr += cls._get_trait_desc(outputs, name, spec) if len(helpstr) == 2: @@ -319,7 +319,7 @@ def _outputs(self): """ outputs = None if self.output_spec: - outputs = self.output_spec() # pylint: disable=E1102 + outputs = self.output_spec() return outputs @@ -1080,7 +1080,7 @@ def _list_outputs(self): metadata = dict(name_source=lambda t: t is not None) traits = self.inputs.traits(**metadata) if traits: - outputs = self.output_spec().get() # pylint: disable=E1102 + outputs = self.output_spec().get() for name, trait_spec in list(traits.items()): out_name = name if trait_spec.output_name is not None: @@ -1184,7 +1184,7 @@ class SEMLikeCommandLine(CommandLine): """ def _list_outputs(self): - outputs = self.output_spec().get() # pylint: disable=E1102 + outputs = self.output_spec().get() return self._outputs_from_inputs(outputs) def _outputs_from_inputs(self, outputs): From bdac9b146455ebeb0c699cad640f609a2921e2ed Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 03:10:09 +0100 Subject: [PATCH 27/56] STY: correction of E225 - missing whitespace around operator --- nipype/algorithms/modelgen.py | 4 +- nipype/algorithms/tests/test_confounds.py | 2 +- nipype/interfaces/afni/preprocess.py | 4 +- nipype/interfaces/afni/utils.py | 6 +-- nipype/interfaces/ants/segmentation.py | 2 +- nipype/interfaces/cmtk/tests/test_nbs.py | 2 +- nipype/interfaces/fsl/tests/test_maths.py | 2 +- .../workflows/smri/freesurfer/autorecon2.py | 38 +++++++++---------- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/nipype/algorithms/modelgen.py b/nipype/algorithms/modelgen.py index 2c994bf20d..ebecbe5303 100644 --- a/nipype/algorithms/modelgen.py +++ b/nipype/algorithms/modelgen.py @@ -586,9 +586,9 @@ def _generate_design(self, infolist=None): sumscans = out.astype(int) + sum(nscans[0:i]) if out.size == 1: - outliers[0]+= [np.array(sumscans, dtype=int).tolist()] + outliers[0] += [np.array(sumscans, dtype=int).tolist()] else: - outliers[0]+= np.array(sumscans, dtype=int).tolist() + outliers[0] += np.array(sumscans, dtype=int).tolist() self._sessinfo = self._generate_standard_design(concatlist, functional_runs=functional_runs, diff --git a/nipype/algorithms/tests/test_confounds.py b/nipype/algorithms/tests/test_confounds.py index 3f5b21ed55..bd145875aa 100644 --- a/nipype/algorithms/tests/test_confounds.py +++ b/nipype/algorithms/tests/test_confounds.py @@ -47,7 +47,7 @@ def test_dvars(tmpdir): res = dvars.run() dv1 = np.loadtxt(res.outputs.out_all, skiprows=1) - assert (np.abs(dv1[:, 0] - ground_truth[:, 0]).sum()/ len(dv1)) < 0.05 + assert (np.abs(dv1[:, 0] - ground_truth[:, 0]).sum() / len(dv1)) < 0.05 assert (np.abs(dv1[:, 1] - ground_truth[:, 1]).sum() / len(dv1)) < 0.05 diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index c94e4d0d5a..68e870fe5a 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -246,7 +246,7 @@ class AllineateInputSpec(AFNICommandInputSpec): desc='overwrite output file if it already exists', argstr='-overwrite') - allcostx= File( + allcostx = File( desc='Compute and print ALL available cost functionals for the un-warped inputs' 'AND THEN QUIT. If you use this option none of the other expected outputs will be produced', argstr='-allcostx |& tee %s', @@ -3509,7 +3509,7 @@ def _list_outputs(self): if not isdefined(self.inputs.out_file): prefix = self._gen_fname(self.inputs.in_file, suffix='_QW') ext = '.HEAD' - suffix ='+tlrc' + suffix = '+tlrc' else: prefix = self.inputs.out_file ext_ind = max([prefix.lower().rfind('.nii.gz'), diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index 805d3c092c..d643e012d0 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -1780,11 +1780,11 @@ def _list_outputs(self): outputs = self.output_spec().get() if isdefined(self.inputs.out_file): - outputs['out_file']=os.path.join(os.getcwd(), self.inputs.out_file) + outputs['out_file'] = os.path.join(os.getcwd(), self.inputs.out_file) if isdefined(self.inputs.show_cormat_warnings): - outputs['out_file']=os.path.join(os.getcwd(), self.inputs.show_cormat_warnings) + outputs['out_file'] = os.path.join(os.getcwd(), self.inputs.show_cormat_warnings) if isdefined(self.inputs.censor_motion): - outputs['out_file']=os.path.join(os.getcwd(), self.inputs.censor_motion[1]) + outputs['out_file'] = os.path.join(os.getcwd(), self.inputs.censor_motion[1]) return outputs class RefitInputSpec(CommandLineInputSpec): diff --git a/nipype/interfaces/ants/segmentation.py b/nipype/interfaces/ants/segmentation.py index 6c594b5e24..733a5dbdbc 100644 --- a/nipype/interfaces/ants/segmentation.py +++ b/nipype/interfaces/ants/segmentation.py @@ -773,7 +773,7 @@ def _list_outputs(self): ) outputs['BrainExtractionInitialAffine'] = os.path.join( os.getcwd(), - self.inputs.out_prefix +'BrainExtractionInitialAffine.mat' + self.inputs.out_prefix + 'BrainExtractionInitialAffine.mat' ) outputs['BrainExtractionInitialAffineFixed'] = os.path.join( os.getcwd(), diff --git a/nipype/interfaces/cmtk/tests/test_nbs.py b/nipype/interfaces/cmtk/tests/test_nbs.py index 03a7aa8619..66a7d05804 100644 --- a/nipype/interfaces/cmtk/tests/test_nbs.py +++ b/nipype/interfaces/cmtk/tests/test_nbs.py @@ -44,7 +44,7 @@ def test_importerror(creating_graphs, tmpdir): @pytest.mark.skipif(not have_cv, reason="cviewer has to be available") def test_keyerror(creating_graphs): - graphlist =creating_graphs + graphlist = creating_graphs group1 = graphlist[:3] group2 = graphlist[3:] diff --git a/nipype/interfaces/fsl/tests/test_maths.py b/nipype/interfaces/fsl/tests/test_maths.py index 4d3c6ad03d..dcaa7cf8bd 100644 --- a/nipype/interfaces/fsl/tests/test_maths.py +++ b/nipype/interfaces/fsl/tests/test_maths.py @@ -157,7 +157,7 @@ def test_stdimage(create_files_in_directory_plus_output_type): # Test the other dimensions cmdline = "fslmaths a.nii -{}std b.nii" for dim in ["X","Y","Z","T"]: - stder.inputs.dimension=dim + stder.inputs.dimension = dim assert stder.cmdline == cmdline.format(dim) # Test the auto naming diff --git a/nipype/workflows/smri/freesurfer/autorecon2.py b/nipype/workflows/smri/freesurfer/autorecon2.py index acd6c6d97f..0812cd1a5f 100644 --- a/nipype/workflows/smri/freesurfer/autorecon2.py +++ b/nipype/workflows/smri/freesurfer/autorecon2.py @@ -625,25 +625,25 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False, (inputspec, hemi_wf, [('num_threads', 'inputspec.num_threads')])]) # Outputs for hemisphere workflow - hemi_outputs=['orig_nofix', - 'orig', - 'smoothwm_nofix', - 'inflated_nofix', - 'qsphere_nofix', - 'white', - 'curv', - 'area', - 'cortex', - 'pial_auto', - 'thickness', - 'smoothwm', - 'sulc', - 'inflated', - 'white_H', - 'white_K', - 'inflated_H', - 'inflated_K', - 'curv_stats'] + hemi_outputs = ['orig_nofix', + 'orig', + 'smoothwm_nofix', + 'inflated_nofix', + 'qsphere_nofix', + 'white', + 'curv', + 'area', + 'cortex', + 'pial_auto', + 'thickness', + 'smoothwm', + 'sulc', + 'inflated', + 'white_H', + 'white_K', + 'inflated_H', + 'inflated_K', + 'curv_stats'] hemi_outputspec = pe.Node(IdentityInterface(fields=hemi_outputs), name="outputspec") From cb71b1885a626c253735d16914c7b2e50808d266 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 03:12:14 +0100 Subject: [PATCH 28/56] STY: correction of E251 - unexpected spaces around keyword / parameter equals --- nipype/interfaces/afni/preprocess.py | 76 ++++++++++++------------- nipype/interfaces/petpvc.py | 2 +- nipype/interfaces/tests/test_bids.py | 2 +- nipype/workflows/fmri/fsl/preprocess.py | 4 +- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index 68e870fe5a..6c37b614ca 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -665,44 +665,44 @@ class AutoTLRCInputSpec(CommandLineInputSpec): exists=True, copyfile=False) base = traits.Str( - desc = ' Reference anatomical volume' - ' Usually this volume is in some standard space like' - ' TLRC or MNI space and with afni dataset view of' - ' (+tlrc).' - ' Preferably, this reference volume should have had' - ' the skull removed but that is not mandatory.' - ' AFNI\'s distribution contains several templates.' - ' For a longer list, use "whereami -show_templates"' - 'TT_N27+tlrc --> Single subject, skull stripped volume.' - ' This volume is also known as ' - ' N27_SurfVol_NoSkull+tlrc elsewhere in ' - ' AFNI and SUMA land.' - ' (www.loni.ucla.edu, www.bic.mni.mcgill.ca)' - ' This template has a full set of FreeSurfer' - ' (surfer.nmr.mgh.harvard.edu)' - ' surface models that can be used in SUMA. ' - ' For details, see Talairach-related link:' - ' https://afni.nimh.nih.gov/afni/suma' - 'TT_icbm452+tlrc --> Average volume of 452 normal brains.' - ' Skull Stripped. (www.loni.ucla.edu)' - 'TT_avg152T1+tlrc --> Average volume of 152 normal brains.' - ' Skull Stripped.(www.bic.mni.mcgill.ca)' - 'TT_EPI+tlrc --> EPI template from spm2, masked as TT_avg152T1' - ' TT_avg152 and TT_EPI volume sources are from' - ' SPM\'s distribution. (www.fil.ion.ucl.ac.uk/spm/)' - 'If you do not specify a path for the template, the script' - 'will attempt to locate the template AFNI\'s binaries directory.' - 'NOTE: These datasets have been slightly modified from' - ' their original size to match the standard TLRC' - ' dimensions (Jean Talairach and Pierre Tournoux' - ' Co-Planar Stereotaxic Atlas of the Human Brain' - ' Thieme Medical Publishers, New York, 1988). ' - ' That was done for internal consistency in AFNI.' - ' You may use the original form of these' - ' volumes if you choose but your TLRC coordinates' - ' will not be consistent with AFNI\'s TLRC database' - ' (San Antonio Talairach Daemon database), for example.', - mandatory = True, + desc=' Reference anatomical volume' + ' Usually this volume is in some standard space like' + ' TLRC or MNI space and with afni dataset view of' + ' (+tlrc).' + ' Preferably, this reference volume should have had' + ' the skull removed but that is not mandatory.' + ' AFNI\'s distribution contains several templates.' + ' For a longer list, use "whereami -show_templates"' + 'TT_N27+tlrc --> Single subject, skull stripped volume.' + ' This volume is also known as ' + ' N27_SurfVol_NoSkull+tlrc elsewhere in ' + ' AFNI and SUMA land.' + ' (www.loni.ucla.edu, www.bic.mni.mcgill.ca)' + ' This template has a full set of FreeSurfer' + ' (surfer.nmr.mgh.harvard.edu)' + ' surface models that can be used in SUMA. ' + ' For details, see Talairach-related link:' + ' https://afni.nimh.nih.gov/afni/suma' + 'TT_icbm452+tlrc --> Average volume of 452 normal brains.' + ' Skull Stripped. (www.loni.ucla.edu)' + 'TT_avg152T1+tlrc --> Average volume of 152 normal brains.' + ' Skull Stripped.(www.bic.mni.mcgill.ca)' + 'TT_EPI+tlrc --> EPI template from spm2, masked as TT_avg152T1' + ' TT_avg152 and TT_EPI volume sources are from' + ' SPM\'s distribution. (www.fil.ion.ucl.ac.uk/spm/)' + 'If you do not specify a path for the template, the script' + 'will attempt to locate the template AFNI\'s binaries directory.' + 'NOTE: These datasets have been slightly modified from' + ' their original size to match the standard TLRC' + ' dimensions (Jean Talairach and Pierre Tournoux' + ' Co-Planar Stereotaxic Atlas of the Human Brain' + ' Thieme Medical Publishers, New York, 1988). ' + ' That was done for internal consistency in AFNI.' + ' You may use the original form of these' + ' volumes if you choose but your TLRC coordinates' + ' will not be consistent with AFNI\'s TLRC database' + ' (San Antonio Talairach Daemon database), for example.', + mandatory=True, argstr='-base %s') no_ss = traits.Bool( desc='Do not strip skull of input data set' diff --git a/nipype/interfaces/petpvc.py b/nipype/interfaces/petpvc.py index 8de4cfd162..753de51891 100644 --- a/nipype/interfaces/petpvc.py +++ b/nipype/interfaces/petpvc.py @@ -56,7 +56,7 @@ class PETPVCInputSpec(CommandLineInputSpec): class PETPVCOutputSpec(TraitedSpec): - out_file = File(desc = "Output file") + out_file = File(desc="Output file") class PETPVC(CommandLine): diff --git a/nipype/interfaces/tests/test_bids.py b/nipype/interfaces/tests/test_bids.py index aa5bc6c359..2ba09f5acf 100644 --- a/nipype/interfaces/tests/test_bids.py +++ b/nipype/interfaces/tests/test_bids.py @@ -42,7 +42,7 @@ def test_bids_grabber(tmpdir): reason="Pybids is not installed in editable mode") def test_bids_fields(tmpdir): tmpdir.chdir() - bg = BIDSDataGrabber(infields = ['subject'], outfields = ['dwi']) + bg = BIDSDataGrabber(infields=['subject'], outfields=['dwi']) bg.inputs.base_dir = os.path.join(datadir, 'ds005') bg.inputs.subject = '01' bg.inputs.output_query['dwi'] = dict(modality='dwi') diff --git a/nipype/workflows/fmri/fsl/preprocess.py b/nipype/workflows/fmri/fsl/preprocess.py index aa8ac03673..a4a98def2b 100644 --- a/nipype/workflows/fmri/fsl/preprocess.py +++ b/nipype/workflows/fmri/fsl/preprocess.py @@ -533,7 +533,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle', if whichvol != 'mean': extract_ref = pe.Node(interface=fsl.ExtractROI(t_size=1), iterfield=['in_file'], - name = 'extractref') + name='extractref') featpreproc.connect(img2float, ('out_file', pickrun, whichrun), extract_ref, 'in_file') featpreproc.connect(img2float, ('out_file', pickvol, 0, whichvol), extract_ref, 't_min') featpreproc.connect(extract_ref, 'roi_file', outputnode, 'reference') @@ -572,7 +572,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle', Extract the mean volume of the first functional run """ - meanfunc = pe.Node(interface=fsl.ImageMaths(op_string = '-Tmean', suffix='_mean'), + meanfunc = pe.Node(interface=fsl.ImageMaths(op_string='-Tmean', suffix='_mean'), name='meanfunc') featpreproc.connect(motion_correct, ('out_file', pickrun, whichrun), meanfunc, 'in_file') From 9ed771fc6bfd48ddef1c74efdbcd26d45a015348 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 03:14:06 +0100 Subject: [PATCH 29/56] STY: correction of E221 - multiple spaces before operator --- nipype/interfaces/freesurfer/model.py | 4 ++-- nipype/interfaces/petpvc.py | 20 +++++++++---------- .../interfaces/utility/tests/test_wrappers.py | 2 +- nipype/pipeline/engine/tests/test_engine.py | 2 +- nipype/scripts/utils.py | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/nipype/interfaces/freesurfer/model.py b/nipype/interfaces/freesurfer/model.py index 71de48d786..55d0b5f225 100644 --- a/nipype/interfaces/freesurfer/model.py +++ b/nipype/interfaces/freesurfer/model.py @@ -183,10 +183,10 @@ def run(self, **inputs): def _format_arg(self, name, spec, value): # mris_preproc looks for these files in the surf dir - if name == 'surfreg_files': + if name == 'surfreg_files': basename = os.path.basename(value[0]) return spec.argstr % basename.lstrip('rh.').lstrip('lh.') - if name == "surf_measure_file": + if name == "surf_measure_file": basename = os.path.basename(value) return spec.argstr % basename.lstrip('rh.').lstrip('lh.') return super(MRISPreprocReconAll, self)._format_arg(name, spec, value) diff --git a/nipype/interfaces/petpvc.py b/nipype/interfaces/petpvc.py index 753de51891..6d85282a52 100644 --- a/nipype/interfaces/petpvc.py +++ b/nipype/interfaces/petpvc.py @@ -41,17 +41,17 @@ class PETPVCInputSpec(CommandLineInputSpec): - in_file = File(desc="PET image file", exists=True, mandatory=True, argstr="-i %s") - out_file = File(desc="Output file", genfile=True, hash_files=False, argstr="-o %s") + in_file = File(desc="PET image file", exists=True, mandatory=True, argstr="-i %s") + out_file = File(desc="Output file", genfile=True, hash_files=False, argstr="-o %s") mask_file = File(desc="Mask image file", exists=True, mandatory=True, argstr="-m %s") - pvc = traits.Enum(pvc_methods, desc="Desired PVC method", mandatory=True, argstr="-p %s") - fwhm_x = traits.Float(desc="The full-width at half maximum in mm along x-axis", mandatory=True, argstr="-x %.4f") - fwhm_y = traits.Float(desc="The full-width at half maximum in mm along y-axis", mandatory=True, argstr="-y %.4f") - fwhm_z = traits.Float(desc="The full-width at half maximum in mm along z-axis", mandatory=True, argstr="-z %.4f") - debug = traits.Bool(desc="Prints debug information", usedefault=True, default_value=False, argstr="-d") - n_iter = traits.Int(desc="Number of iterations", default_value=10, argstr="-n %d") - n_deconv = traits.Int(desc="Number of deconvolution iterations", default_value=10, argstr="-k %d") - alpha = traits.Float(desc="Alpha value", default_value=1.5, argstr="-a %.4f") + pvc = traits.Enum(pvc_methods, desc="Desired PVC method", mandatory=True, argstr="-p %s") + fwhm_x = traits.Float(desc="The full-width at half maximum in mm along x-axis", mandatory=True, argstr="-x %.4f") + fwhm_y = traits.Float(desc="The full-width at half maximum in mm along y-axis", mandatory=True, argstr="-y %.4f") + fwhm_z = traits.Float(desc="The full-width at half maximum in mm along z-axis", mandatory=True, argstr="-z %.4f") + debug = traits.Bool(desc="Prints debug information", usedefault=True, default_value=False, argstr="-d") + n_iter = traits.Int(desc="Number of iterations", default_value=10, argstr="-n %d") + n_deconv = traits.Int(desc="Number of deconvolution iterations", default_value=10, argstr="-k %d") + alpha = traits.Float(desc="Alpha value", default_value=1.5, argstr="-a %.4f") stop_crit = traits.Float(desc="Stopping criterion", default_value=0.01, argstr="-a %.4f") diff --git a/nipype/interfaces/utility/tests/test_wrappers.py b/nipype/interfaces/utility/tests/test_wrappers.py index b995dc27ad..e8aa537413 100644 --- a/nipype/interfaces/utility/tests/test_wrappers.py +++ b/nipype/interfaces/utility/tests/test_wrappers.py @@ -93,7 +93,7 @@ def _inc(x): return x + 1 params = pe.Node(utility.IdentityInterface(fields=['size', 'num']), name='params') - params.inputs.num = 42 + params.inputs.num = 42 params.inputs.size = 1 gen_tuple = pe.Node(utility.Function(input_names=['size'], diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py index c7b6c2f35a..400293d4f9 100644 --- a/nipype/pipeline/engine/tests/test_engine.py +++ b/nipype/pipeline/engine/tests/test_engine.py @@ -472,7 +472,7 @@ def double_func(x): double_node = MapNode(double, name="double", iterfield=["x"]) double_node.inputs.x = x_inp - res = double_node.run() + res = double_node.run() assert res.outputs.f_x == f_exp diff --git a/nipype/scripts/utils.py b/nipype/scripts/utils.py index e35f4d464e..99e9665291 100644 --- a/nipype/scripts/utils.py +++ b/nipype/scripts/utils.py @@ -20,7 +20,7 @@ ignore_unknown_options=True) # specification of existing ParamTypes -ExistingDirPath = click.Path(exists=True, file_okay=False, resolve_path=True) +ExistingDirPath = click.Path(exists=True, file_okay=False, resolve_path=True) ExistingFilePath = click.Path(exists=True, dir_okay=False, resolve_path=True) UnexistingFilePath = click.Path(dir_okay=False, resolve_path=True) From 70681c0a5a4b05ad3e0ce83a745a637c2d877e3c Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 03:17:06 +0100 Subject: [PATCH 30/56] STY: correction of E502 - the backslash is redundant between brackets --- nipype/algorithms/confounds.py | 8 ++++---- nipype/interfaces/ants/tests/test_resampling.py | 2 +- nipype/interfaces/io.py | 16 ++++++++-------- nipype/utils/draw_gantt_chart.py | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/nipype/algorithms/confounds.py b/nipype/algorithms/confounds.py index 4bb0ddeac6..9199871a17 100644 --- a/nipype/algorithms/confounds.py +++ b/nipype/algorithms/confounds.py @@ -58,10 +58,10 @@ class ComputeDVARSInputSpec(BaseInterfaceInputSpec): 'by the median calculated across all voxels' 'and timepoints within the mask (if specified)' 'and then multiply by the value specified by' - 'this parameter. By using the default (1000)' \ - 'output DVARS will be expressed in ' \ - 'x10 % BOLD units compatible with Power et al.' \ - '2012. Set this to 0 to disable intensity' \ + 'this parameter. By using the default (1000)' + 'output DVARS will be expressed in ' + 'x10 % BOLD units compatible with Power et al.' + '2012. Set this to 0 to disable intensity' 'normalization altogether.') diff --git a/nipype/interfaces/ants/tests/test_resampling.py b/nipype/interfaces/ants/tests/test_resampling.py index c51d497794..e4d0f5ddb1 100644 --- a/nipype/interfaces/ants/tests/test_resampling.py +++ b/nipype/interfaces/ants/tests/test_resampling.py @@ -24,7 +24,7 @@ def create_wimt(): wimt = WarpImageMultiTransform() wimt.inputs.input_image = 'diffusion_weighted.nii' wimt.inputs.reference_image = 'functional.nii' - wimt.inputs.transformation_series = ['func2anat_coreg_Affine.txt','func2anat_InverseWarp.nii.gz', \ + wimt.inputs.transformation_series = ['func2anat_coreg_Affine.txt','func2anat_InverseWarp.nii.gz', 'dwi2anat_Warp.nii.gz','dwi2anat_coreg_Affine.txt'] return wimt diff --git a/nipype/interfaces/io.py b/nipype/interfaces/io.py index 0793b955bd..6265836053 100644 --- a/nipype/interfaces/io.py +++ b/nipype/interfaces/io.py @@ -190,8 +190,8 @@ class DataSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): 'it with')) regexp_substitutions = \ InputMultiPath(traits.Tuple(Str, Str), - desc=('List of 2-tuples reflecting a pair of a '\ - 'Python regexp pattern and a replacement '\ + desc=('List of 2-tuples reflecting a pair of a ' + 'Python regexp pattern and a replacement ' 'string. Invoked after string `substitutions`')) _outputs = traits.Dict(Str, value={}, usedefault=True) @@ -199,11 +199,11 @@ class DataSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): desc='remove dest directory when copying dirs') # AWS S3 data attributes - creds_path = Str(desc='Filepath to AWS credentials file for S3 bucket '\ - 'access; if not specified, the credentials will '\ - 'be taken from the AWS_ACCESS_KEY_ID and '\ + creds_path = Str(desc='Filepath to AWS credentials file for S3 bucket ' + 'access; if not specified, the credentials will ' + 'be taken from the AWS_ACCESS_KEY_ID and ' 'AWS_SECRET_ACCESS_KEY environment variables') - encrypt_bucket_keys = traits.Bool(desc='Flag indicating whether to use S3 '\ + encrypt_bucket_keys = traits.Bool(desc='Flag indicating whether to use S3 ' 'server-side AES-256 encryption') # Set this if user wishes to override the bucket with their own bucket = traits.Any(desc='Boto3 S3 bucket for manual override of bucket') @@ -588,7 +588,7 @@ def _upload_to_s3(self, bucket, src, dst): for root, dirs, files in os.walk(src): src_files.extend([os.path.join(root, fil) for fil in files]) # Make the dst files have the dst folder as base dir - dst_files = [os.path.join(dst, src_f.split(src)[1]) \ + dst_files = [os.path.join(dst, src_f.split(src)[1]) for src_f in src_files] else: src_files = [src] @@ -669,7 +669,7 @@ def _list_outputs(self): 's3_datasink_' + bucket_name) outdir = local_out_exception # Log local copying directory - iflogger.info('Access to S3 failed! Storing outputs locally at: '\ + iflogger.info('Access to S3 failed! Storing outputs locally at: ' '%s\nError: %s', outdir, exc) else: s3dir = '' diff --git a/nipype/utils/draw_gantt_chart.py b/nipype/utils/draw_gantt_chart.py index fc78f49ea5..1a35b66b22 100644 --- a/nipype/utils/draw_gantt_chart.py +++ b/nipype/utils/draw_gantt_chart.py @@ -22,7 +22,7 @@ try: import pandas as pd except ImportError: - print('Pandas not found; in order for full functionality of this module '\ + print('Pandas not found; in order for full functionality of this module ' 'install the pandas package') pass @@ -248,7 +248,7 @@ def draw_nodes(start, nodes_list, cores, minute_scale, space_between_minutes, scale = space_between_minutes / minute_scale space_between_minutes = space_between_minutes / scale end_times = [datetime.datetime(start.year, start.month, start.day, - start.hour, start.minute, start.second) \ + start.hour, start.minute, start.second) for core in range(cores)] # For each node in the pipeline From 6d3a76b4348c96fa5de6b4d615d7b6b0e64d14b5 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 13:13:06 +0100 Subject: [PATCH 31/56] STY: correction of E701 - multiple statements on one line (colon) --- nipype/algorithms/tests/test_compcor.py | 6 ++++-- nipype/algorithms/tests/test_misc.py | 3 ++- nipype/algorithms/tests/test_modelgen.py | 3 ++- .../freesurfer/tests/test_preprocess.py | 12 ++++++++---- .../interfaces/freesurfer/tests/test_utils.py | 18 ++++++++++++------ nipype/interfaces/fsl/tests/test_preprocess.py | 9 ++++++--- nipype/interfaces/nitime/tests/test_nitime.py | 3 ++- nipype/interfaces/spm/tests/test_utils.py | 15 ++++++++++----- nipype/pipeline/engine/tests/test_engine.py | 18 ++++++++++++------ nipype/pipeline/plugins/tests/test_debug.py | 3 ++- nipype/utils/tests/test_functions.py | 3 ++- 11 files changed, 62 insertions(+), 31 deletions(-) diff --git a/nipype/algorithms/tests/test_compcor.py b/nipype/algorithms/tests/test_compcor.py index 455e994f6e..7f716e909a 100644 --- a/nipype/algorithms/tests/test_compcor.py +++ b/nipype/algorithms/tests/test_compcor.py @@ -102,13 +102,15 @@ def test_compcor_bad_input_shapes(self): data_file = utils.save_toy_nii(np.zeros(data_shape), 'temp.nii') interface = CompCor(realigned_file=data_file, mask_files=self.mask_files[0]) - with pytest.raises(ValueError, message="Dimension mismatch"): interface.run() + with pytest.raises(ValueError, message="Dimension mismatch"): + interface.run() def test_tcompcor_bad_input_dim(self): bad_dims = (2, 2, 2) data_file = utils.save_toy_nii(np.zeros(bad_dims), 'temp.nii') interface = TCompCor(realigned_file=data_file) - with pytest.raises(ValueError, message='Not a 4D file'): interface.run() + with pytest.raises(ValueError, message='Not a 4D file'): + interface.run() def test_tcompcor_merge_intersect_masks(self): for method in ['union', 'intersect']: diff --git a/nipype/algorithms/tests/test_misc.py b/nipype/algorithms/tests/test_misc.py index d148ee8ca1..84c70bfe98 100644 --- a/nipype/algorithms/tests/test_misc.py +++ b/nipype/algorithms/tests/test_misc.py @@ -39,7 +39,8 @@ def test_CalculateMedian(create_analyze_pair_file_in_directory): mean = misc.CalculateMedian() - with pytest.raises(TypeError): mean.run() + with pytest.raises(TypeError): + mean.run() mean.inputs.in_files = example_data('ds003_sub-01_mc.nii.gz') eg = mean.run() diff --git a/nipype/algorithms/tests/test_modelgen.py b/nipype/algorithms/tests/test_modelgen.py index f3f7a37aa7..4a45e76c4d 100644 --- a/nipype/algorithms/tests/test_modelgen.py +++ b/nipype/algorithms/tests/test_modelgen.py @@ -24,7 +24,8 @@ def test_modelgen1(tmpdir): s = SpecifyModel() s.inputs.input_units = 'scans' set_output_units = lambda: setattr(s.inputs, 'output_units', 'scans') - with pytest.raises(TraitError): set_output_units() + with pytest.raises(TraitError): + set_output_units() s.inputs.functional_runs = [filename1, filename2] s.inputs.time_repetition = 6 s.inputs.high_pass_filter_cutoff = 128. diff --git a/nipype/interfaces/freesurfer/tests/test_preprocess.py b/nipype/interfaces/freesurfer/tests/test_preprocess.py index 4965329fae..e4ae160d96 100644 --- a/nipype/interfaces/freesurfer/tests/test_preprocess.py +++ b/nipype/interfaces/freesurfer/tests/test_preprocess.py @@ -23,7 +23,8 @@ def test_robustregister(create_files_in_directory): assert reg.cmd == 'mri_robust_register' # test raising error with mandatory args absent - with pytest.raises(ValueError): reg.run() + with pytest.raises(ValueError): + reg.run() # .inputs based parameters setting reg.inputs.source_file = filelist[0] @@ -51,7 +52,8 @@ def test_fitmsparams(create_files_in_directory): assert fit.cmd == 'mri_ms_fitparms' # test raising error with mandatory args absent - with pytest.raises(ValueError): fit.run() + with pytest.raises(ValueError): + fit.run() # .inputs based parameters setting fit.inputs.in_files = filelist @@ -74,7 +76,8 @@ def test_synthesizeflash(create_files_in_directory): assert syn.cmd == 'mri_synthesize' # test raising error with mandatory args absent - with pytest.raises(ValueError): syn.run() + with pytest.raises(ValueError): + syn.run() # .inputs based parameters setting syn.inputs.t1_image = filelist[0] @@ -100,7 +103,8 @@ def test_mandatory_outvol(create_files_in_directory): assert mni.cmd == "mri_nu_correct.mni" # test raising error with mandatory args absent - with pytest.raises(ValueError): mni.cmdline + with pytest.raises(ValueError): + mni.cmdline # test with minimal args mni.inputs.in_file = filelist[0] diff --git a/nipype/interfaces/freesurfer/tests/test_utils.py b/nipype/interfaces/freesurfer/tests/test_utils.py index 054aeb276e..cbee31bb48 100644 --- a/nipype/interfaces/freesurfer/tests/test_utils.py +++ b/nipype/interfaces/freesurfer/tests/test_utils.py @@ -23,7 +23,8 @@ def test_sample2surf(create_files_in_directory_plus_dummy_file): assert s2s.cmd == 'mri_vol2surf' # Test mandatory args exception - with pytest.raises(ValueError): s2s.run() + with pytest.raises(ValueError): + s2s.run() # Create testing files files, cwd = create_files_in_directory_plus_dummy_file @@ -53,7 +54,8 @@ def test_sample2surf(create_files_in_directory_plus_dummy_file): # Test that a 2-tuple range raises an error def set_illegal_range(): s2s.inputs.sampling_range = (.2, .5) - with pytest.raises(TraitError): set_illegal_range() + with pytest.raises(TraitError): + set_illegal_range() @pytest.mark.skipif(fs.no_freesurfer(), reason="freesurfer is not installed") @@ -65,7 +67,8 @@ def test_surfsmooth(create_surf_file_in_directory): assert smooth.cmd == "mri_surf2surf" # Test mandatory args exception - with pytest.raises(ValueError): smooth.run() + with pytest.raises(ValueError): + smooth.run() # Create testing files surf, cwd = create_surf_file_in_directory @@ -97,7 +100,8 @@ def test_surfxfm(create_surf_file_in_directory): assert xfm.cmd == "mri_surf2surf" # Test mandatory args exception - with pytest.raises(ValueError): xfm.run() + with pytest.raises(ValueError): + xfm.run() # Create testing files surf, cwd = create_surf_file_in_directory @@ -128,7 +132,8 @@ def test_surfshots(create_files_in_directory_plus_dummy_file): assert fotos.cmd == "tksurfer" # Test mandatory args exception - with pytest.raises(ValueError): fotos.run() + with pytest.raises(ValueError): + fotos.run() # Create testing files files, cwd = create_files_in_directory_plus_dummy_file @@ -158,7 +163,8 @@ def test_surfshots(create_files_in_directory_plus_dummy_file): try: hold_display = os.environ["DISPLAY"] del os.environ["DISPLAY"] - with pytest.raises(RuntimeError): fotos.run() + with pytest.raises(RuntimeError): + fotos.run() os.environ["DISPLAY"] = hold_display except KeyError: pass diff --git a/nipype/interfaces/fsl/tests/test_preprocess.py b/nipype/interfaces/fsl/tests/test_preprocess.py index e404177e87..cd5f50ac6f 100644 --- a/nipype/interfaces/fsl/tests/test_preprocess.py +++ b/nipype/interfaces/fsl/tests/test_preprocess.py @@ -239,7 +239,8 @@ def test_flirt(setup_flirt): axfm = deepcopy(flirter) axfm.inputs.apply_xfm = True # in_matrix_file or uses_qform must be defined - with pytest.raises(RuntimeError): axfm.cmdline + with pytest.raises(RuntimeError): + axfm.cmdline axfm2 = deepcopy(axfm) # test uses_qform axfm.inputs.uses_qform = True @@ -569,8 +570,10 @@ def test_fugue(setup_fugue, attr, out_file): fugue = fsl.FUGUE() for key, value in attr.items(): - if value == "infile": setattr(fugue.inputs, key, infile) - else: setattr(fugue.inputs, key, value) + if value == "infile": + setattr(fugue.inputs, key, infile) + else: + setattr(fugue.inputs, key, value) res = fugue.run() assert isdefined(getattr(res.outputs,out_file)) diff --git a/nipype/interfaces/nitime/tests/test_nitime.py b/nipype/interfaces/nitime/tests/test_nitime.py index d37fea4f4f..12aff75b3b 100644 --- a/nipype/interfaces/nitime/tests/test_nitime.py +++ b/nipype/interfaces/nitime/tests/test_nitime.py @@ -21,7 +21,8 @@ def test_read_csv(): CA = nitime.CoherenceAnalyzer() CA.inputs.TR = 1.89 # bogus value just to pass traits test CA.inputs.in_file = example_data('fmri_timeseries_nolabels.csv') - with pytest.raises(ValueError): CA._read_csv() + with pytest.raises(ValueError): + CA._read_csv() CA.inputs.in_file = example_data('fmri_timeseries.csv') data, roi_names = CA._read_csv() diff --git a/nipype/interfaces/spm/tests/test_utils.py b/nipype/interfaces/spm/tests/test_utils.py index 43b759717e..a574fb90a7 100644 --- a/nipype/interfaces/spm/tests/test_utils.py +++ b/nipype/interfaces/spm/tests/test_utils.py @@ -50,8 +50,10 @@ def test_reslice(): reslice.inputs.in_file = moving reslice.inputs.space_defining = space_defining assert reslice.inputs.interp == 0 - with pytest.raises(TraitError): reslice.inputs.trait_set(interp='nearest') - with pytest.raises(TraitError): reslice.inputs.trait_set(interp=10) + with pytest.raises(TraitError): + reslice.inputs.trait_set(interp='nearest') + with pytest.raises(TraitError): + reslice.inputs.trait_set(interp=10) reslice.inputs.interp = 1 script = reslice._make_matlab_command(None) outfile = fname_presuffix(moving, prefix='r') @@ -71,8 +73,11 @@ def test_dicom_import(): assert di.inputs.output_dir == './converted_dicom' assert di.inputs.format == 'nii' assert not di.inputs.icedims - with pytest.raises(TraitError): di.inputs.trait_set(output_dir_struct='wrong') - with pytest.raises(TraitError): di.inputs.trait_set(format='FAT') - with pytest.raises(TraitError): di.inputs.trait_set(in_files=['does_sfd_not_32fn_exist.dcm']) + with pytest.raises(TraitError): + di.inputs.trait_set(output_dir_struct='wrong') + with pytest.raises(TraitError): + di.inputs.trait_set(format='FAT') + with pytest.raises(TraitError): + di.inputs.trait_set(in_files=['does_sfd_not_32fn_exist.dcm']) di.inputs.in_files = [dicom] assert di.inputs.in_files == [dicom] diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py index 400293d4f9..cac377917c 100644 --- a/nipype/pipeline/engine/tests/test_engine.py +++ b/nipype/pipeline/engine/tests/test_engine.py @@ -44,7 +44,8 @@ def _list_outputs(self): def test_init(): - with pytest.raises(TypeError): pe.Workflow() + with pytest.raises(TypeError): + pe.Workflow() pipe = pe.Workflow(name='pipe') assert type(pipe._graph) == nx.DiGraph @@ -413,7 +414,8 @@ def test_doubleconnect(): def test_node_init(): - with pytest.raises(Exception): pe.Node() + with pytest.raises(Exception): + pe.Node() try: node = pe.Node(EngineTestInterface, name='test') except IOError: @@ -431,8 +433,10 @@ def test_workflow_add(): w1 = pe.Workflow(name='test') w1.connect(n1, 'a', n2, 'c') for node in [n1, n2, n3]: - with pytest.raises(IOError): w1.add_nodes([node]) - with pytest.raises(IOError): w1.connect([(w1, n2, [('n1.a', 'd')])]) + with pytest.raises(IOError): + w1.add_nodes([node]) + with pytest.raises(IOError): + w1.connect([(w1, n2, [('n1.a', 'd')])]) def test_node_get_output(): @@ -448,13 +452,15 @@ def test_mapnode_iterfield_check(): mod1 = pe.MapNode(EngineTestInterface(), iterfield=['input1'], name='mod1') - with pytest.raises(ValueError): mod1._check_iterfield() + with pytest.raises(ValueError): + mod1._check_iterfield() mod1 = pe.MapNode(EngineTestInterface(), iterfield=['input1', 'input2'], name='mod1') mod1.inputs.input1 = [1, 2] mod1.inputs.input2 = 3 - with pytest.raises(ValueError): mod1._check_iterfield() + with pytest.raises(ValueError): + mod1._check_iterfield() @pytest.mark.parametrize("x_inp, f_exp", [ diff --git a/nipype/pipeline/plugins/tests/test_debug.py b/nipype/pipeline/plugins/tests/test_debug.py index e7997ba7f0..0b6bbc7150 100644 --- a/nipype/pipeline/plugins/tests/test_debug.py +++ b/nipype/pipeline/plugins/tests/test_debug.py @@ -46,7 +46,8 @@ def test_debug(tmpdir): mod1.inputs.input1 = 1 run_wf = lambda: pipe.run(plugin="Debug") - with pytest.raises(ValueError): run_wf() + with pytest.raises(ValueError): + run_wf() exc = None try: diff --git a/nipype/utils/tests/test_functions.py b/nipype/utils/tests/test_functions.py index 1d9b9dac7a..4dfa114ff4 100644 --- a/nipype/utils/tests/test_functions.py +++ b/nipype/utils/tests/test_functions.py @@ -19,7 +19,8 @@ def func1(x): def test_func_to_str_err(): bad_src = "obbledygobbledygook" - with pytest.raises(RuntimeError): create_function_from_source(bad_src) + with pytest.raises(RuntimeError): + create_function_from_source(bad_src) def _print_statement(): try: From d540d54408f80b4ab95d09d8d0bae631eded91d9 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 13:20:28 +0100 Subject: [PATCH 32/56] STY: correction of E203 - whitespace before ':' or ',' --- nipype/info.py | 2 +- nipype/interfaces/io.py | 2 +- nipype/interfaces/tests/test_io.py | 4 +-- nipype/interfaces/utility/tests/test_base.py | 4 +-- nipype/pipeline/plugins/tests/test_tools.py | 6 ++-- nipype/utils/draw_gantt_chart.py | 32 ++++++++++---------- nipype/workflows/smri/freesurfer/utils.py | 26 ++++++++-------- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/nipype/info.py b/nipype/info.py index 8714f99707..6b462e3516 100644 --- a/nipype/info.py +++ b/nipype/info.py @@ -162,7 +162,7 @@ def get_nipype_gitversion(): 'profiler': ['psutil>=5.0'], 'duecredit': ['duecredit'], 'xvfbwrapper': ['xvfbwrapper'], - 'pybids' : ['pybids'] + 'pybids': ['pybids'] # 'mesh': ['mayavi'] # Enable when it works } diff --git a/nipype/interfaces/io.py b/nipype/interfaces/io.py index 6265836053..09bddcf526 100644 --- a/nipype/interfaces/io.py +++ b/nipype/interfaces/io.py @@ -622,7 +622,7 @@ def _upload_to_s3(self, bucket, src, dst): iflogger.info('Uploading %s to S3 bucket, %s, as %s...', src_f, bucket.name, dst_f) if self.inputs.encrypt_bucket_keys: - extra_args = {'ServerSideEncryption' : 'AES256'} + extra_args = {'ServerSideEncryption': 'AES256'} else: extra_args = {} bucket.upload_file(src_f, dst_k, ExtraArgs=extra_args, diff --git a/nipype/interfaces/tests/test_io.py b/nipype/interfaces/tests/test_io.py index e2eb4e3c09..82b2730701 100644 --- a/nipype/interfaces/tests/test_io.py +++ b/nipype/interfaces/tests/test_io.py @@ -420,8 +420,8 @@ def test_jsonsink_input(): @pytest.mark.parametrize("inputs_attributes", [ - {'new_entry' : 'someValue'}, - {'new_entry' : 'someValue', 'test' : 'testInfields'} + {'new_entry': 'someValue'}, + {'new_entry': 'someValue', 'test': 'testInfields'} ]) def test_jsonsink(tmpdir, inputs_attributes): tmpdir.chdir() diff --git a/nipype/interfaces/utility/tests/test_base.py b/nipype/interfaces/utility/tests/test_base.py index 3e66f827d2..058be87885 100644 --- a/nipype/interfaces/utility/tests/test_base.py +++ b/nipype/interfaces/utility/tests/test_base.py @@ -37,8 +37,8 @@ def test_rename(tmpdir): @pytest.mark.parametrize("args, expected", [ - ({} , ([0], [1,2,3])), - ({"squeeze" : True}, (0 , [1,2,3])) + ({}, ([0], [1,2,3])), + ({"squeeze": True}, (0, [1,2,3])) ]) def test_split(tmpdir, args, expected): tmpdir.chdir() diff --git a/nipype/pipeline/plugins/tests/test_tools.py b/nipype/pipeline/plugins/tests/test_tools.py index 479cc773df..def55058f2 100644 --- a/nipype/pipeline/plugins/tests/test_tools.py +++ b/nipype/pipeline/plugins/tests/test_tools.py @@ -18,9 +18,9 @@ def test_report_crash(): mock_node = mock.MagicMock(name='mock_node') mock_node._id = 'an_id' mock_node.config = { - 'execution' : { - 'crashdump_dir' : '.', - 'crashfile_format' : 'pklz', + 'execution': { + 'crashdump_dir': '.', + 'crashfile_format': 'pklz', } } diff --git a/nipype/utils/draw_gantt_chart.py b/nipype/utils/draw_gantt_chart.py index 1a35b66b22..ee62c6250a 100644 --- a/nipype/utils/draw_gantt_chart.py +++ b/nipype/utils/draw_gantt_chart.py @@ -283,14 +283,14 @@ def draw_nodes(start, nodes_list, cores, minute_scale, space_between_minutes, color = 'red' # Setup dictionary for node html string insertion - node_dict = {'left' : left, - 'offset' : offset, - 'scale_duration' : scale_duration, - 'color' : color, - 'node_name' : node['name'], - 'node_dur' : node['duration'] / 60.0, - 'node_start' : node_start.strftime("%Y-%m-%d %H:%M:%S"), - 'node_finish' : node_finish.strftime("%Y-%m-%d %H:%M:%S")} + node_dict = {'left': left, + 'offset': offset, + 'scale_duration': scale_duration, + 'color': color, + 'node_name': node['name'], + 'node_dur': node['duration'] / 60.0, + 'node_start': node_start.strftime("%Y-%m-%d %H:%M:%S"), + 'node_finish': node_finish.strftime("%Y-%m-%d %H:%M:%S")} # Create new node string new_node = "
Date: Sat, 6 Jan 2018 13:27:47 +0100 Subject: [PATCH 33/56] STY: correction of E261 - at least two spaces before inline comment --- examples/fmri_fsl_reuse.py | 14 +++++++------- examples/fmri_spm_dartel.py | 18 +++++++++--------- nipype/algorithms/confounds.py | 6 +++--- nipype/algorithms/tests/test_compcor.py | 4 ++-- nipype/algorithms/tests/test_tsnr.py | 2 +- nipype/interfaces/dcm2nii.py | 2 +- nipype/interfaces/freesurfer/utils.py | 6 +++--- nipype/interfaces/fsl/tests/test_base.py | 8 ++++---- nipype/interfaces/nilearn.py | 12 ++++++------ nipype/interfaces/tests/test_nilearn.py | 2 +- nipype/pipeline/engine/tests/test_engine.py | 16 ++++++++-------- nipype/pipeline/engine/workflows.py | 12 ++++++------ nipype/pipeline/plugins/tests/test_tools.py | 2 +- nipype/sphinxext/plot_workflow.py | 2 +- .../workflows/rsfmri/fsl/tests/test_resting.py | 2 +- nipype/workflows/smri/freesurfer/autorecon2.py | 2 +- nipype/workflows/smri/freesurfer/recon.py | 4 ++-- tools/run_examples.py | 2 +- 18 files changed, 58 insertions(+), 58 deletions(-) diff --git a/examples/fmri_fsl_reuse.py b/examples/fmri_fsl_reuse.py index beb09f0345..85c2c7f2c8 100755 --- a/examples/fmri_fsl_reuse.py +++ b/examples/fmri_fsl_reuse.py @@ -20,13 +20,13 @@ from builtins import str from builtins import range -import os # system functions -import nipype.interfaces.io as nio # Data i/o -import nipype.interfaces.fsl as fsl # fsl -from nipype.interfaces import utility as niu # Utilities -import nipype.pipeline.engine as pe # pypeline engine -import nipype.algorithms.modelgen as model # model generation -import nipype.algorithms.rapidart as ra # artifact detection +import os # system functions +import nipype.interfaces.io as nio # Data i/o +import nipype.interfaces.fsl as fsl # fsl +from nipype.interfaces import utility as niu # Utilities +import nipype.pipeline.engine as pe # pypeline engine +import nipype.algorithms.modelgen as model # model generation +import nipype.algorithms.rapidart as ra # artifact detection from nipype.workflows.fmri.fsl import (create_featreg_preproc, create_modelfit_workflow, diff --git a/examples/fmri_spm_dartel.py b/examples/fmri_spm_dartel.py index 746da9f810..0246b8a722 100755 --- a/examples/fmri_spm_dartel.py +++ b/examples/fmri_spm_dartel.py @@ -19,15 +19,15 @@ from builtins import str from builtins import range -import nipype.interfaces.io as nio # Data i/o -import nipype.interfaces.spm as spm # spm -import nipype.workflows.fmri.spm as spm_wf # spm -import nipype.interfaces.fsl as fsl # fsl -from nipype.interfaces import utility as niu # Utilities -import nipype.pipeline.engine as pe # pypeline engine -import nipype.algorithms.rapidart as ra # artifact detection -import nipype.algorithms.modelgen as model # model specification -import os # system functions +import nipype.interfaces.io as nio # Data i/o +import nipype.interfaces.spm as spm # spm +import nipype.workflows.fmri.spm as spm_wf # spm +import nipype.interfaces.fsl as fsl # fsl +from nipype.interfaces import utility as niu # Utilities +import nipype.pipeline.engine as pe # pypeline engine +import nipype.algorithms.rapidart as ra # artifact detection +import nipype.algorithms.modelgen as model # model specification +import os # system functions """ diff --git a/nipype/algorithms/confounds.py b/nipype/algorithms/confounds.py index 9199871a17..24db2cc565 100644 --- a/nipype/algorithms/confounds.py +++ b/nipype/algorithms/confounds.py @@ -324,7 +324,7 @@ class CompCorInputSpec(BaseInterfaceInputSpec): 'first is the default.')) components_file = traits.Str('components_file.txt', usedefault=True, desc='Filename to store physiological components') - num_components = traits.Int(6, usedefault=True) # 6 for BOLD, 4 for ASL + num_components = traits.Int(6, usedefault=True) # 6 for BOLD, 4 for ASL pre_filter = traits.Enum('polynomial', 'cosine', False, usedefault=True, desc='Detrend time series prior to component ' 'extraction') @@ -929,7 +929,7 @@ def regress_poly(degree, data, remove_mean=True, axis=-1): data = data.reshape((-1, timepoints)) # Generate design matrix - X = np.ones((timepoints, 1)) # quick way to calc degree 0 + X = np.ones((timepoints, 1)) # quick way to calc degree 0 for i in range(degree): polynomial_func = Legendre.basis(i + 1) value_array = np.linspace(-1, 1, timepoints) @@ -943,7 +943,7 @@ def regress_poly(degree, data, remove_mean=True, axis=-1): # Estimation if remove_mean: datahat = X.dot(betas).T - else: # disregard the first layer of X, which is degree 0 + else: # disregard the first layer of X, which is degree 0 datahat = X[:, 1:].dot(betas[1:, ...]).T regressed_data = data - datahat diff --git a/nipype/algorithms/tests/test_compcor.py b/nipype/algorithms/tests/test_compcor.py index 7f716e909a..952d079d37 100644 --- a/nipype/algorithms/tests/test_compcor.py +++ b/nipype/algorithms/tests/test_compcor.py @@ -95,8 +95,8 @@ def test_tcompcor_asymmetric_dim(self): assert nb.load('mask_000.nii.gz').get_data().shape == asymmetric_shape[:3] def test_compcor_bad_input_shapes(self): - shape_less_than = (1, 2, 2, 5) # dim 0 is < dim 0 of self.mask_files (2) - shape_more_than = (3, 3, 3, 5) # dim 0 is > dim 0 of self.mask_files (2) + shape_less_than = (1, 2, 2, 5) # dim 0 is < dim 0 of self.mask_files (2) + shape_more_than = (3, 3, 3, 5) # dim 0 is > dim 0 of self.mask_files (2) for data_shape in (shape_less_than, shape_more_than): data_file = utils.save_toy_nii(np.zeros(data_shape), 'temp.nii') diff --git a/nipype/algorithms/tests/test_tsnr.py b/nipype/algorithms/tests/test_tsnr.py index f4bac9a17d..e78da27606 100644 --- a/nipype/algorithms/tests/test_tsnr.py +++ b/nipype/algorithms/tests/test_tsnr.py @@ -20,7 +20,7 @@ class TestTSNR(): 'in_file': 'tsnrinfile.nii', } - out_filenames = {# default output file names + out_filenames = { # default output file names 'detrended_file': 'detrend.nii.gz', 'mean_file': 'mean.nii.gz', 'stddev_file': 'stdev.nii.gz', diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 88ed4b1f52..5fb2b6480e 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -303,7 +303,7 @@ def _parse_stdout(self, stdout): for line in stdout.split("\n"): if not skip: out_file = None - if line.startswith("Convert "): # output + if line.startswith("Convert "): # output fname = str(re.search('\S+/\S+', line).group(0)) if isdefined(self.inputs.output_dir): output_dir = self.inputs.output_dir diff --git a/nipype/interfaces/freesurfer/utils.py b/nipype/interfaces/freesurfer/utils.py index ca9130122e..28c2aecc46 100644 --- a/nipype/interfaces/freesurfer/utils.py +++ b/nipype/interfaces/freesurfer/utils.py @@ -49,13 +49,13 @@ def copy2subjdir(cls, in_file, folder=None, basename=None, subject_id=None): if isdefined(cls.inputs.subjects_dir): subjects_dir = cls.inputs.subjects_dir else: - subjects_dir = os.getcwd() # if not use cwd + subjects_dir = os.getcwd() # if not use cwd # check for subject_id if not subject_id: if isdefined(cls.inputs.subject_id): subject_id = cls.inputs.subject_id else: - subject_id = 'subject_id' # default + subject_id = 'subject_id' # default # check for basename if basename is None: basename = os.path.basename(in_file) @@ -2114,7 +2114,7 @@ def _format_arg(self, name, spec, value): else: prefix = basename if prefix == 'aseg': - return # aseg is already the default + return # aseg is already the default return spec.argstr % prefix elif name in ['orig_white', 'orig_pial']: # these inputs do take full file paths or even basenames diff --git a/nipype/interfaces/fsl/tests/test_base.py b/nipype/interfaces/fsl/tests/test_base.py index 916f8e7826..f3d844bbf6 100644 --- a/nipype/interfaces/fsl/tests/test_base.py +++ b/nipype/interfaces/fsl/tests/test_base.py @@ -61,11 +61,11 @@ def test_FSLCommand2(): @pytest.mark.skipif(no_fsl(), reason="fsl is not installed") @pytest.mark.parametrize("args, desired_name", - [({}, {"file": 'foo.nii.gz'}), # just the filename - ({"suffix": '_brain'}, {"file": 'foo_brain.nii.gz'}), # filename with suffix + [({}, {"file": 'foo.nii.gz'}), # just the filename + ({"suffix": '_brain'}, {"file": 'foo_brain.nii.gz'}), # filename with suffix ({"suffix": '_brain', "cwd": '/data'}, - {"dir": '/data', "file": 'foo_brain.nii.gz'}), # filename with suffix and working directory - ({"suffix": '_brain.mat', "change_ext": False}, {"file": 'foo_brain.mat'}) # filename with suffix and no file extension change + {"dir": '/data', "file": 'foo_brain.nii.gz'}), # filename with suffix and working directory + ({"suffix": '_brain.mat', "change_ext": False}, {"file": 'foo_brain.mat'}s) # filename with suffix and no file extension change ]) def test_gen_fname(args, desired_name): # Test _gen_fname method of FSLCommand diff --git a/nipype/interfaces/nilearn.py b/nipype/interfaces/nilearn.py index db47b57e8b..29c6048133 100644 --- a/nipype/interfaces/nilearn.py +++ b/nipype/interfaces/nilearn.py @@ -100,15 +100,15 @@ def _process_inputs(self): maskers = [] # determine form of label files, choose appropriate nilearn masker - if np.amax(label_data.get_data()) > 1: # 3d label file + if np.amax(label_data.get_data()) > 1: # 3d label file n_labels = np.amax(label_data.get_data()) maskers.append(nl.NiftiLabelsMasker(label_data)) - else: # 4d labels + else: # 4d labels n_labels = label_data.get_data().shape[3] - if self.inputs.incl_shared_variance: # 4d labels, independent computation + if self.inputs.incl_shared_variance: # 4d labels, independent computation for img in nli.iter_img(label_data): maskers.append(nl.NiftiMapsMasker(self._4d(img.get_data(), img.affine))) - else: # 4d labels, one computation fitting all + else: # 4d labels, one computation fitting all maskers.append(nl.NiftiMapsMasker(label_data)) # check label list size @@ -124,8 +124,8 @@ def _process_inputs(self): self.inputs.label_files)) if self.inputs.include_global: - global_label_data = label_data.get_data().sum(axis=3) # sum across all regions - global_label_data = np.rint(global_label_data).astype(int).clip(0, 1) # binarize + global_label_data = label_data.get_data().sum(axis=3) # sum across all regions + global_label_data = np.rint(global_label_data).astype(int).clip(0, 1) # binarize global_label_data = self._4d(global_label_data, label_data.affine) global_masker = nl.NiftiLabelsMasker(global_label_data, detrend=self.inputs.detrend) maskers.insert(0, global_masker) diff --git a/nipype/interfaces/tests/test_nilearn.py b/nipype/interfaces/tests/test_nilearn.py index ce3846a6d3..7d06c59834 100644 --- a/nipype/interfaces/tests/test_nilearn.py +++ b/nipype/interfaces/tests/test_nilearn.py @@ -140,7 +140,7 @@ def _test_4d_label(self, wanted, fake_labels, include_global=False, incl_shared_ def assert_expected_output(self, labels, wanted): with open(self.filenames['out_file'], 'r') as output: got = [line.split() for line in output] - labels_got = got.pop(0) # remove header + labels_got = got.pop(0) # remove header assert labels_got == labels assert len(got) == self.fake_fmri_data.shape[3],'num rows and num volumes' # convert from string to float diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py index cac377917c..b267567345 100644 --- a/nipype/pipeline/engine/tests/test_engine.py +++ b/nipype/pipeline/engine/tests/test_engine.py @@ -76,8 +76,8 @@ def test_add_nodes(): # ensure that all connections are tested later @pytest.mark.parametrize("iterables, expected", [ - ({"1": None}, (1,0)), # test1 - ({"1": dict(input1=lambda: [1, 2], input2=lambda: [1, 2])}, (4,0)) # test2 + ({"1": None}, (1,0)), # test1 + ({"1": dict(input1=lambda: [1, 2], input2=lambda: [1, 2])}, (4,0)) # test2 ]) def test_1mod(iterables, expected): pipe = pe.Workflow(name='pipe') @@ -91,9 +91,9 @@ def test_1mod(iterables, expected): @pytest.mark.parametrize("iterables, expected", [ - ({"1": {}, "2": dict(input1=lambda: [1, 2])}, (3,2)), # test3 - ({"1": dict(input1=lambda: [1, 2]), "2": {}}, (4,2)), # test4 - ({"1": dict(input1=lambda: [1, 2]), "2": dict(input1=lambda: [1, 2])}, (6,4)) # test5 + ({"1": {}, "2": dict(input1=lambda: [1, 2])}, (3,2)), # test3 + ({"1": dict(input1=lambda: [1, 2]), "2": {}}, (4,2)), # test4 + ({"1": dict(input1=lambda: [1, 2]), "2": dict(input1=lambda: [1, 2])}, (6,4)) # test5 ]) def test_2mods(iterables, expected): pipe = pe.Workflow(name='pipe') @@ -109,10 +109,10 @@ def test_2mods(iterables, expected): @pytest.mark.parametrize("iterables, expected, connect", [ - ({"1": {}, "2": dict(input1=lambda: [1, 2]), "3": {}}, (5,4), ("1-2","2-3")), # test6 - ({"1": dict(input1=lambda: [1, 2]), "2": {}, "3": {}}, (5,4), ("1-3","2-3")), # test7 + ({"1": {}, "2": dict(input1=lambda: [1, 2]), "3": {}}, (5,4), ("1-2","2-3")), # test6 + ({"1": dict(input1=lambda: [1, 2]), "2": {}, "3": {}}, (5,4), ("1-3","2-3")), # test7 ({"1": dict(input1=lambda: [1, 2]), "2": dict(input1=lambda: [1, 2]), "3": {}}, - (8,8), ("1-3","2-3")), # test8 + (8,8), ("1-3","2-3")), # test8 ]) def test_3mods(iterables, expected, connect): pipe = pe.Workflow(name='pipe') diff --git a/nipype/pipeline/engine/workflows.py b/nipype/pipeline/engine/workflows.py index f2ad13cddf..192d7e0f0e 100644 --- a/nipype/pipeline/engine/workflows.py +++ b/nipype/pipeline/engine/workflows.py @@ -930,13 +930,13 @@ def _get_dot(self, prefix=None, hierarchy=None, colored=False, prefix = ' ' if hierarchy is None: hierarchy = [] - colorset = ['#FFFFC8', # Y - '#0000FF', '#B4B4FF', '#E6E6FF', # B - '#FF0000', '#FFB4B4', '#FFE6E6', # R - '#00A300', '#B4FFB4', '#E6FFE6', # G - '#0000FF', '#B4B4FF'] # loop B + colorset = ['#FFFFC8', # Y + '#0000FF', '#B4B4FF', '#E6E6FF', # B + '#FF0000', '#FFB4B4', '#FFE6E6', # R + '#00A300', '#B4FFB4', '#E6FFE6', # G + '#0000FF', '#B4B4FF'] # loop B if level > len(colorset) - 2: - level = 3 # Loop back to blue + level = 3 # Loop back to blue dotlist = ['%slabel="%s";' % (prefix, self.name)] for node in nx.topological_sort(self._graph): diff --git a/nipype/pipeline/plugins/tests/test_tools.py b/nipype/pipeline/plugins/tests/test_tools.py index def55058f2..dcf3faa57f 100644 --- a/nipype/pipeline/plugins/tests/test_tools.py +++ b/nipype/pipeline/plugins/tests/test_tools.py @@ -13,7 +13,7 @@ def test_report_crash(): with mock.patch('pickle.dump', mock.MagicMock()) as mock_pickle_dump: - with mock.patch('nipype.pipeline.plugins.tools.format_exception', mock.MagicMock()): # see iss 1517 + with mock.patch('nipype.pipeline.plugins.tools.format_exception', mock.MagicMock()): # see iss 1517 mock_pickle_dump.return_value = True mock_node = mock.MagicMock(name='mock_node') mock_node._id = 'an_id' diff --git a/nipype/sphinxext/plot_workflow.py b/nipype/sphinxext/plot_workflow.py index 47f369ef75..c5250b7ad5 100644 --- a/nipype/sphinxext/plot_workflow.py +++ b/nipype/sphinxext/plot_workflow.py @@ -623,7 +623,7 @@ def run(arguments, content, options, state_machine, state, lineno): dest_dir = os.path.abspath(os.path.join(setup.app.builder.outdir, source_rel_dir)) if not os.path.exists(dest_dir): - os.makedirs(dest_dir) # no problem here for me, but just use built-ins + os.makedirs(dest_dir) # no problem here for me, but just use built-ins # how to link to files from the RST file dest_dir_link = os.path.join(relpath(setup.confdir, rst_dir), diff --git a/nipype/workflows/rsfmri/fsl/tests/test_resting.py b/nipype/workflows/rsfmri/fsl/tests/test_resting.py index c176d49ed6..39061e6f8c 100644 --- a/nipype/workflows/rsfmri/fsl/tests/test_resting.py +++ b/nipype/workflows/rsfmri/fsl/tests/test_resting.py @@ -23,7 +23,7 @@ def stub_node_factory(*args, **kwargs): name = kwargs['name'] if name == 'compcor': return Node(*args, **kwargs) - else: # replace with an IdentityInterface + else: # replace with an IdentityInterface return Node(IdentityInterface(fields=ALL_FIELDS), name=name) diff --git a/nipype/workflows/smri/freesurfer/autorecon2.py b/nipype/workflows/smri/freesurfer/autorecon2.py index 0812cd1a5f..fee6145709 100644 --- a/nipype/workflows/smri/freesurfer/autorecon2.py +++ b/nipype/workflows/smri/freesurfer/autorecon2.py @@ -18,7 +18,7 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False, ar2_wf = pe.Workflow(name=name) inputspec = pe.Node(IdentityInterface(fields=['orig', - 'nu', # version < 6 + 'nu', # version < 6 'brainmask', 'transform', 'subject_id', diff --git a/nipype/workflows/smri/freesurfer/recon.py b/nipype/workflows/smri/freesurfer/recon.py index eec6856578..909a982d12 100644 --- a/nipype/workflows/smri/freesurfer/recon.py +++ b/nipype/workflows/smri/freesurfer/recon.py @@ -160,7 +160,7 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None): fs_version = 'v6.0' th3 = True shrink = 2 - distance = 200 # 3T should be 50 + distance = 200 # 3T should be 50 stop = 0.0001 exvivo = True entorhinal = True @@ -178,7 +178,7 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None): "set or if you are using an older version of " "FreeSurfer")) else: - fs_version = 5.3 # assume version 5.3 + fs_version = 5.3 # assume version 5.3 th3 = False shrink = None distance = 50 diff --git a/tools/run_examples.py b/tools/run_examples.py index 45f4c8dc4f..6f12d02bcf 100644 --- a/tools/run_examples.py +++ b/tools/run_examples.py @@ -43,7 +43,7 @@ def run_examples(example, pipelines, data_path, plugin=None, rm_base_dir=True): try: wf.inputs.inputnode.in_data = os.path.abspath(data_path) except AttributeError: - pass # the workflow does not have inputnode.in_data + pass # the workflow does not have inputnode.in_data wf.run(plugin=plugin, plugin_args=plugin_args) # run twice to check if nothing is rerunning From ed7db38c99ffa8a798522a38deaabef5562a0a28 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 13:31:01 +0100 Subject: [PATCH 34/56] STY: correction of E111 - indentation is not a multiple of four --- nipype/interfaces/afni/preprocess.py | 2 +- .../interfaces/ants/tests/test_resampling.py | 78 +++++++++---------- nipype/interfaces/dcm2nii.py | 2 +- nipype/interfaces/fsl/model.py | 8 +- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index 6c37b614ca..6a7985ae55 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -1927,7 +1927,7 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None): outputs = self._outputs() output_filename = 'roi_stats.csv' with open(output_filename, 'w') as f: - f.write(runtime.stdout) + f.write(runtime.stdout) outputs.stats = os.path.abspath(output_filename) return outputs diff --git a/nipype/interfaces/ants/tests/test_resampling.py b/nipype/interfaces/ants/tests/test_resampling.py index e4d0f5ddb1..cc9feff8bb 100644 --- a/nipype/interfaces/ants/tests/test_resampling.py +++ b/nipype/interfaces/ants/tests/test_resampling.py @@ -8,76 +8,76 @@ @pytest.fixture() def change_dir(request): - orig_dir = os.getcwd() - filepath = os.path.dirname(os.path.realpath(__file__)) - datadir = os.path.realpath(os.path.join(filepath, '../../../testing/data')) - os.chdir(datadir) + orig_dir = os.getcwd() + filepath = os.path.dirname(os.path.realpath(__file__)) + datadir = os.path.realpath(os.path.join(filepath, '../../../testing/data')) + os.chdir(datadir) - def move2orig(): - os.chdir(orig_dir) + def move2orig(): + os.chdir(orig_dir) - request.addfinalizer(move2orig) + request.addfinalizer(move2orig) @pytest.fixture() def create_wimt(): - wimt = WarpImageMultiTransform() - wimt.inputs.input_image = 'diffusion_weighted.nii' - wimt.inputs.reference_image = 'functional.nii' - wimt.inputs.transformation_series = ['func2anat_coreg_Affine.txt','func2anat_InverseWarp.nii.gz', - 'dwi2anat_Warp.nii.gz','dwi2anat_coreg_Affine.txt'] - return wimt + wimt = WarpImageMultiTransform() + wimt.inputs.input_image = 'diffusion_weighted.nii' + wimt.inputs.reference_image = 'functional.nii' + wimt.inputs.transformation_series = ['func2anat_coreg_Affine.txt','func2anat_InverseWarp.nii.gz', + 'dwi2anat_Warp.nii.gz','dwi2anat_coreg_Affine.txt'] + return wimt def test_WarpImageMultiTransform(change_dir, create_wimt): - wimt = create_wimt - assert wimt.cmdline == 'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii \ + wimt = create_wimt + assert wimt.cmdline == 'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii \ func2anat_coreg_Affine.txt func2anat_InverseWarp.nii.gz dwi2anat_Warp.nii.gz dwi2anat_coreg_Affine.txt' def test_WarpImageMultiTransform_invaffine_1(change_dir, create_wimt): - wimt = create_wimt - wimt.inputs.invert_affine = [1] - assert wimt.cmdline == 'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii \ + wimt = create_wimt + wimt.inputs.invert_affine = [1] + assert wimt.cmdline == 'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii \ -i func2anat_coreg_Affine.txt func2anat_InverseWarp.nii.gz dwi2anat_Warp.nii.gz dwi2anat_coreg_Affine.txt' def test_WarpImageMultiTransform_invaffine_2(change_dir, create_wimt): - wimt = create_wimt - wimt.inputs.invert_affine = [2] - assert wimt.cmdline == 'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii func2anat_coreg_Affine.txt func2anat_InverseWarp.nii.gz dwi2anat_Warp.nii.gz -i dwi2anat_coreg_Affine.txt' + wimt = create_wimt + wimt.inputs.invert_affine = [2] + assert wimt.cmdline == 'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii func2anat_coreg_Affine.txt func2anat_InverseWarp.nii.gz dwi2anat_Warp.nii.gz -i dwi2anat_coreg_Affine.txt' def test_WarpImageMultiTransform_invaffine_wrong(change_dir, create_wimt): - wimt = create_wimt - wimt.inputs.invert_affine = [3] - with pytest.raises(Exception): - assert wimt.cmdline + wimt = create_wimt + wimt.inputs.invert_affine = [3] + with pytest.raises(Exception): + assert wimt.cmdline @pytest.fixture() def create_wtsimt(): - wtsimt = WarpTimeSeriesImageMultiTransform() - wtsimt.inputs.input_image = 'resting.nii' - wtsimt.inputs.reference_image = 'ants_deformed.nii.gz' - wtsimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt'] - return wtsimt + wtsimt = WarpTimeSeriesImageMultiTransform() + wtsimt.inputs.input_image = 'resting.nii' + wtsimt.inputs.reference_image = 'ants_deformed.nii.gz' + wtsimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt'] + return wtsimt def test_WarpTimeSeriesImageMultiTransform(change_dir, create_wtsimt): - wtsimt = create_wtsimt - assert wtsimt.cmdline == 'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii \ + wtsimt = create_wtsimt + assert wtsimt.cmdline == 'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii \ -R ants_deformed.nii.gz ants_Warp.nii.gz ants_Affine.txt' def test_WarpTimeSeriesImageMultiTransform_invaffine(change_dir, create_wtsimt): - wtsimt = create_wtsimt - wtsimt.inputs.invert_affine = [1] - assert wtsimt.cmdline == 'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii \ + wtsimt = create_wtsimt + wtsimt.inputs.invert_affine = [1] + assert wtsimt.cmdline == 'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii \ -R ants_deformed.nii.gz ants_Warp.nii.gz -i ants_Affine.txt' def test_WarpTimeSeriesImageMultiTransform_invaffine_wrong(change_dir, create_wtsimt): - wtsimt = create_wtsimt - wtsimt.inputs.invert_affine = [0] - with pytest.raises(Exception): - wtsimt.cmdline + wtsimt = create_wtsimt + wtsimt.inputs.invert_affine = [0] + with pytest.raises(Exception): + wtsimt.cmdline diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 5fb2b6480e..6efc5a161a 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -289,7 +289,7 @@ def _run_interface(self, runtime): (self.output_files, self.bvecs, self.bvals, self.bids) = self._parse_stdout(new_runtime.stdout) else: - (self.output_files, self.bvecs, + (self.output_files, self.bvecs, self.bvals) = self._parse_stdout(new_runtime.stdout) return new_runtime diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py index 9cbee3fd3d..e78a31ae7f 100644 --- a/nipype/interfaces/fsl/model.py +++ b/nipype/interfaces/fsl/model.py @@ -159,13 +159,13 @@ def _create_ev_files( basis_key = "hrf" elif basis_key == "gamma": try: - _ = ev_parameters['gammasigma'] + _ = ev_parameters['gammasigma'] except KeyError: - ev_parameters['gammasigma'] = 3 + ev_parameters['gammasigma'] = 3 try: - _ = ev_parameters['gammadelay'] + _ = ev_parameters['gammadelay'] except KeyError: - ev_parameters['gammadelay'] = 6 + ev_parameters['gammadelay'] = 6 ev_template = load_template('feat_ev_'+basis_key+'.tcl') ev_none = load_template('feat_ev_none.tcl') ev_ortho = load_template('feat_ev_ortho.tcl') From 777985d77152b79661eb2fcc327b6e35fd533c23 Mon Sep 17 00:00:00 2001 From: miykael Date: Sat, 6 Jan 2018 13:39:30 +0100 Subject: [PATCH 35/56] STY: correction of most E265 - block comment should start with '# ' --- nipype/interfaces/dipy/tensors.py | 2 +- nipype/interfaces/freesurfer/preprocess.py | 4 ++-- nipype/interfaces/tests/test_nilearn.py | 2 +- nipype/pipeline/engine/tests/test_join.py | 4 ++-- nipype/pipeline/engine/tests/test_utils.py | 2 +- nipype/sphinxext/plot_workflow.py | 8 ++++---- nipype/utils/draw_gantt_chart.py | 6 +++--- nipype/workflows/smri/freesurfer/autorecon3.py | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/nipype/interfaces/dipy/tensors.py b/nipype/interfaces/dipy/tensors.py index e5518f4ea0..c939523291 100644 --- a/nipype/interfaces/dipy/tensors.py +++ b/nipype/interfaces/dipy/tensors.py @@ -67,7 +67,7 @@ def _run_interface(self, runtime): nb.save(img, out_file) IFLOGGER.info('DTI parameters image saved as %s', out_file) - #FA MD RD and AD + # FA MD RD and AD for metric in ["fa", "md", "rd", "ad"]: data = getattr(ten_fit,metric).astype("float32") out_name = self._gen_filename(metric) diff --git a/nipype/interfaces/freesurfer/preprocess.py b/nipype/interfaces/freesurfer/preprocess.py index 1d209c3022..ff940d26eb 100644 --- a/nipype/interfaces/freesurfer/preprocess.py +++ b/nipype/interfaces/freesurfer/preprocess.py @@ -1964,7 +1964,7 @@ def _list_outputs(self): class CARegisterInputSpec(FSTraitedSpecOpenMP): - #required + # required in_file = File(argstr='%s', exists=True, mandatory=True, position=-3, desc="The input volume for CARegister") out_file = File(argstr='%s', position=-1, @@ -2031,7 +2031,7 @@ def _list_outputs(self): class CALabelInputSpec(FSTraitedSpecOpenMP): - #required + # required in_file = File(argstr="%s", position=-4, mandatory=True, exists=True, desc="Input volume for CALabel") out_file = File(argstr="%s", position=-1, mandatory=True, exists=False, diff --git a/nipype/interfaces/tests/test_nilearn.py b/nipype/interfaces/tests/test_nilearn.py index 7d06c59834..02cbbf0646 100644 --- a/nipype/interfaces/tests/test_nilearn.py +++ b/nipype/interfaces/tests/test_nilearn.py @@ -150,7 +150,7 @@ def assert_expected_output(self, labels, wanted): for j, segment in enumerate(time): npt.assert_almost_equal(segment, wanted[i][j], decimal=1) -#dj: self doesnt have orig_dir at this point, not sure how to change it. should work without it +# dj: self doesnt have orig_dir at this point, not sure how to change it. should work without it # def teardown_class(self): # self.orig_dir.chdir() diff --git a/nipype/pipeline/engine/tests/test_join.py b/nipype/pipeline/engine/tests/test_join.py index 8b8608b248..021833c7ea 100644 --- a/nipype/pipeline/engine/tests/test_join.py +++ b/nipype/pipeline/engine/tests/test_join.py @@ -548,7 +548,7 @@ def test_nested_workflow_join(tmpdir): # Make the nested workflow def nested_wf(i, name='smallwf'): - #iterables with list of nums + # iterables with list of nums inputspec = pe.Node(IdentityInterface(fields=['n']), name='inputspec') inputspec.iterables = [('n', i)] # increment each iterable before joining @@ -559,7 +559,7 @@ def nested_wf(i, name='smallwf'): joinsource='inputspec', joinfield='n', name='join') - #define and connect nested workflow + # define and connect nested workflow wf = pe.Workflow(name='wf_%d' % i[0]) wf.connect(inputspec, 'n', pre_join, 'input1') wf.connect(pre_join, 'output1', join, 'n') diff --git a/nipype/pipeline/engine/tests/test_utils.py b/nipype/pipeline/engine/tests/test_utils.py index 7435bccc85..eb903c6cd2 100644 --- a/nipype/pipeline/engine/tests/test_utils.py +++ b/nipype/pipeline/engine/tests/test_utils.py @@ -375,7 +375,7 @@ def test_mapnode_crash3(tmpdir): wf = pe.Workflow('testmapnodecrash') wf.add_nodes([node]) wf.base_dir = tmpdir.strpath - #changing crashdump dir to cwl (to avoid problems with read-only systems) + # changing crashdump dir to cwl (to avoid problems with read-only systems) wf.config["execution"]["crashdump_dir"] = os.getcwd() with pytest.raises(RuntimeError): wf.run(plugin='Linear') diff --git a/nipype/sphinxext/plot_workflow.py b/nipype/sphinxext/plot_workflow.py index c5250b7ad5..c1498cf122 100644 --- a/nipype/sphinxext/plot_workflow.py +++ b/nipype/sphinxext/plot_workflow.py @@ -273,9 +273,9 @@ def setup(app): return metadata -#------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Doctest handling -#------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ def contains_doctest(text): try: @@ -316,9 +316,9 @@ def remove_coding(text): sub_re = re.compile("^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE) return sub_re.sub("", text) -#------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Template -#------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ TEMPLATE = """ diff --git a/nipype/utils/draw_gantt_chart.py b/nipype/utils/draw_gantt_chart.py index ee62c6250a..0a87c4f793 100644 --- a/nipype/utils/draw_gantt_chart.py +++ b/nipype/utils/draw_gantt_chart.py @@ -423,7 +423,7 @@ def generate_gantt_chart(logfile, cores, minute_scale=10, # generate_gantt_chart('callback.log', 8) ''' - #add the html header + # add the html header html_string = '''