Commit 2c73dbeb authored by Eric Larson's avatar Eric Larson

ENH: Py3k support

parent e704ac3b
......@@ -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,8 +34,8 @@ LICENSE = 'BSD (3-clause)'
DOWNLOAD_URL = 'https://github.com/nipy/PySurfer'
VERSION = version
def check_dependencies():
def check_dependencies():
needed_deps = ["IPython",
"numpy", "scipy", "matplotlib",
"mayavi",
......@@ -50,8 +52,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 +64,6 @@ if __name__ == "__main__":
'clean'))):
check_dependencies()
setup(name=DISTNAME,
maintainer=MAINTAINER,
include_package_data=True,
......@@ -79,6 +78,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