From b5dca7c5b321bedecabf3946d474522a4ec9c7f0 Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Tue, 24 May 2016 16:15:39 -0700 Subject: [PATCH 01/12] small updates to documentation: install, tutorials, make --- Makefile | 7 ++++--- doc/users/install.rst | 18 ++++++++++++------ doc/users/pipeline_tutorial.rst | 27 +++++---------------------- doc/users/tutorial_101.rst | 17 +++++++++++------ 4 files changed, 32 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index d0f6e4a4ce..8c7856e7ca 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,6 @@ sdist: zipdoc python setup.py sdist @echo "Done building source distribution." # XXX copy documentation.zip to dist directory. - # XXX Somewhere the doc/_build directory is removed and causes - # this script to fail. egg: zipdoc @echo "Building egg..." @@ -45,7 +43,10 @@ clean-build: clean-ctags: rm -f tags -clean: clean-build clean-pyc clean-so clean-ctags +clean-doc: + rm -rf doc/_build + +clean: clean-build clean-pyc clean-so clean-ctags clean-doc in: inplace # just a shortcut inplace: diff --git a/doc/users/install.rst b/doc/users/install.rst index c46865ff19..5f96c040c7 100644 --- a/doc/users/install.rst +++ b/doc/users/install.rst @@ -76,8 +76,14 @@ nose_ installed, then do the following:: you can also test with nosetests:: - nosetests --with-doctest /software/nipy-repo/masternipype/nipype - --exclude=external --exclude=testing + nosetests --with-doctest /nipype --exclude=external --exclude=testing + +A successful test run should complete in a few minutes and end with +something like:: + + Ran 13053 tests in 126.618s + + OK (SKIP=66) All tests should pass (unless you're missing a dependency). If SUBJECTS_DIR variable is not set some FreeSurfer related tests will fail. If any tests @@ -89,9 +95,9 @@ tests:: export MATLABCMD=$pathtomatlabdir/bin/$platform/MATLAB -where, $pathtomatlabdir is the path to your matlab installation and -$platform is the directory referring to x86 or x64 installations -(typically glnxa64 on 64-bit installations). +where ``$pathtomatlabdir`` is the path to your matlab installation and +``$platform`` is the directory referring to x86 or x64 installations +(typically ``glnxa64`` on 64-bit installations). Avoiding any MATLAB calls from testing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -119,7 +125,7 @@ Must Have Nibabel_ 1.0 - 1.4 Neuroimaging file i/o library. -Python_ 2.7 +Python_ 2.7 or Python_ 3 NetworkX_ 1.0 - 1.8 Python package for working with complex networks. diff --git a/doc/users/pipeline_tutorial.rst b/doc/users/pipeline_tutorial.rst index 85abf384ed..463c879386 100644 --- a/doc/users/pipeline_tutorial.rst +++ b/doc/users/pipeline_tutorial.rst @@ -59,29 +59,12 @@ Checklist for analysis tutorials For the analysis tutorials, we will be using a slightly modified version of the FBIRN Phase I travelling data set. -Step 0 -~~~~~~ +# Download and extract the `Pipeline tutorial data (429MB). +`_ +(md5: d175083784c5167de4ea11b43b37c166) -Download and extract the `Pipeline tutorial data (429MB). -`_ - -(checksum: 56ed4b7e0aac5627d1724e9c10cd26a7) - - -Step 1. -~~~~~~~ - -Ensure that all programs are available by calling ``bet``, ``matlab`` -and then ``which spm`` within matlab to ensure you have spm5/8 in your +# Ensure that all programs are available by calling ``bet``, ``matlab`` +and then ``which spm`` within matlab to ensure you have spm5/8/12 in your matlab path. -Step 2. -~~~~~~~ - -You can now run the tutorial by typing ``python tutorial_script.py`` -within the nipype-tutorial directory. This will run a full first level -analysis on two subjects following by a 1-sample t-test on their first -level results. The next section goes through each section of the -tutorial script and describes what it is doing. - .. include:: ../links_names.txt diff --git a/doc/users/tutorial_101.rst b/doc/users/tutorial_101.rst index 64b9be2a3c..a6b7a1333e 100644 --- a/doc/users/tutorial_101.rst +++ b/doc/users/tutorial_101.rst @@ -75,7 +75,8 @@ realigner to the smoother in step 5. **3. Creating and configuring a workflow** Here we create an instance of a workflow and indicate that it should operate in -the current directory. +the current directory. The workflow's output will be placed in the ``preproc`` +directory. .. testcode:: @@ -128,11 +129,13 @@ above were generated using this. workflow.write_graph() -This creates two files graph.dot and graph_detailed.dot and if +This creates two files ``graph.dot`` and ``graph_detailed.dot`` inside +``./preproc`` and if graphviz_ is installed on your system it automatically converts it to png files. If graphviz is not installed you can take the dot files and load them in a graphviz visualizer elsewhere. You can specify how detailed -the graph is going to be, by using "graph2use" argument which takes the following +the graph is going to be, by using the ``graph2use`` argument which takes +the following options: * hierarchical - creates a graph showing all embedded workflows (default) @@ -152,9 +155,11 @@ above pipeline. import nipype.algorithms.rapidart as ra artdetect = pe.Node(interface=ra.ArtifactDetect(), name='artdetect') artdetect.inputs.use_differences = [True, False] - art.inputs.use_norm = True - art.inputs.norm_threshold = 0.5 - art.inputs.zintensity_threshold = 3 + artdetect.inputs.use_norm = True + artdetect.inputs.norm_threshold = 0.5 + artdetect.inputs.zintensity_threshold = 3 + artdetect.inputs.parameter_source = "SPM" + artdetect.inputs.mask_type = "spm_global" workflow.connect([(realigner, artdetect, [('realigned_files', 'realigned_files'), ('realignment_parameters','realignment_parameters')] From ac0c5ef1f3a4260e2d796a71afaf13e5c5bab6eb Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Tue, 24 May 2016 16:46:47 -0700 Subject: [PATCH 02/12] minor improvements to error reporting --- nipype/algorithms/rapidart.py | 5 ++++- nipype/interfaces/base.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nipype/algorithms/rapidart.py b/nipype/algorithms/rapidart.py index 06ad009d50..fecf990c73 100644 --- a/nipype/algorithms/rapidart.py +++ b/nipype/algorithms/rapidart.py @@ -362,7 +362,10 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None): nim = funcs.concat_images(images) # compute global intensity signal - (x, y, z, timepoints) = nim.shape + try: + (x, y, z, timepoints) = nim.shape + except ValueError as ve: + raise NipypeInterfaceError(ve, 'Check dimensions of input image; 4-D input required.') data = nim.get_data() affine = nim.affine diff --git a/nipype/interfaces/base.py b/nipype/interfaces/base.py index 16b1c95293..583185f72b 100644 --- a/nipype/interfaces/base.py +++ b/nipype/interfaces/base.py @@ -1056,7 +1056,7 @@ def run(self, **inputs): if config.has_option('logging', 'interface_level') and \ config.get('logging', 'interface_level').lower() == 'debug': - inputs_str = "Inputs:" + str(self.inputs) + "\n" + inputs_str = "\nInputs:" + str(self.inputs) + "\n" else: inputs_str = '' From 58dddfd19ddac68e2b10985bdbd4088680134e97 Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Wed, 25 May 2016 13:44:22 -0700 Subject: [PATCH 03/12] Revert "minor improvements to error reporting" discussion with Chris re: better solution --- nipype/algorithms/rapidart.py | 5 +---- nipype/interfaces/base.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/nipype/algorithms/rapidart.py b/nipype/algorithms/rapidart.py index fecf990c73..06ad009d50 100644 --- a/nipype/algorithms/rapidart.py +++ b/nipype/algorithms/rapidart.py @@ -362,10 +362,7 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None): nim = funcs.concat_images(images) # compute global intensity signal - try: - (x, y, z, timepoints) = nim.shape - except ValueError as ve: - raise NipypeInterfaceError(ve, 'Check dimensions of input image; 4-D input required.') + (x, y, z, timepoints) = nim.shape data = nim.get_data() affine = nim.affine diff --git a/nipype/interfaces/base.py b/nipype/interfaces/base.py index 583185f72b..16b1c95293 100644 --- a/nipype/interfaces/base.py +++ b/nipype/interfaces/base.py @@ -1056,7 +1056,7 @@ def run(self, **inputs): if config.has_option('logging', 'interface_level') and \ config.get('logging', 'interface_level').lower() == 'debug': - inputs_str = "\nInputs:" + str(self.inputs) + "\n" + inputs_str = "Inputs:" + str(self.inputs) + "\n" else: inputs_str = '' From 363ac67f6c5b0b6f3d1522b808ba4ea211ffe4b4 Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Wed, 25 May 2016 17:12:23 -0700 Subject: [PATCH 04/12] use raise_from instead of raise to keep stack trace --- nipype/algorithms/misc.py | 7 ++++--- nipype/external/six.py | 5 +++-- nipype/interfaces/afni/base.py | 5 +++-- nipype/pipeline/plugins/ipython.py | 16 +++++++++------- nipype/pipeline/plugins/ipythonx.py | 11 ++++++----- nipype/testing/utils.py | 10 +++++----- nipype/utils/misc.py | 15 ++++++++------- nipype/utils/spm_docs.py | 5 +++-- .../dmri/connectivity/group_connectivity.py | 8 ++++++-- 9 files changed, 47 insertions(+), 35 deletions(-) diff --git a/nipype/algorithms/misc.py b/nipype/algorithms/misc.py index 1aea8cdbae..c476ed003a 100644 --- a/nipype/algorithms/misc.py +++ b/nipype/algorithms/misc.py @@ -15,6 +15,7 @@ from __future__ import division from builtins import zip from builtins import range +from future.utils import raise_from import os import os.path as op @@ -857,9 +858,9 @@ def __init__(self, infields=None, force_run=True, **kwargs): def _run_interface(self, runtime): try: import pandas as pd - except ImportError: - raise ImportError(('This interface requires pandas ' - '(http://pandas.pydata.org/) to run.')) + except ImportError as e: + raise_from(ImportError('This interface requires pandas ' + '(http://pandas.pydata.org/) to run.'), e) try: import lockfile as pl diff --git a/nipype/external/six.py b/nipype/external/six.py index 876aed3945..9e9e1b6d5b 100644 --- a/nipype/external/six.py +++ b/nipype/external/six.py @@ -21,6 +21,7 @@ # SOFTWARE. from __future__ import absolute_import +from future.utils import raise_from import functools import itertools @@ -186,8 +187,8 @@ def find_module(self, fullname, path=None): def __get_module(self, fullname): try: return self.known_modules[fullname] - except KeyError: - raise ImportError("This loader does not know module " + fullname) + except KeyError as e: + raise_from(ImportError("This loader does not know module " + fullname), e) def load_module(self, fullname): try: diff --git a/nipype/interfaces/afni/base.py b/nipype/interfaces/afni/base.py index 431b024780..3438240741 100644 --- a/nipype/interfaces/afni/base.py +++ b/nipype/interfaces/afni/base.py @@ -5,6 +5,7 @@ import os from sys import platform from builtins import object +from future.utils import raise_from from ... import logging from ...utils.filemanip import split_filename @@ -82,9 +83,9 @@ def outputtype_to_ext(cls, outputtype): try: return cls.ftypes[outputtype] - except KeyError: + except KeyError as e: msg = 'Invalid AFNIOUTPUTTYPE: ', outputtype - raise KeyError(msg) + raise_from(KeyError(msg), e) @classmethod def outputtype(cls): diff --git a/nipype/pipeline/plugins/ipython.py b/nipype/pipeline/plugins/ipython.py index 2ad7ccf1b6..197c1ee68d 100644 --- a/nipype/pipeline/plugins/ipython.py +++ b/nipype/pipeline/plugins/ipython.py @@ -5,6 +5,7 @@ from future import standard_library standard_library.install_aliases() +from future.utils import raise_from from pickle import dumps @@ -63,19 +64,20 @@ def run(self, graph, config, updatehash=False): name = 'ipyparallel' __import__(name) self.iparallel = sys.modules[name] - except ImportError: - raise ImportError("Ipython kernel not found. Parallel execution " - "will be unavailable") + except ImportError as e: + raise_from(ImportError("Ipython kernel not found. Parallel execution " + "will be unavailable"), e) try: self.taskclient = self.iparallel.Client() except Exception as e: if isinstance(e, TimeoutError): - raise Exception("No IPython clients found.") + raise_from(Exception("No IPython clients found."), e) if isinstance(e, IOError): - raise Exception("ipcluster/ipcontroller has not been started") + raise_from(Exception("ipcluster/ipcontroller has not been started"), e) if isinstance(e, ValueError): - raise Exception("Ipython kernel not installed") - raise e + raise_from(Exception("Ipython kernel not installed"), e) + else: + raise e return super(IPythonPlugin, self).run(graph, config, updatehash=updatehash) def _get_result(self, taskid): diff --git a/nipype/pipeline/plugins/ipythonx.py b/nipype/pipeline/plugins/ipythonx.py index 61ffd78fba..b9691277fa 100644 --- a/nipype/pipeline/plugins/ipythonx.py +++ b/nipype/pipeline/plugins/ipythonx.py @@ -4,6 +4,7 @@ """ import sys +from future.utils import raise_from IPython_not_loaded = False try: @@ -36,16 +37,16 @@ def run(self, graph, config, updatehash=False): name = 'IPython.kernel.client' __import__(name) self.ipyclient = sys.modules[name] - except ImportError: - raise ImportError("Ipython kernel not found. Parallel execution " - "will be unavailable") + except ImportError as e: + raise_from(ImportError("Ipython kernel not found. Parallel execution " + "will be unavailable"), e) try: self.taskclient = self.ipyclient.TaskClient() except Exception as e: if isinstance(e, ConnectionRefusedError): - raise Exception("No IPython clients found.") + raise_from(Exception("No IPython clients found."), e) if isinstance(e, ValueError): - raise Exception("Ipython kernel not installed") + raise_from(Exception("Ipython kernel not installed"), e) return super(IPythonXPlugin, self).run(graph, config, updatehash=updatehash) def _get_result(self, taskid): diff --git a/nipype/testing/utils.py b/nipype/testing/utils.py index 2e7404bcc5..abc0362d42 100644 --- a/nipype/testing/utils.py +++ b/nipype/testing/utils.py @@ -12,7 +12,7 @@ from tempfile import mkdtemp from ..utils.misc import package_check from nose import SkipTest - +from future.utils import raise_from def skip_if_no_package(*args, **kwargs): """Raise SkipTest if package_check fails @@ -62,15 +62,15 @@ def __init__(self, size_in_mbytes=8, delay=0.5): try: subprocess.check_call(args=mkfs_args, stdout=self.dev_null, stderr=self.dev_null) - except subprocess.CalledProcessError: - raise IOError("mkfs.vfat failed") + except subprocess.CalledProcessError as e: + raise_from(IOError("mkfs.vfat failed"), e) try: self.fusefat = subprocess.Popen(args=mount_args, stdout=self.dev_null, stderr=self.dev_null) - except OSError: - raise IOError("fusefat is not installed") + except OSError as e: + raise_from(IOError("fusefat is not installed"), e) time.sleep(self.delay) diff --git a/nipype/utils/misc.py b/nipype/utils/misc.py index 0c98900695..8024b3a67d 100644 --- a/nipype/utils/misc.py +++ b/nipype/utils/misc.py @@ -5,6 +5,7 @@ from future import standard_library standard_library.install_aliases() +from future.utils import raise_from from builtins import next from pickle import dumps, loads import inspect @@ -90,14 +91,14 @@ def create_function_from_source(function_source, imports=None): import_keys = list(ns.keys()) exec(function_source, ns) - except Exception as msg: - msg = str(msg) + '\nError executing function:\n %s\n' % function_source + except Exception as e: + msg = '\nError executing function:\n %s\n' % function_source msg += '\n'.join(["Functions in connection strings have to be standalone.", "They cannot be declared either interactively or inside", "another function or inline in the connect string. Any", "imports should be done inside the function" ]) - raise RuntimeError(msg) + raise_from(RuntimeError(msg), e) ns_funcs = list(set(ns) - set(import_keys + ['__builtins__'])) assert len(ns_funcs) == 1, "Function or inputs are ill-defined" funcname = ns_funcs[0] @@ -199,14 +200,14 @@ def package_check(pkg_name, version=None, app=None, checker=LooseVersion, msg += ' with version >= %s' % (version,) try: mod = __import__(pkg_name) - except ImportError: - raise exc_failed_import(msg) + except ImportError as e: + raise_from(exc_failed_import(msg), e) if not version: return try: have_version = mod.__version__ - except AttributeError: - raise exc_failed_check('Cannot find version for %s' % pkg_name) + except AttributeError as e: + raise_from(exc_failed_check('Cannot find version for %s' % pkg_name), e) if checker(have_version) < checker(version): raise exc_failed_check(msg) diff --git a/nipype/utils/spm_docs.py b/nipype/utils/spm_docs.py index dd720e024a..3dd5af528e 100644 --- a/nipype/utils/spm_docs.py +++ b/nipype/utils/spm_docs.py @@ -4,6 +4,7 @@ import os +from future.utils import raise_from from nipype.interfaces import matlab @@ -55,5 +56,5 @@ def _strip_header(doc): except ValueError: index = len(doc) return doc[:index] - except KeyError: - raise IOError('This docstring was not generated by Nipype!\n') + except KeyError as e: + raise_from(IOError('This docstring was not generated by Nipype!\n'), e) diff --git a/nipype/workflows/dmri/connectivity/group_connectivity.py b/nipype/workflows/dmri/connectivity/group_connectivity.py index e4651febd9..d7141c2a82 100644 --- a/nipype/workflows/dmri/connectivity/group_connectivity.py +++ b/nipype/workflows/dmri/connectivity/group_connectivity.py @@ -1,4 +1,8 @@ +asdf;alksjahgldhjgioae + + from __future__ import print_function +from future.utils import raise_from import os.path as op @@ -459,9 +463,9 @@ def create_average_networks_by_group_workflow(group_list, data_dir, subjects_dir try: l4infosource.inputs.group_id1 = list(group_list.keys())[0] l4infosource.inputs.group_id2 = list(group_list.keys())[1] - except IndexError: + except IndexError as e: print('The create_average_networks_by_group_workflow requires 2 groups') - raise Exception + raise_from(Exception(), e) l4info = dict(networks=[['group_id', '']], CMatrices=[['group_id', '']], fibmean=[['group_id', 'mean_fiber_length']], fibdev=[['group_id', 'fiber_length_std']]) From bc28780560e2b6d4f1107a5b1097c46ce89b596f Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Wed, 25 May 2016 18:04:03 -0700 Subject: [PATCH 05/12] removed dependencies section --- doc/users/install.rst | 40 +++++++-------------------------- doc/users/pipeline_tutorial.rst | 4 ++-- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/doc/users/install.rst b/doc/users/install.rst index 5f96c040c7..0d24335970 100644 --- a/doc/users/install.rst +++ b/doc/users/install.rst @@ -25,13 +25,14 @@ or:: git clone https://github.com/nipy/nipype.git +Check out the list of nipype's `current dependencies `_. + Install ------- The installation process is similar to other Python packages. -If you already have a Python environment setup that has the dependencies listed -below, you can do:: +If you already have a Python environment set up, you can do:: easy_install nipype @@ -78,6 +79,10 @@ you can also test with nosetests:: nosetests --with-doctest /nipype --exclude=external --exclude=testing +or:: + + nosetests --with-doctest nipype + A successful test run should complete in a few minutes and end with something like:: @@ -108,38 +113,9 @@ On unix systems, set an empty environment variable:: This will skip any tests that require matlab. -Dependencies +Recommended Software ------------ -Below is a list of required dependencies, along with additional software -recommendations. - -Must Have -~~~~~~~~~ - -.. note:: - - Full distributions of Nipype, such as the ones in Anaconda_ or Canopy_, provide - the following packages automatically. - -Nibabel_ 1.0 - 1.4 - Neuroimaging file i/o library. - -Python_ 2.7 or Python_ 3 - -NetworkX_ 1.0 - 1.8 - Python package for working with complex networks. - -NumPy_ 1.3 - 1.7 - -SciPy_ 0.7 - 0.12 - Numpy and Scipy are high-level, optimized scientific computing libraries. - -Enthought_ Traits_ 4.0.0 - 4.3.0 - -Dateutil 1.5 - - - Strong Recommendations ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/users/pipeline_tutorial.rst b/doc/users/pipeline_tutorial.rst index 463c879386..df550fe6a9 100644 --- a/doc/users/pipeline_tutorial.rst +++ b/doc/users/pipeline_tutorial.rst @@ -59,11 +59,11 @@ Checklist for analysis tutorials For the analysis tutorials, we will be using a slightly modified version of the FBIRN Phase I travelling data set. -# Download and extract the `Pipeline tutorial data (429MB). +1. Download and extract the `Pipeline tutorial data (429MB). `_ (md5: d175083784c5167de4ea11b43b37c166) -# Ensure that all programs are available by calling ``bet``, ``matlab`` +2. Ensure that all programs are available by calling ``bet``, ``matlab`` and then ``which spm`` within matlab to ensure you have spm5/8/12 in your matlab path. From b9ac4e8eb13517e01636f0c3bdd7d533c59b2844 Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Wed, 25 May 2016 18:07:54 -0700 Subject: [PATCH 06/12] Revert "Revert "minor improvements to error reporting"" This reverts commit 58dddfd19ddac68e2b10985bdbd4088680134e97. --- nipype/algorithms/rapidart.py | 5 ++++- nipype/interfaces/base.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nipype/algorithms/rapidart.py b/nipype/algorithms/rapidart.py index 06ad009d50..fecf990c73 100644 --- a/nipype/algorithms/rapidart.py +++ b/nipype/algorithms/rapidart.py @@ -362,7 +362,10 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None): nim = funcs.concat_images(images) # compute global intensity signal - (x, y, z, timepoints) = nim.shape + try: + (x, y, z, timepoints) = nim.shape + except ValueError as ve: + raise NipypeInterfaceError(ve, 'Check dimensions of input image; 4-D input required.') data = nim.get_data() affine = nim.affine diff --git a/nipype/interfaces/base.py b/nipype/interfaces/base.py index 16b1c95293..583185f72b 100644 --- a/nipype/interfaces/base.py +++ b/nipype/interfaces/base.py @@ -1056,7 +1056,7 @@ def run(self, **inputs): if config.has_option('logging', 'interface_level') and \ config.get('logging', 'interface_level').lower() == 'debug': - inputs_str = "Inputs:" + str(self.inputs) + "\n" + inputs_str = "\nInputs:" + str(self.inputs) + "\n" else: inputs_str = '' From 5d22313d7f5e2a14c4e8339d51c9722f7ad74586 Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Wed, 25 May 2016 18:12:05 -0700 Subject: [PATCH 07/12] Revert "Revert "minor improvements to error reporting"" This reverts commit 58dddfd19ddac68e2b10985bdbd4088680134e97. --- nipype/algorithms/rapidart.py | 5 ++++- nipype/interfaces/base.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nipype/algorithms/rapidart.py b/nipype/algorithms/rapidart.py index 06ad009d50..fecf990c73 100644 --- a/nipype/algorithms/rapidart.py +++ b/nipype/algorithms/rapidart.py @@ -362,7 +362,10 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None): nim = funcs.concat_images(images) # compute global intensity signal - (x, y, z, timepoints) = nim.shape + try: + (x, y, z, timepoints) = nim.shape + except ValueError as ve: + raise NipypeInterfaceError(ve, 'Check dimensions of input image; 4-D input required.') data = nim.get_data() affine = nim.affine diff --git a/nipype/interfaces/base.py b/nipype/interfaces/base.py index 16b1c95293..583185f72b 100644 --- a/nipype/interfaces/base.py +++ b/nipype/interfaces/base.py @@ -1056,7 +1056,7 @@ def run(self, **inputs): if config.has_option('logging', 'interface_level') and \ config.get('logging', 'interface_level').lower() == 'debug': - inputs_str = "Inputs:" + str(self.inputs) + "\n" + inputs_str = "\nInputs:" + str(self.inputs) + "\n" else: inputs_str = '' From 31e4e39e76943a0a1aab1232753b01c0a5828746 Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Wed, 25 May 2016 18:21:50 -0700 Subject: [PATCH 08/12] add alt nosetests command --- doc/users/install.rst | 4 ++++ doc/users/pipeline_tutorial.rst | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/users/install.rst b/doc/users/install.rst index 0d24335970..6be7372710 100644 --- a/doc/users/install.rst +++ b/doc/users/install.rst @@ -83,6 +83,10 @@ or:: nosetests --with-doctest nipype +or:: + + nosetests --with-doctest nipype + A successful test run should complete in a few minutes and end with something like:: diff --git a/doc/users/pipeline_tutorial.rst b/doc/users/pipeline_tutorial.rst index df550fe6a9..084860d692 100644 --- a/doc/users/pipeline_tutorial.rst +++ b/doc/users/pipeline_tutorial.rst @@ -49,7 +49,7 @@ Requirements - FSL_, FreeSurfer_, Camino_, ConnectomeViewer and MATLAB_ are available and callable from the command line - - SPM_ 5/8 is installed and callable in matlab + - SPM_ 5/8/12 is installed and callable in matlab - Space: 3-10 GB From c61bcb7e05fc3e19c1bd0d935810891592a49d8f Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Wed, 25 May 2016 18:22:22 -0700 Subject: [PATCH 09/12] Revert "use raise_from instead of raise to keep stack trace" This reverts commit 363ac67f6c5b0b6f3d1522b808ba4ea211ffe4b4. --- nipype/algorithms/misc.py | 7 +++---- nipype/external/six.py | 5 ++--- nipype/interfaces/afni/base.py | 5 ++--- nipype/pipeline/plugins/ipython.py | 16 +++++++--------- nipype/pipeline/plugins/ipythonx.py | 11 +++++------ nipype/testing/utils.py | 10 +++++----- nipype/utils/misc.py | 15 +++++++-------- nipype/utils/spm_docs.py | 5 ++--- .../dmri/connectivity/group_connectivity.py | 8 ++------ 9 files changed, 35 insertions(+), 47 deletions(-) diff --git a/nipype/algorithms/misc.py b/nipype/algorithms/misc.py index c476ed003a..1aea8cdbae 100644 --- a/nipype/algorithms/misc.py +++ b/nipype/algorithms/misc.py @@ -15,7 +15,6 @@ from __future__ import division from builtins import zip from builtins import range -from future.utils import raise_from import os import os.path as op @@ -858,9 +857,9 @@ def __init__(self, infields=None, force_run=True, **kwargs): def _run_interface(self, runtime): try: import pandas as pd - except ImportError as e: - raise_from(ImportError('This interface requires pandas ' - '(http://pandas.pydata.org/) to run.'), e) + except ImportError: + raise ImportError(('This interface requires pandas ' + '(http://pandas.pydata.org/) to run.')) try: import lockfile as pl diff --git a/nipype/external/six.py b/nipype/external/six.py index 9e9e1b6d5b..876aed3945 100644 --- a/nipype/external/six.py +++ b/nipype/external/six.py @@ -21,7 +21,6 @@ # SOFTWARE. from __future__ import absolute_import -from future.utils import raise_from import functools import itertools @@ -187,8 +186,8 @@ def find_module(self, fullname, path=None): def __get_module(self, fullname): try: return self.known_modules[fullname] - except KeyError as e: - raise_from(ImportError("This loader does not know module " + fullname), e) + except KeyError: + raise ImportError("This loader does not know module " + fullname) def load_module(self, fullname): try: diff --git a/nipype/interfaces/afni/base.py b/nipype/interfaces/afni/base.py index 3438240741..431b024780 100644 --- a/nipype/interfaces/afni/base.py +++ b/nipype/interfaces/afni/base.py @@ -5,7 +5,6 @@ import os from sys import platform from builtins import object -from future.utils import raise_from from ... import logging from ...utils.filemanip import split_filename @@ -83,9 +82,9 @@ def outputtype_to_ext(cls, outputtype): try: return cls.ftypes[outputtype] - except KeyError as e: + except KeyError: msg = 'Invalid AFNIOUTPUTTYPE: ', outputtype - raise_from(KeyError(msg), e) + raise KeyError(msg) @classmethod def outputtype(cls): diff --git a/nipype/pipeline/plugins/ipython.py b/nipype/pipeline/plugins/ipython.py index 197c1ee68d..2ad7ccf1b6 100644 --- a/nipype/pipeline/plugins/ipython.py +++ b/nipype/pipeline/plugins/ipython.py @@ -5,7 +5,6 @@ from future import standard_library standard_library.install_aliases() -from future.utils import raise_from from pickle import dumps @@ -64,20 +63,19 @@ def run(self, graph, config, updatehash=False): name = 'ipyparallel' __import__(name) self.iparallel = sys.modules[name] - except ImportError as e: - raise_from(ImportError("Ipython kernel not found. Parallel execution " - "will be unavailable"), e) + except ImportError: + raise ImportError("Ipython kernel not found. Parallel execution " + "will be unavailable") try: self.taskclient = self.iparallel.Client() except Exception as e: if isinstance(e, TimeoutError): - raise_from(Exception("No IPython clients found."), e) + raise Exception("No IPython clients found.") if isinstance(e, IOError): - raise_from(Exception("ipcluster/ipcontroller has not been started"), e) + raise Exception("ipcluster/ipcontroller has not been started") if isinstance(e, ValueError): - raise_from(Exception("Ipython kernel not installed"), e) - else: - raise e + raise Exception("Ipython kernel not installed") + raise e return super(IPythonPlugin, self).run(graph, config, updatehash=updatehash) def _get_result(self, taskid): diff --git a/nipype/pipeline/plugins/ipythonx.py b/nipype/pipeline/plugins/ipythonx.py index b9691277fa..61ffd78fba 100644 --- a/nipype/pipeline/plugins/ipythonx.py +++ b/nipype/pipeline/plugins/ipythonx.py @@ -4,7 +4,6 @@ """ import sys -from future.utils import raise_from IPython_not_loaded = False try: @@ -37,16 +36,16 @@ def run(self, graph, config, updatehash=False): name = 'IPython.kernel.client' __import__(name) self.ipyclient = sys.modules[name] - except ImportError as e: - raise_from(ImportError("Ipython kernel not found. Parallel execution " - "will be unavailable"), e) + except ImportError: + raise ImportError("Ipython kernel not found. Parallel execution " + "will be unavailable") try: self.taskclient = self.ipyclient.TaskClient() except Exception as e: if isinstance(e, ConnectionRefusedError): - raise_from(Exception("No IPython clients found."), e) + raise Exception("No IPython clients found.") if isinstance(e, ValueError): - raise_from(Exception("Ipython kernel not installed"), e) + raise Exception("Ipython kernel not installed") return super(IPythonXPlugin, self).run(graph, config, updatehash=updatehash) def _get_result(self, taskid): diff --git a/nipype/testing/utils.py b/nipype/testing/utils.py index abc0362d42..2e7404bcc5 100644 --- a/nipype/testing/utils.py +++ b/nipype/testing/utils.py @@ -12,7 +12,7 @@ from tempfile import mkdtemp from ..utils.misc import package_check from nose import SkipTest -from future.utils import raise_from + def skip_if_no_package(*args, **kwargs): """Raise SkipTest if package_check fails @@ -62,15 +62,15 @@ def __init__(self, size_in_mbytes=8, delay=0.5): try: subprocess.check_call(args=mkfs_args, stdout=self.dev_null, stderr=self.dev_null) - except subprocess.CalledProcessError as e: - raise_from(IOError("mkfs.vfat failed"), e) + except subprocess.CalledProcessError: + raise IOError("mkfs.vfat failed") try: self.fusefat = subprocess.Popen(args=mount_args, stdout=self.dev_null, stderr=self.dev_null) - except OSError as e: - raise_from(IOError("fusefat is not installed"), e) + except OSError: + raise IOError("fusefat is not installed") time.sleep(self.delay) diff --git a/nipype/utils/misc.py b/nipype/utils/misc.py index 8024b3a67d..0c98900695 100644 --- a/nipype/utils/misc.py +++ b/nipype/utils/misc.py @@ -5,7 +5,6 @@ from future import standard_library standard_library.install_aliases() -from future.utils import raise_from from builtins import next from pickle import dumps, loads import inspect @@ -91,14 +90,14 @@ def create_function_from_source(function_source, imports=None): import_keys = list(ns.keys()) exec(function_source, ns) - except Exception as e: - msg = '\nError executing function:\n %s\n' % function_source + except Exception as msg: + msg = str(msg) + '\nError executing function:\n %s\n' % function_source msg += '\n'.join(["Functions in connection strings have to be standalone.", "They cannot be declared either interactively or inside", "another function or inline in the connect string. Any", "imports should be done inside the function" ]) - raise_from(RuntimeError(msg), e) + raise RuntimeError(msg) ns_funcs = list(set(ns) - set(import_keys + ['__builtins__'])) assert len(ns_funcs) == 1, "Function or inputs are ill-defined" funcname = ns_funcs[0] @@ -200,14 +199,14 @@ def package_check(pkg_name, version=None, app=None, checker=LooseVersion, msg += ' with version >= %s' % (version,) try: mod = __import__(pkg_name) - except ImportError as e: - raise_from(exc_failed_import(msg), e) + except ImportError: + raise exc_failed_import(msg) if not version: return try: have_version = mod.__version__ - except AttributeError as e: - raise_from(exc_failed_check('Cannot find version for %s' % pkg_name), e) + except AttributeError: + raise exc_failed_check('Cannot find version for %s' % pkg_name) if checker(have_version) < checker(version): raise exc_failed_check(msg) diff --git a/nipype/utils/spm_docs.py b/nipype/utils/spm_docs.py index 3dd5af528e..dd720e024a 100644 --- a/nipype/utils/spm_docs.py +++ b/nipype/utils/spm_docs.py @@ -4,7 +4,6 @@ import os -from future.utils import raise_from from nipype.interfaces import matlab @@ -56,5 +55,5 @@ def _strip_header(doc): except ValueError: index = len(doc) return doc[:index] - except KeyError as e: - raise_from(IOError('This docstring was not generated by Nipype!\n'), e) + except KeyError: + raise IOError('This docstring was not generated by Nipype!\n') diff --git a/nipype/workflows/dmri/connectivity/group_connectivity.py b/nipype/workflows/dmri/connectivity/group_connectivity.py index d7141c2a82..e4651febd9 100644 --- a/nipype/workflows/dmri/connectivity/group_connectivity.py +++ b/nipype/workflows/dmri/connectivity/group_connectivity.py @@ -1,8 +1,4 @@ -asdf;alksjahgldhjgioae - - from __future__ import print_function -from future.utils import raise_from import os.path as op @@ -463,9 +459,9 @@ def create_average_networks_by_group_workflow(group_list, data_dir, subjects_dir try: l4infosource.inputs.group_id1 = list(group_list.keys())[0] l4infosource.inputs.group_id2 = list(group_list.keys())[1] - except IndexError as e: + except IndexError: print('The create_average_networks_by_group_workflow requires 2 groups') - raise_from(Exception(), e) + raise Exception l4info = dict(networks=[['group_id', '']], CMatrices=[['group_id', '']], fibmean=[['group_id', 'mean_fiber_length']], fibdev=[['group_id', 'fiber_length_std']]) From d375c2a9918e48699c4184ee936025227e57bdc8 Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Wed, 25 May 2016 18:22:44 -0700 Subject: [PATCH 10/12] Revert "Revert "Revert "minor improvements to error reporting""" This reverts commit 5d22313d7f5e2a14c4e8339d51c9722f7ad74586. --- nipype/algorithms/rapidart.py | 5 +---- nipype/interfaces/base.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/nipype/algorithms/rapidart.py b/nipype/algorithms/rapidart.py index fecf990c73..06ad009d50 100644 --- a/nipype/algorithms/rapidart.py +++ b/nipype/algorithms/rapidart.py @@ -362,10 +362,7 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None): nim = funcs.concat_images(images) # compute global intensity signal - try: - (x, y, z, timepoints) = nim.shape - except ValueError as ve: - raise NipypeInterfaceError(ve, 'Check dimensions of input image; 4-D input required.') + (x, y, z, timepoints) = nim.shape data = nim.get_data() affine = nim.affine diff --git a/nipype/interfaces/base.py b/nipype/interfaces/base.py index 583185f72b..16b1c95293 100644 --- a/nipype/interfaces/base.py +++ b/nipype/interfaces/base.py @@ -1056,7 +1056,7 @@ def run(self, **inputs): if config.has_option('logging', 'interface_level') and \ config.get('logging', 'interface_level').lower() == 'debug': - inputs_str = "\nInputs:" + str(self.inputs) + "\n" + inputs_str = "Inputs:" + str(self.inputs) + "\n" else: inputs_str = '' From 5aefcef2d6efe9ce8fe5d5f3eb35f02425100784 Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Wed, 25 May 2016 18:27:51 -0700 Subject: [PATCH 11/12] little fixes *whistle* --- doc/users/install.rst | 4 ---- nipype/algorithms/rapidart.py | 5 +---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/doc/users/install.rst b/doc/users/install.rst index 6be7372710..0d24335970 100644 --- a/doc/users/install.rst +++ b/doc/users/install.rst @@ -83,10 +83,6 @@ or:: nosetests --with-doctest nipype -or:: - - nosetests --with-doctest nipype - A successful test run should complete in a few minutes and end with something like:: diff --git a/nipype/algorithms/rapidart.py b/nipype/algorithms/rapidart.py index fecf990c73..06ad009d50 100644 --- a/nipype/algorithms/rapidart.py +++ b/nipype/algorithms/rapidart.py @@ -362,10 +362,7 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None): nim = funcs.concat_images(images) # compute global intensity signal - try: - (x, y, z, timepoints) = nim.shape - except ValueError as ve: - raise NipypeInterfaceError(ve, 'Check dimensions of input image; 4-D input required.') + (x, y, z, timepoints) = nim.shape data = nim.get_data() affine = nim.affine From 20d94fddbf4e43b2736a4e01a5c6d3be9d72c5d1 Mon Sep 17 00:00:00 2001 From: Shoshana Berleant Date: Mon, 30 May 2016 20:21:13 -0700 Subject: [PATCH 12/12] change current release link to always point to current release --- doc/users/install.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/users/install.rst b/doc/users/install.rst index 0d24335970..a4af43f927 100644 --- a/doc/users/install.rst +++ b/doc/users/install.rst @@ -9,10 +9,9 @@ This page covers the necessary steps to install Nipype. Download -------- -Release 0.10.0: [`zip `__ `tar.gz -`__] +Current release: ``_. -Development: [`zip `__ `tar.gz +Development version: [`zip `__ `tar.gz `__] `Prior downloads `_