Commit 40621da6 authored by Eric Larson's avatar Eric Larson

Merge pull request #152 from Eric89GXL/py3k

MRG: Py3k support
parents e704ac3b a079c223
......@@ -15,7 +15,7 @@ env:
before_install:
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- ./miniconda.sh -b -p /home/travis/miniconda
- export PATH=/home/travis/miniconda/bin:$PATH
- conda update --yes conda
......@@ -23,7 +23,7 @@ install:
- conda create -n testenv --yes pip python=$PYTHON
- source activate testenv
# Pillow (or PIL/imaging) is necessary for scipy.misc.imsave to exist
- conda install --yes --quiet ipython==1.1.0 numpy scipy mayavi matplotlib nose imaging
- conda install --yes --quiet numpy scipy mayavi matplotlib nose imaging
- if [ "${DEPS}" == "full" ]; then
travis_retry sudo apt-get update -qq;
travis_retry sudo apt-get install mencoder;
......
......@@ -24,6 +24,14 @@ create Brain object for visualization
"""
brain = Brain(subject_id, hemi, surface, size=(800, 400))
"""
label for time annotation in milliseconds
"""
def time_label(t):
return 'time=%0.2f ms' % (t * 1e3)
"""
read MNE dSPM inverse solution
"""
......@@ -49,11 +57,6 @@ for hemi in ['lh', 'rh']:
"""
colormap = 'hot'
"""
label for time annotation in milliseconds
"""
time_label = lambda t: 'time=%0.2f ms' % (t * 1e3)
brain.add_data(data, colormap=colormap, vertices=vertices,
smoothing_steps=10, time=time, time_label=time_label,
hemi=hemi)
......
......@@ -6,9 +6,11 @@
# Martin Luessi
# Eric Larson
import os
from setuptools import setup
descr = """PySurfer: cortical surface visualization using Python."""
import os
# deal with MPL sandbox violations during easy_install
os.environ['MPLCONFIGDIR'] = '.'
......@@ -32,10 +34,9 @@ LICENSE = 'BSD (3-clause)'
DOWNLOAD_URL = 'https://github.com/nipy/PySurfer'
VERSION = version
def check_dependencies():
needed_deps = ["IPython",
"numpy", "scipy", "matplotlib",
def check_dependencies():
needed_deps = ["numpy", "scipy", "matplotlib",
"mayavi",
]
missing_deps = []
......@@ -50,8 +51,6 @@ def check_dependencies():
raise ImportError("Missing dependencies: %s" % missing)
from setuptools import setup
if __name__ == "__main__":
if os.path.exists('MANIFEST'):
os.remove('MANIFEST')
......@@ -64,7 +63,6 @@ if __name__ == "__main__":
'clean'))):
check_dependencies()
setup(name=DISTNAME,
maintainer=MAINTAINER,
include_package_data=True,
......@@ -79,6 +77,9 @@ if __name__ == "__main__":
classifiers=['Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'License :: OSI Approved',
'Programming Language :: Python',
'Topic :: Software Development',
......
......@@ -176,7 +176,8 @@ def project_volume_data(filepath, hemi, reg_file=None, subject_id=None,
cmd = ['bash', '-c', 'source {} && env'.format(
os.path.join(env['FREESURFER_HOME'], 'FreeSurferEnv.sh'))]
envout = check_output(cmd)
env = dict(line.split('=', 1) for line in envout.split('\n')
env = dict(line.split('=', 1)
for line in envout.decode('utf-8').split('\n')
if '=' in line)
# Set the basic commands
......@@ -199,7 +200,7 @@ def project_volume_data(filepath, hemi, reg_file=None, subject_id=None,
proj_flag += "-"
proj_flag += projsum
if hasattr(projarg, "__iter__"):
proj_arg = map(str, projarg)
proj_arg = list(map(str, projarg))
else:
proj_arg = [str(projarg)]
cmd_list.extend([proj_flag] + proj_arg)
......
......@@ -82,9 +82,9 @@ def make_montage(filename, fnames, orientation='h', colorbar=None,
# dimension-dependent-attributeerror-in-pil-fromarray-function
fnames = [f if isinstance(f, string_types) else f.copy() for f in fnames]
if isinstance(fnames[0], string_types):
images = map(Image.open, fnames)
images = list(map(Image.open, fnames))
else:
images = map(Image.fromarray, fnames)
images = list(map(Image.fromarray, fnames))
# get bounding box for cropping
boxes = []
for ix, im in enumerate(images):
......@@ -566,7 +566,7 @@ class Brain(object):
'or brain.brains.' % name)
if isinstance(d, dict):
out = dict()
for key, value in d.iteritems():
for key, value in d.items():
out[key] = value[0]
else:
out = d[0]
......@@ -595,7 +595,7 @@ class Brain(object):
@property
def annot(self):
"""Wrap to annot"""
return self._get_one_brain(self.annot_list, 'contour')
return self._get_one_brain(self.annot_list, 'annot')
@property
def texts(self):
......@@ -879,9 +879,11 @@ class Brain(object):
if not self.n_times == len(time):
raise ValueError('time is not the same length as '
'array.shape[1]')
if isinstance(time_label, basestring):
if isinstance(time_label, string_types):
time_label_fmt = time_label
time_label = lambda x: time_label_fmt % x
def time_label(x):
return time_label_fmt % x
data["time_label"] = time_label
data["time"] = time
data["time_idx"] = 0
......@@ -1374,7 +1376,7 @@ class Brain(object):
scalar_data = _prepare_data(scalar_data)
# Maybe get rid of an old overlay
if hasattr(self, "contour") and remove_existing:
if remove_existing:
for c in self.contour_list:
c['surface'].remove()
if c['colorbar'] is not None:
......@@ -2234,7 +2236,7 @@ class Brain(object):
Column index of the brain to use
"""
brain = self.brain_matrix[row, col]
gviews = map(brain._xfm_view, views)
gviews = list(map(brain._xfm_view, views))
allowed = ('lateral', 'caudal', 'medial', 'rostral')
if not len([v for v in gviews if v in allowed]) == len(gviews):
raise ValueError('Animate through %s views.' % ' '.join(allowed))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment