Skip to content

Commit 634cd6d

Browse files
committed
Merge pull request #121 from mwaskom/remove_config_file
Remove config_opts and config file
2 parents 4e0165b + 4755e8b commit 634cd6d

17 files changed

+156
-192
lines changed

CHANGES

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
11
PySurfer Changes
22
================
33

4+
Version 0.6
5+
-----------
6+
7+
- Values that were previously selected using a ``config_opts``
8+
dictionary in the ``Brain`` constructor are now keyword arguments.
9+
This should make it easier to use tab-completion in IPython, and will
10+
generally simplify your scripts. To ease transition, a ``config_opts``
11+
argument will still be caught, and its entries will be used (overriding
12+
the keyword arguments), but it will be removed in a future release.
13+
- The ability to set default values in a config file has been removed.
14+
While convenient, this approach encourages code that is not fully
15+
reproducible. While existing code that was written expecting a config
16+
file will still run, the visualization will fall back to default values.
17+
These should be updated directly in your plotting scripts.
18+
- Figure size is now specified only through the ``size`` keyword argument
19+
of :class:`Brain`. To make a rectangular window, pass a ``(width, height)``
20+
tuple. Passing a single value to ``size`` will still make a square window.
21+
- The ``cortex`` keyword argument can now be a mayavi colormap name or
22+
a ``(colormap, min, max, reverse)`` tuple for full control.
23+
- Morphometry plotting was made more flexible with the ability to pass
24+
a specific colormap and anchor points for that colormap. Additionally,
25+
the default anchor points now use robust statistics to give better
26+
values.
27+
428
Version 0.5
529
-----------
630

731
- Added control over the width of outlines when plotting the borders of
832
annotations or labels.
9-
- The visual display of the surfaces was improved by using surface normals
33+
- The visual display of the surfaces was improved by using surface normals.
1034
- Made colormap specification in Brain.add_data and Brain.add_contour_overlay
11-
more flexible, with better defaults
35+
more flexible, with better defaults.
1236
- Brain.save_montage() can now produce 2d grids of views in addition to
1337
horizontal and vertical arrangements.
1438
- Fixed some installation issues and added explicit checks for dependencies

bin/pysurfer

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,10 @@ if __name__ == '__main__':
7272

7373
from surfer import Brain
7474

75-
# Get a dict of config override options
76-
confkeys = ["size", "background", "cortex"]
77-
argdict = args.__dict__
78-
config_opts = dict([(k, v) for k, v in argdict.items()
79-
if k in confkeys and v])
80-
views = args.views
81-
8275
# Load up the figure and underlying brain object
8376
b = Brain(args.subject_id, args.hemi, args.surf, args.curv,
84-
args.title, views=views, config_opts=config_opts)
77+
args.title, views=args.views, size=args.size,
78+
background=args.background, cortex=args.cortex)
8579

8680
# Maybe load some morphometry
8781
if args.morphometry is not None:

doc/documentation/custom_viz.rst

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ have to delve into the underlying engine to get a different look.
1212
Changing the display background
1313
-------------------------------
1414

15-
The display background can take any valid matplotlib color.
15+
The display background can take any valid matplotlib color (i.e.,
16+
it can be a tuple of rgb values, an rgb hex string, or a named HTML
17+
color).
18+
19+
Changing the display size
20+
-------------------------
21+
22+
The default display window is 800px by 800px, but this can be configured
23+
using the ``size`` keyword argument in the Brain constructor. ``size``
24+
should either be a single number to make a square window, or a pair of
25+
values, ``(width, height)``, to make a rectangular window.
1626

1727
Changing the curvature color scheme
1828
-----------------------------------
@@ -22,45 +32,33 @@ cortical curvature values, so you can see which patches of cortex
2232
are gyri and which are sulci (pass ``curv=False`` to the
2333
:class:`Brain` constructor, or use the ``-no-curv`` switch in the
2434
command-line interface to turn this off). There are four preset
25-
themes for the curvature color scheme: ``classic``, ``bone``,
26-
``high_contrast``, and ``low_contrast``:
35+
themes for the curvature color scheme, which you can pass to the
36+
``cortex`` parameter in the :class:`Brain` constructor: ``classic``,
37+
``bone``, ``high_contrast``, and ``low_contrast``:
2738

2839
.. image:: ../_static/cortex_options.png
2940

3041
Note that, in each theme, the darker color signifies sulci.
3142

32-
Changing the display size
33-
-------------------------
43+
It's also possible to customize this further by passing the name of
44+
a mayavi colormap or a colormap name along with the endpoints of the
45+
colormap and whether it should be reversed.
3446

35-
The default display window is 800px by 800px, but this is also
36-
customizable. You may use any positive number for the size
37-
(subject, possibly, to Mayavi/hardware limitations we are not
38-
aware of). The viewing window is always square, so just give one
39-
number and it will be used for both width and height.
47+
Additionally, you can load a continuous curvature map with the
48+
:func:`add_morphometry` method.
4049

4150
How to use these themes
4251
-----------------------
4352

44-
These options can be set in three places. The first is in your
45-
config file. Set your preferred visualization theme there, and it
46-
will be used automatically whenever you start PySurfer. You may
47-
also override this theme for any individual visualization session.
48-
If using the Python ``surfer`` library, you may pass a
49-
``config_opts`` dictionary to the :class:`Brain` constructor,
50-
which will override any values you have set in your config file.
51-
If using the command-line interface, there are parameters for each
52-
of the above options. Regardless of method, the key names are
53-
``background``, ``cortex``, and ``size``.
54-
55-
For example:
53+
These options can be selected either as keyword arguments to the
54+
:class:`Brain` constructor,
5655

5756
.. sourcecode:: ipython
5857

5958
In [1]: from surfer import Brain
60-
In [2]: b = Brain('fsaverage', 'lh', 'inflated', config_opts={'cortex':'bone'})
59+
In [2]: b = Brain('fsaverage', 'lh', 'inflated', cortex='bone')
6160

62-
or::
61+
or as options in the command-line interface::
6362

6463
pysurfer fsaverage lh inflated -background slategray -size 400
6564

66-
in your shell terminal.

examples/plot_fmri_conjunction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"""
2121
Initialize the visualization.
2222
"""
23-
brain = Brain("fsaverage", "lh", "inflated",
24-
config_opts=dict(background="white"))
23+
brain = Brain("fsaverage", "lh", "inflated", background="white")
2524

2625
"""
2726
Read both of the activation maps in using

examples/plot_meg_inverse_solution.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"""
2323
create Brain object for visualization
2424
"""
25-
brain = Brain(subject_id, hemi, surface,
26-
config_opts=dict(width=800, height=400))
25+
brain = Brain(subject_id, hemi, surface, size=(800, 400))
2726

2827
"""
2928
read MNE dSPM inverse solution

examples/plot_morphometry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
print(__doc__)
1212

1313
brain = Brain("fsaverage", "both", "pial", views="frontal",
14-
config_opts=dict(background="dimgray"))
14+
background="dimgray")
1515

1616
"""
1717
Because the morphometry files generated by

examples/plot_parc_values.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"""
2323
Bring up the visualization.
2424
"""
25-
brain = Brain(subject_id, hemi, surface,
26-
config_opts=dict(background="white"))
25+
brain = Brain(subject_id, hemi, surface, background="white")
2726

2827
"""
2928
Read in the Buckner resting state network annotation. (This requires a

examples/plot_parcellation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
Bring up the visualization
2121
"""
2222
brain = Brain(subject_id, hemi, surface, views=view,
23-
config_opts={"cortex": "bone",
24-
"background": "ivory"})
23+
cortex="bone", background="ivory")
2524

2625
"""
2726
Display the 'aparc' parcellation borders.

examples/plot_probabilistic_label.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
print(__doc__)
1717

18-
brain = Brain("fsaverage", "lh", "inflated",
19-
config_opts=dict(cortex="low_contrast"))
18+
brain = Brain("fsaverage", "lh", "inflated", cortex="low_contrast")
2019

2120
"""
2221
The easiest way to label any vertex that could be in the region is with

examples/plot_resting_correlations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
print(__doc__)
1616

1717
"""Bring up the visualization"""
18-
brain = Brain("fsaverage", "split", "inflated", views=['lat', 'med'],
19-
config_opts=dict(background="white"))
18+
brain = Brain("fsaverage", "split", "inflated",
19+
views=['lat', 'med'], background="white")
2020

2121
"""Project the volume file and return as an array"""
2222
mri_file = "example_data/resting_corr.nii.gz"

0 commit comments

Comments
 (0)