Skip to content

Commit ca601ac

Browse files
committed
Merge pull request #94 from Eric89GXL/travis
ENH: Add Travis
2 parents 9db8414 + 4a9043f commit ca601ac

16 files changed

+177
-64
lines changed

.coveragerc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[run]
2+
branch = True
3+
source = surfer
4+
include = */surfer/*
5+
omit =
6+
*/setup.py

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ doc/samples
2222
pysurfer.egg-info
2323
*.avi
2424
.tmp/*.png
25-
examples/example_data/coord-lh.label

.travis.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
language: python
2+
3+
env:
4+
# Enable python 2 and python 3 builds
5+
# DEPS=full: build optional dependencies: pandas, nitime, statsmodels,
6+
# scikit-learn, patsy, nibabel; in the case of Python 2, also
7+
# nitime
8+
# DEPS=minimal: don't build optional dependencies; tests that require those
9+
# dependencies are supposed to be skipped
10+
- PYTHON=2.7 DEPS=full
11+
# PYTHON=3.3 DEPS=full # Mayavi doesn't support Py3 :(
12+
- PYTHON=2.7 DEPS=minimal # mencoder is an optional dependency
13+
14+
# Setup anaconda
15+
before_install:
16+
- wget http://repo.continuum.io/miniconda/Miniconda-2.2.2-Linux-x86_64.sh -O miniconda.sh
17+
- chmod +x miniconda.sh
18+
- ./miniconda.sh -b
19+
- export PATH=/home/travis/anaconda/bin:$PATH
20+
- conda update --yes conda
21+
22+
install:
23+
- conda create -n testenv --yes pip python=$PYTHON
24+
- source activate testenv
25+
# Pillow (or PIL/imaging) is necessary for scipy.misc.imsave to exist
26+
- conda install --yes --quiet ipython==1.1.0 numpy scipy mayavi matplotlib nose imaging
27+
- if [ "${DEPS}" == "full" ]; then
28+
travis_retry sudo apt-get install mencoder;
29+
fi;
30+
- pip install -q coverage coveralls nose-timer nibabel flake8
31+
- python setup.py build
32+
- python setup.py install
33+
- SRC_DIR=$(pwd)
34+
35+
before_script:
36+
# Let's create a (fake) display on Travis, and let's use a funny resolution
37+
- export DISPLAY=:99.0
38+
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1400x900x24 -ac +extension GLX +render
39+
- cd ~
40+
- wget --quiet http://faculty.washington.edu/larsoner/fsaverage_min.tar.gz
41+
- mkdir subjects
42+
- tar --directory subjects -xzf fsaverage_min.tar.gz
43+
- export SUBJECTS_DIR="${PWD}/subjects"
44+
- SURFER_DIR=$(python -c 'import surfer;print(surfer.__path__[0])')
45+
# Link coverage to src dir, coveralls should be run from there (needs git calls)
46+
- ln -s ${SURFER_DIR}/../.coverage ${SRC_DIR}/.coverage
47+
- cd ${SURFER_DIR}/../
48+
- ln -s ${SRC_DIR}/.coveragerc .coveragerc
49+
- ln -s ${SRC_DIR}/Makefile Makefile
50+
- ln -s ${SRC_DIR}/setup.cfg setup.cfg
51+
- ln -s ${SRC_DIR}/examples examples
52+
53+
script:
54+
- # Nose-timer has bugs on 3+ as of Jan 2014
55+
- if [ "{PYTHON}" == "2.7" ]; then
56+
nosetests --with-timer --timer-top-n 20;
57+
else
58+
nosetests;
59+
fi
60+
- cd ${SRC_DIR}
61+
- make flake
62+
63+
after_success:
64+
# Need to run from source dir to exectue "git" commands
65+
- coveralls

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# simple makefile to simplify repetetive build env management tasks under posix
2+
3+
# caution: testing won't work on windows, see README
4+
5+
PYTHON ?= python
6+
NOSETESTS ?= nosetests
7+
CTAGS ?= ctags
8+
9+
all: clean inplace test
10+
11+
clean-pyc:
12+
find . -name "*.pyc" | xargs rm -f
13+
14+
clean-so:
15+
find . -name "*.so" | xargs rm -f
16+
find . -name "*.pyd" | xargs rm -f
17+
18+
clean-build:
19+
rm -rf build
20+
21+
clean-ctags:
22+
rm -f tags
23+
24+
clean: clean-build clean-pyc clean-so clean-ctags
25+
26+
flake:
27+
if command -v flake8 > /dev/null; then \
28+
flake8 --count surfer examples; \
29+
fi
30+
31+
in: inplace # just a shortcut
32+
inplace:
33+
$(PYTHON) setup.py build_ext -i
34+
35+
nosetests:
36+
rm -f .coverage
37+
$(NOSETESTS) surfer
38+
39+
test: clean nosetests flake
40+
41+

examples/example_data/__init__.py

Whitespace-only changes.

examples/plot_fmri_activation_volume.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
anatomy, you can provide project_volume_data with the subject ID, avoiding the
5353
need to specify a registration file.
5454
55-
By default, 3mm of smoothing is applied on the surface to clean up the overlay a
56-
bit, although the extent of smoothing can be controlled.
55+
By default, 3mm of smoothing is applied on the surface to clean up the overlay
56+
a bit, although the extent of smoothing can be controlled.
5757
"""
5858
zstat = project_volume_data(volume_file, "lh",
5959
subject_id="fsaverage", smooth_fwhm=0.5)
@@ -68,8 +68,8 @@
6868
It can also be a good idea to plot the inverse of the mask that was used in the
6969
analysis, so you can be clear about areas that were not included.
7070
71-
It's good to change some parameters of the sampling to account for the fact that
72-
you are projecting binary (0, 1) data.
71+
It's good to change some parameters of the sampling to account for the fact
72+
that you are projecting binary (0, 1) data.
7373
"""
7474
mask_file = "example_data/mask.nii.gz"
7575
mask = project_volume_data(mask_file, "lh", subject_id="fsaverage",

examples/plot_fmri_conjunction.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
Read both of the activation maps in using
2929
surfer's io functions.
3030
"""
31-
data_dir = op.join("example_data")
32-
sig1 = io.read_scalar_data(op.join(data_dir, "lh.sig.nii.gz"))
33-
sig2 = io.read_scalar_data(op.join(data_dir, "lh.alt_sig.nii.gz"))
31+
sig1 = io.read_scalar_data(op.join('example_data', "lh.sig.nii.gz"))
32+
sig2 = io.read_scalar_data(op.join('example_data', "lh.alt_sig.nii.gz"))
3433

3534
"""
3635
Zero out the vertices that do not meet a threshold.

examples/plot_label_foci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
coordinate of the point we want to display.
5858
"""
5959
brain.add_foci([coord], map_surface="white", coords_as_verts=True,
60-
color="mediumblue")
60+
color="mediumblue")
6161

6262
"""
6363
Set the camera position to show the extent of the labels.

examples/plot_meg_inverse_solution.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
import numpy as np
1212

13-
from surfer import Brain, TimeViewer
13+
from surfer import Brain
1414
from surfer.io import read_stc
1515

1616
"""
@@ -29,8 +29,8 @@
2929
read MNE dSPM inverse solution
3030
"""
3131
for hemi in ['lh', 'rh']:
32-
stc_fname = os.path.join('example_data',
33-
'meg_source_estimate-' + hemi + '.stc')
32+
stc_fname = os.path.join('example_data/meg_source_estimate-'
33+
+ hemi + '.stc')
3434
stc = read_stc(stc_fname)
3535

3636
"""
@@ -66,6 +66,7 @@
6666
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
6767

6868
"""
69-
uncomment this line to use the interactive TimeViewer GUI
69+
uncomment these lines to use the interactive TimeViewer GUI
7070
"""
71+
#from surfer import TimeViewer
7172
#viewer = TimeViewer(brain)

examples/plot_resting_correlations.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@
4747
is centered on 0, which is a meaningful transition-point as it marks the change
4848
from negative correlations to positive correlations.
4949
50-
We'll also plot the map with some transparency so that we can see through to the
51-
underlying anatomy.
50+
We'll also plot the map with some transparency so that we can see through to
51+
the underlying anatomy.
5252
"""
53-
brain.add_data(surf_data_lh, -.7, .7, colormap="coolwarm", alpha=.75, hemi='lh')
54-
brain.add_data(surf_data_rh, -.7, .7, colormap="coolwarm", alpha=.75, hemi='rh')
53+
brain.add_data(surf_data_lh, -.7, .7, colormap="coolwarm", alpha=.75,
54+
hemi='lh')
55+
brain.add_data(surf_data_rh, -.7, .7, colormap="coolwarm", alpha=.75,
56+
hemi='rh')
5557

5658
"""
5759
This overlay represents resting-state correlations with a

0 commit comments

Comments
 (0)