Skip to content

Commit 498414c

Browse files
committed
FIX: Fixing docs
1 parent 56d6a68 commit 498414c

File tree

4 files changed

+24
-32
lines changed

4 files changed

+24
-32
lines changed

doc/sphinxext/gen_rst.py

+17-26
Original file line numberDiff line numberDiff line change
@@ -148,59 +148,50 @@ def generate_file_rst(fname, target_dir, src_dir, plot_gallery):
148148
this_template = rst_template
149149
last_dir = os.path.split(src_dir)[-1]
150150
# to avoid leading . in file names
151-
if last_dir == '.': last_dir = ''
152-
else: last_dir += '_'
153-
short_fname = last_dir + fname
151+
if last_dir == '.':
152+
last_dir = ''
153+
else:
154+
last_dir += '_'
155+
short_fname = last_dir + fname
154156
src_file = os.path.join(src_dir, fname)
155157
example_file = os.path.join(target_dir, fname)
156158
shutil.copyfile(src_file, example_file)
157159
if plot_gallery and fname.startswith('plot'):
158160
# generate the plot as png image if file name
159161
# starts with plot and if it is more recent than an
160162
# existing image.
161-
if not os.path.exists(
162-
os.path.join(target_dir, 'images')):
163+
if not os.path.exists(os.path.join(target_dir, 'images')):
163164
os.makedirs(os.path.join(target_dir, 'images'))
164165
image_file = os.path.join(target_dir, 'images', image_name)
165166
if (not os.path.exists(image_file) or
166-
os.stat(image_file).st_mtime <=
167-
os.stat(src_file).st_mtime):
167+
os.stat(image_file).st_mtime <= os.stat(src_file).st_mtime):
168168
print 'plotting %s' % fname
169169
import matplotlib.pyplot as plt
170170
plt.close('all')
171171
try:
172-
try:
173-
from mayavi import mlab
174-
except ImportError:
175-
from enthought.mayavi import mlab
176-
mlab.close(all=True)
177-
except:
178-
pass
179-
180-
try:
181-
execfile(example_file, {'pl' : plt})
182-
facecolor = plt.gcf().get_facecolor() # hack to keep black bg
172+
brain = None
173+
global plt
174+
global brain
175+
execfile(example_file, globals())
176+
facecolor = plt.gcf().get_facecolor() # hack to keep black bg
183177
if facecolor == (0.0, 0.0, 0.0, 1.0):
184178
plt.savefig(image_file, facecolor='black')
185179
else:
186180
plt.savefig(image_file)
187181

188-
try:
189-
brain.save_image(image_file)
190-
except:
191-
pass
182+
brain.save_image(image_file)
192183

193184
except:
194-
print 80*'_'
185+
print 80 * '_'
195186
print '%s is not compiling:' % fname
196187
traceback.print_exc()
197-
print 80*'_'
188+
print 80 * '_'
198189
this_template = plot_rst_template
199190

200191
docstring, short_desc, end_row = extract_docstring(example_file)
201192

202-
f = open(os.path.join(target_dir, fname[:-2] + 'rst'),'w')
203-
f.write( this_template % locals())
193+
f = open(os.path.join(target_dir, fname[:-2] + 'rst'), 'w')
194+
f.write(this_template % locals())
204195
f.flush()
205196

206197

doc/surfer.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[visual]
2+
width=600
3+
height=600
24
background=black
35
cortex=classic
46
default_view=lateral

examples/example_data/index.rst

Whitespace-only changes.

surfer/viz.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from warnings import warn
44

55
import numpy as np
6-
from scipy import stats
7-
from scipy import ndimage
6+
from scipy import stats, ndimage, misc
87
from matplotlib.colors import colorConverter
98

109
import nibabel as nib
@@ -1697,7 +1696,7 @@ def close(self):
16971696
self._v = None
16981697

16991698
def __del__(self):
1700-
if self._v is not None:
1699+
if hasattr(self, '_v') and self._v is not None:
17011700
self._v.dispose()
17021701
self._v = None
17031702

@@ -1760,8 +1759,7 @@ def save_image(self, filename):
17601759
a Mayavi figure to plot instead of TraitsUI) if you intend to
17611760
script plotting commands.
17621761
"""
1763-
data = self.screenshot()
1764-
make_montage(filename, [data])
1762+
misc.imsave(filename, self.screenshot())
17651763

17661764
def screenshot(self, mode='rgb', antialiased=False):
17671765
"""Generate a screenshot of current view
@@ -1796,7 +1794,8 @@ def screenshot(self, mode='rgb', antialiased=False):
17961794
row = []
17971795
for ri in range(self.brain_matrix.shape[0]):
17981796
col = []
1799-
for ci in range(self.brain_matrix.shape[1]):
1797+
n_col = 2 if self._hemi == 'split' else 1
1798+
for ci in range(n_col):
18001799
col += [self.screenshot_single(mode, antialiased,
18011800
ri, ci)]
18021801
row += [np.concatenate(col, axis=1)]

0 commit comments

Comments
 (0)