Commit 498414c4 authored by Eric Larson's avatar Eric Larson

FIX: Fixing docs

parent 56d6a684
......@@ -148,9 +148,11 @@ def generate_file_rst(fname, target_dir, src_dir, plot_gallery):
this_template = rst_template
last_dir = os.path.split(src_dir)[-1]
# to avoid leading . in file names
if last_dir == '.': last_dir = ''
else: last_dir += '_'
short_fname = last_dir + fname
if last_dir == '.':
last_dir = ''
else:
last_dir += '_'
short_fname = last_dir + fname
src_file = os.path.join(src_dir, fname)
example_file = os.path.join(target_dir, fname)
shutil.copyfile(src_file, example_file)
......@@ -158,49 +160,38 @@ def generate_file_rst(fname, target_dir, src_dir, plot_gallery):
# generate the plot as png image if file name
# starts with plot and if it is more recent than an
# existing image.
if not os.path.exists(
os.path.join(target_dir, 'images')):
if not os.path.exists(os.path.join(target_dir, 'images')):
os.makedirs(os.path.join(target_dir, 'images'))
image_file = os.path.join(target_dir, 'images', image_name)
if (not os.path.exists(image_file) or
os.stat(image_file).st_mtime <=
os.stat(src_file).st_mtime):
os.stat(image_file).st_mtime <= os.stat(src_file).st_mtime):
print 'plotting %s' % fname
import matplotlib.pyplot as plt
plt.close('all')
try:
try:
from mayavi import mlab
except ImportError:
from enthought.mayavi import mlab
mlab.close(all=True)
except:
pass
try:
execfile(example_file, {'pl' : plt})
facecolor = plt.gcf().get_facecolor() # hack to keep black bg
brain = None
global plt
global brain
execfile(example_file, globals())
facecolor = plt.gcf().get_facecolor() # hack to keep black bg
if facecolor == (0.0, 0.0, 0.0, 1.0):
plt.savefig(image_file, facecolor='black')
else:
plt.savefig(image_file)
try:
brain.save_image(image_file)
except:
pass
brain.save_image(image_file)
except:
print 80*'_'
print 80 * '_'
print '%s is not compiling:' % fname
traceback.print_exc()
print 80*'_'
print 80 * '_'
this_template = plot_rst_template
docstring, short_desc, end_row = extract_docstring(example_file)
f = open(os.path.join(target_dir, fname[:-2] + 'rst'),'w')
f.write( this_template % locals())
f = open(os.path.join(target_dir, fname[:-2] + 'rst'), 'w')
f.write(this_template % locals())
f.flush()
......
[visual]
width=600
height=600
background=black
cortex=classic
default_view=lateral
......@@ -3,8 +3,7 @@ from os.path import join as pjoin
from warnings import warn
import numpy as np
from scipy import stats
from scipy import ndimage
from scipy import stats, ndimage, misc
from matplotlib.colors import colorConverter
import nibabel as nib
......@@ -1697,7 +1696,7 @@ class Brain(object):
self._v = None
def __del__(self):
if self._v is not None:
if hasattr(self, '_v') and self._v is not None:
self._v.dispose()
self._v = None
......@@ -1760,8 +1759,7 @@ class Brain(object):
a Mayavi figure to plot instead of TraitsUI) if you intend to
script plotting commands.
"""
data = self.screenshot()
make_montage(filename, [data])
misc.imsave(filename, self.screenshot())
def screenshot(self, mode='rgb', antialiased=False):
"""Generate a screenshot of current view
......@@ -1796,7 +1794,8 @@ class Brain(object):
row = []
for ri in range(self.brain_matrix.shape[0]):
col = []
for ci in range(self.brain_matrix.shape[1]):
n_col = 2 if self._hemi == 'split' else 1
for ci in range(n_col):
col += [self.screenshot_single(mode, antialiased,
ri, ci)]
row += [np.concatenate(col, axis=1)]
......
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