Skip to content

Commit 134a3d4

Browse files
committed
fix: resolved conflicts
2 parents 75b38cb + ff36588 commit 134a3d4

File tree

822 files changed

+3854
-5166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

822 files changed

+3854
-5166
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### Summary
2+
3+
### Actual behavior
4+
5+
### Expected behavior
6+
7+
### How to replicate the behavior
8+
9+
### Platform details:
10+
please paste the output of: `python -c "import nipype; print(nipype.get_info())"`

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ before_install:
1919
if $INSTALL_DEB_DEPENDECIES; then sudo ln -s /run/shm /dev/shm; fi &&
2020
bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh) &&
2121
sudo apt-get -y update &&
22-
sudo apt-get -y install xvfb fusefat &&
22+
sudo apt-get -y install xvfb fusefat graphviz &&
2323
if $INSTALL_DEB_DEPENDECIES; then travis_retry sudo apt-get install -y -qq
2424
fsl afni elastix fsl-atlases; fi &&
2525
if $INSTALL_DEB_DEPENDECIES; then
2626
source /etc/fsl/fsl.sh;
27-
source /etc/afni/afni.sh;
27+
source /etc/afni/afni.sh;
2828
export FSLOUTPUTTYPE=NIFTI_GZ; fi }
2929
- travis_retry bef_inst
3030
install:
@@ -42,7 +42,7 @@ install:
4242
echo "data_file = ${COVERAGE_DATA_FILE}" >> ${COVERAGE_PROCESS_START}; }
4343
- travis_retry inst
4444
script:
45-
- python -W once:FSL:UserWarning:nipype `which nosetests` --with-doctest --with-doctest-ignore-unicode --with-cov --cover-package nipype --logging-level=DEBUG --verbosity=3
45+
- py.test --doctest-modules --cov=nipype nipype
4646
after_success:
4747
- bash <(curl -s https://codecov.io/bash) -t ac172a50-8e66-42e5-8822-5373fcf54686 -cF unittests
4848
deploy:

Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
PYTHON ?= python
66
NOSETESTS=`which nosetests`
77

8-
.PHONY: zipdoc sdist egg upload_to_pypi trailing-spaces clean-pyc clean-so clean-build clean-ctags clean in inplace test-code test-doc test-coverage test html specs check-before-commit check
8+
.PHONY: zipdoc sdist egg upload_to_pypi trailing-spaces clean-pyc clean-so clean-build clean-ctags clean in inplace test-code test-coverage test html specs check-before-commit check
99

1010
zipdoc: html
1111
zip documentation.zip doc/_build/html
@@ -56,16 +56,11 @@ inplace:
5656
$(PYTHON) setup.py build_ext -i
5757

5858
test-code: in
59-
python -W once:FSL:UserWarning:nipype $(NOSETESTS) --with-doctest --with-doctest-ignore-unicode --logging-level=DEBUG --verbosity=3 nipype
60-
61-
test-doc:
62-
$(NOSETESTS) -s --with-doctest --with-doctest-ignore-unicode --doctest-tests --doctest-extension=rst \
63-
--doctest-fixtures=_fixture doc/
59+
py.test --doctest-module nipype
6460

6561
test-coverage: clean-tests in
66-
$(NOSETESTS) -s --with-doctest --with-doctest-ignore-unicode --with-coverage --cover-package=nipype \
67-
--config=.coveragerc
68-
62+
py.test --doctest-modules --cov-config .coveragerc --cov=nipype nipype
63+
6964
test: tests # just another name
7065
tests: clean test-code
7166

circle.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- sudo apt-get -y update && sudo apt-get install -y wget bzip2
2121

2222
override:
23-
- mkdir -p ~/examples ~/scratch/nose ~/scratch/logs
23+
- mkdir -p ~/examples ~/scratch/pytest ~/scratch/logs
2424
- if [[ ! -d ~/examples/nipype-tutorial ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O nipype-tutorial.tar.bz2 "${DATA_NIPYPE_TUTORIAL_URL}" && tar xjf nipype-tutorial.tar.bz2 -C ~/examples/; fi
2525
- if [[ ! -d ~/examples/nipype-fsl_course_data ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O nipype-fsl_course_data.tar.gz "${DATA_NIPYPE_FSL_COURSE}" && tar xzf nipype-fsl_course_data.tar.gz -C ~/examples/; fi
2626
- if [[ ! -d ~/examples/feeds ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O fsl-5.0.9-feeds.tar.gz "${DATA_NIPYPE_FSL_FEEDS}" && tar xzf fsl-5.0.9-feeds.tar.gz -C ~/examples/; fi
@@ -35,10 +35,10 @@ dependencies:
3535
test:
3636
override:
3737
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/scratch:/scratch -w /root/src/nipype/doc nipype/nipype_test:py35 /usr/bin/run_builddocs.sh
38-
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py35 /usr/bin/run_nosetests.sh py35 :
38+
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py35 /usr/bin/run_pytests.sh py35 :
39+
timeout: 2600
40+
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py27 /usr/bin/run_pytests.sh py27 :
3941
timeout: 2600
40-
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py27 /usr/bin/run_nosetests.sh py27 :
41-
timeout: 5200
4242
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh test_spm Linear /root/examples/ workflow3d :
4343
timeout: 1600
4444
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh test_spm Linear /root/examples/ workflow4d :
@@ -49,14 +49,15 @@ test:
4949
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /root/examples/ l2pipeline :
5050
timeout: 1600
5151
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_fsl_reuse Linear /root/examples/ level1_workflow
52-
- docker run -v /etc/localtime:/etc/localtime:ro -e NIPYPE_NUMBER_OF_CPUS=4 -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py27 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /root/examples/ level1
52+
# Disabled until https://github.com/nipy/nipype/issues/1692 is resolved
53+
# - docker run -v /etc/localtime:/etc/localtime:ro -e NIPYPE_NUMBER_OF_CPUS=4 -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py27 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /root/examples/ level1
5354
- docker run -v /etc/localtime:/etc/localtime:ro -e NIPYPE_NUMBER_OF_CPUS=4 -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /root/examples/ level1
5455
- docker run -v /etc/localtime:/etc/localtime:ro -e NIPYPE_NUMBER_OF_CPUS=4 -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /root/examples/ l2pipeline
5556

5657
post:
5758
- bash docker/circleci/teardown.sh
58-
- for xml_f in ${CIRCLE_TEST_REPORTS}/nose/coverage*.xml; do bash <(curl -s https://codecov.io/bash) -f $xml_f -t ac172a50-8e66-42e5-8822-5373fcf54686 -F unittests; done
59-
- for xml_f in ${CIRCLE_TEST_REPORTS}/nose/smoketest*.xml; do bash <(curl -s https://codecov.io/bash) -f $xml_f -t ac172a50-8e66-42e5-8822-5373fcf54686 -F smoketests; done
59+
- for xml_f in ${CIRCLE_TEST_REPORTS}/pytest/coverage*.xml; do bash <(curl -s https://codecov.io/bash) -f $xml_f -t ac172a50-8e66-42e5-8822-5373fcf54686 -F unittests; done
60+
- for xml_f in ${CIRCLE_TEST_REPORTS}/pytest/smoketest*.xml; do bash <(curl -s https://codecov.io/bash) -f $xml_f -t ac172a50-8e66-42e5-8822-5373fcf54686 -F smoketests; done
6061

6162
general:
6263
artifacts:

doc/devel/testing_nipype.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ or::
4040
Test implementation
4141
-------------------
4242

43-
Nipype testing framework is built upon `nose <http://nose.readthedocs.io/en/latest/>`_.
43+
Nipype testing framework is built upon `pytest <http://doc.pytest.org/en/latest/>`_.
4444
By the time these guidelines are written, Nipype implements 17638 tests.
4545

4646
After installation in developer mode, the tests can be run with the
@@ -50,20 +50,18 @@ following simple command at the root folder of the project ::
5050

5151
If ``make`` is not installed in the system, it is possible to run the tests using::
5252

53-
python -W once:FSL:UserWarning:nipype `which nosetests` --with-doctest \
54-
--with-doctest-ignore-unicode --logging-level=DEBUG --verbosity=3 nipype
53+
py.test --doctest-modules --cov=nipype nipype
5554

5655

57-
A successful test run should complete in a few minutes and end with
56+
A successful test run should complete in 10-30 minutes and end with
5857
something like::
5958

6059
----------------------------------------------------------------------
61-
Ran 17922 tests in 107.254s
60+
2445 passed, 41 skipped, 7 xfailed in 1277.66 seconds
6261

63-
OK (SKIP=27)
6462

6563

66-
All tests should pass (unless you're missing a dependency). If the ``SUBJECTS_DIR```
64+
No test should fail (unless you're missing a dependency). If the ``SUBJECTS_DIR```
6765
environment variable is not set, some FreeSurfer related tests will fail.
6866
If any of the tests failed, please report them on our `bug tracker
6967
<http://github.com/nipy/nipype/issues>`_.
@@ -90,6 +88,11 @@ Some tests in Nipype make use of some images distributed within the `FSL course
9088
To enable the tests depending on these data, just unpack the targz file and set the :code:`FSL_COURSE_DATA` environment
9189
variable to point to that folder.
9290

91+
Xfail tests
92+
~~~~~~~~~~
93+
94+
Some tests are expect to fail until the code will be changed or for other reasons.
95+
9396

9497
Avoiding any MATLAB calls from testing
9598
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -115,7 +118,7 @@ Nipype is as easy as follows::
115118
-v ~/examples:/root/examples:ro \
116119
-v ~/scratch:/scratch \
117120
-w /root/src/nipype \
118-
nipype/nipype_test:py27 /usr/bin/run_nosetests.sh
121+
nipype/nipype_test:py27 /usr/bin/run_pytest.sh
119122

120123
For running nipype in Python 3.5::
121124

@@ -126,4 +129,4 @@ For running nipype in Python 3.5::
126129
-v ~/examples:/root/examples:ro \
127130
-v ~/scratch:/scratch \
128131
-w /root/src/nipype \
129-
nipype/nipype_test:py35 /usr/bin/run_nosetests.sh
132+
nipype/nipype_test:py35 /usr/bin/run_pytest.sh

docker/circleci/run_nosetests.sh renamed to docker/circleci/run_pytests.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -u
66
PYTHON_VERSION=$( python -c "import sys; print('{}{}'.format(sys.version_info[0], sys.version_info[1]))" )
77

88
# Create necessary directories
9-
mkdir -p /scratch/nose /scratch/crashfiles /scratch/logs/py${PYTHON_VERSION}
9+
mkdir -p /scratch/pytest /scratch/crashfiles /scratch/logs/py${PYTHON_VERSION}
1010

1111
# Create a nipype config file
1212
mkdir -p /root/.nipype
@@ -20,17 +20,18 @@ if [[ "${PYTHON_VERSION}" -lt "30" ]]; then
2020
echo 'profile_runtime = true' >> /root/.nipype/nipype.cfg
2121
fi
2222

23-
# Run tests
23+
# Run tests using pytest
2424
cd /root/src/nipype/
2525
make clean
26-
nosetests -s nipype -c /root/src/nipype/.noserc --xunit-file="/scratch/nosetests_py${PYTHON_VERSION}.xml" --cover-xml-file="/scratch/coverage_py${PYTHON_VERSION}.xml"
26+
py.test --doctest-modules --cov-report xml:/scratch/coverage_py${PYTHON_VERSION}.xml --cov=nipype nipype
27+
2728

2829
# Workaround: run here the profiler tests in python 3
2930
if [[ "${PYTHON_VERSION}" -ge "30" ]]; then
3031
echo '[execution]' >> /root/.nipype/nipype.cfg
3132
echo 'profile_runtime = true' >> /root/.nipype/nipype.cfg
32-
nosetests nipype/interfaces/tests/test_runtime_profiler.py --xunit-file="/scratch/nosetests_py${PYTHON_VERSION}_profiler.xml" --cover-xml-file="/scratch/coverage_py${PYTHON_VERSION}_profiler.xml"
33-
nosetests nipype/pipeline/plugins/tests/test_multiproc*.py --xunit-file="/scratch/nosetests_py${PYTHON_VERSION}_multiproc.xml" --cover-xml-file="/scratch/coverage_py${PYTHON_VERSION}_multiproc.xml"
33+
py.test --cov-report xml:/scratch/coverage_py${PYTHON_VERSION}_profiler.xml --cov=nipype nipype/interfaces/tests/test_runtime_profiler.py
34+
py.test --cov-report xml:/scratch/coverage_py${PYTHON_VERSION}_multiproc.xml --cov=nipype nipype/pipeline/plugins/tests/test_multiproc*.py
3435
fi
3536

3637
# Copy crashfiles to scratch

docker/circleci/teardown.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
set -u
77
set -e
88

9-
mkdir -p ${CIRCLE_TEST_REPORTS}/nose
10-
sudo mv ~/scratch/*.xml ${CIRCLE_TEST_REPORTS}/nose
9+
mkdir -p ${CIRCLE_TEST_REPORTS}/pytest
10+
sudo mv ~/scratch/*.xml ${CIRCLE_TEST_REPORTS}/pytest
1111
mkdir -p ~/docs
1212
sudo mv ~/scratch/docs/* ~/docs/
1313
mkdir -p ~/logs

docker/nipype_test/Dockerfile_base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ RUN conda config --add channels conda-forge && \
122122
nitime \
123123
dipy \
124124
pandas && \
125-
pip install nose-cov doctest-ignore-unicode configparser
125+
pip install configparser
126126

127127
CMD ["/bin/bash"]

docker/nipype_test/Dockerfile_py27

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ MAINTAINER The nipype developers https://github.com/nipy/nipype
3232
# Downgrade python to 2.7
3333
RUN conda update -y conda && \
3434
conda update --all -y python=2.7 && \
35-
pip install nose-cov doctest-ignore-unicode configparser
35+
pip install configparser
3636

3737
COPY docker/circleci/run_* /usr/bin/
3838
RUN chmod +x /usr/bin/run_*

nipype/algorithms/confounds.py

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _run_interface(self, runtime):
182182
if self.inputs.save_all:
183183
out_file = self._gen_fname('dvars', ext='tsv')
184184
np.savetxt(out_file, np.vstack(dvars).T, fmt=b'%0.8f', delimiter=b'\t',
185-
header='std DVARS\tnon-std DVARS\tvx-wise std DVARS')
185+
header='std DVARS\tnon-std DVARS\tvx-wise std DVARS', comments='')
186186
self._results['out_all'] = out_file
187187

188188
return runtime
@@ -255,7 +255,7 @@ def _run_interface(self, runtime):
255255
'out_file': op.abspath(self.inputs.out_file),
256256
'fd_average': float(fd_res.mean())
257257
}
258-
np.savetxt(self.inputs.out_file, fd_res, header='framewise_displacement')
258+
np.savetxt(self.inputs.out_file, fd_res, header='FramewiseDisplacement', comments='')
259259

260260
if self.inputs.save_plot:
261261
tr = None
@@ -364,16 +364,16 @@ def _run_interface(self, runtime):
364364

365365
self._set_header()
366366
np.savetxt(components_file, components, fmt=b"%.10f", delimiter='\t',
367-
header=self._make_headers(components.shape[1]))
367+
header=self._make_headers(components.shape[1]), comments='')
368368
return runtime
369369

370370
def _list_outputs(self):
371371
outputs = self._outputs().get()
372372
outputs['components_file'] = os.path.abspath(self.inputs.components_file)
373373
return outputs
374374

375-
def _compute_tSTD(self, M, x):
376-
stdM = np.std(M, axis=0)
375+
def _compute_tSTD(self, M, x, axis=0):
376+
stdM = np.std(M, axis=axis)
377377
# set bad values to x
378378
stdM[stdM == 0] = x
379379
stdM[np.isnan(stdM)] = x
@@ -411,6 +411,10 @@ class TCompCorInputSpec(CompCorInputSpec):
411411
'That is, the 2% of voxels '
412412
'with the highest variance are used.')
413413

414+
class TCompCorOutputSpec(CompCorInputSpec):
415+
# and all the fields in CompCorInputSpec
416+
high_variance_mask = File(exists=True, desc="voxels excedding the variance threshold")
417+
414418
class TCompCor(CompCor):
415419
'''
416420
Interface for tCompCor. Computes a ROI mask based on variance of voxels.
@@ -428,7 +432,7 @@ class TCompCor(CompCor):
428432
'''
429433

430434
input_spec = TCompCorInputSpec
431-
output_spec = CompCorOutputSpec
435+
output_spec = TCompCorOutputSpec
432436

433437
def _run_interface(self, runtime):
434438
imgseries = nb.load(self.inputs.realigned_file).get_data()
@@ -438,29 +442,34 @@ def _run_interface(self, runtime):
438442
'(shape {})'
439443
.format(self.inputs.realigned_file, imgseries.ndim, imgseries.shape))
440444

445+
if isdefined(self.inputs.mask_file):
446+
in_mask_data = nb.load(self.inputs.mask_file).get_data()
447+
imgseries = imgseries[in_mask_data != 0, :]
448+
441449
# From the paper:
442450
# "For each voxel time series, the temporal standard deviation is
443451
# defined as the standard deviation of the time series after the removal
444452
# of low-frequency nuisance terms (e.g., linear and quadratic drift)."
445453
imgseries = regress_poly(2, imgseries)
446454

447-
time_voxels = imgseries.T
448-
num_voxels = np.prod(time_voxels.shape[1:])
449-
450455
# "To construct the tSTD noise ROI, we sorted the voxels by their
451456
# temporal standard deviation ..."
452-
tSTD = self._compute_tSTD(time_voxels, 0)
453-
sortSTD = np.sort(tSTD, axis=None) # flattened sorted matrix
457+
tSTD = self._compute_tSTD(imgseries, 0, axis=-1)
454458

455459
# use percentile_threshold to pick voxels
456-
threshold_index = int(num_voxels * (1. - self.inputs.percentile_threshold))
457-
threshold_std = sortSTD[threshold_index]
460+
threshold_std = np.percentile(tSTD, 100. * (1. - self.inputs.percentile_threshold))
458461
mask = tSTD >= threshold_std
459-
mask = mask.astype(int).T
462+
463+
if isdefined(self.inputs.mask_file):
464+
mask_data = np.zeros_like(in_mask_data)
465+
mask_data[in_mask_data != 0] = mask
466+
else:
467+
mask_data = mask.astype(int)
460468

461469
# save mask
462470
mask_file = os.path.abspath('mask.nii')
463-
nb.nifti1.save(nb.Nifti1Image(mask, np.eye(4)), mask_file)
471+
nb.Nifti1Image(mask_data,
472+
nb.load(self.inputs.realigned_file).affine).to_filename(mask_file)
464473
IFLOG.debug('tCompcor computed and saved mask of shape {} to mask_file {}'
465474
.format(mask.shape, mask_file))
466475
self.inputs.mask_file = mask_file
@@ -469,6 +478,11 @@ def _run_interface(self, runtime):
469478
super(TCompCor, self)._run_interface(runtime)
470479
return runtime
471480

481+
def _list_outputs(self):
482+
outputs = super(TCompCor, self)._list_outputs()
483+
outputs['high_variance_mask'] = self.inputs.mask_file
484+
return outputs
485+
472486
class TSNRInputSpec(BaseInterfaceInputSpec):
473487
in_file = InputMultiPath(File(exists=True), mandatory=True,
474488
desc='realigned 4D file or a list of 3D files')
@@ -654,7 +668,7 @@ def compute_dvars(in_file, in_mask, remove_zerovariance=False):
654668
warnings.filterwarnings('error')
655669

656670
# voxelwise standardization
657-
diff_vx_stdz = func_diff / np.array([diff_sdhat] * func_diff.shape[-1]).T
671+
diff_vx_stdz = func_diff / np.array([diff_sdhat] * func_diff.shape[-1]).T
658672
dvars_vx_stdz = diff_vx_stdz.std(axis=0, ddof=1)
659673

660674
return (dvars_stdz, dvars_nstd, dvars_vx_stdz)

0 commit comments

Comments
 (0)