@@ -913,7 +913,7 @@ def _iter_time(self, time_idx, interpolation):
913
913
###########################################################################
914
914
# ADDING DATA PLOTS
915
915
def add_overlay (self , source , min = 2 , max = "robust_max" , sign = "abs" ,
916
- name = None , hemi = None , ** kwargs ):
916
+ name = None , hemi = None , ** mlab_kws ):
917
917
"""Add an overlay to the overlay dict from a file or array.
918
918
919
919
Parameters
@@ -932,7 +932,8 @@ def add_overlay(self, source, min=2, max="robust_max", sign="abs",
932
932
If None, it is assumed to belong to the hemipshere being
933
933
shown. If two hemispheres are being shown, an error will
934
934
be thrown.
935
- kwargs: other mayavi surface arguments.
935
+ **mlab_kws: All additional keyword arguments are passed to the
936
+ `mlab.pipeline.surface` call.
936
937
"""
937
938
hemi = self ._check_hemi (hemi )
938
939
# load data here
@@ -945,7 +946,7 @@ def add_overlay(self, source, min=2, max="robust_max", sign="abs",
945
946
views = self ._toggle_render (False )
946
947
for brain in self ._brain_list :
947
948
if brain ['hemi' ] == hemi :
948
- ol .append (brain ['brain' ].add_overlay (old , ** kwargs ))
949
+ ol .append (brain ['brain' ].add_overlay (old , ** mlab_kws ))
949
950
if name in self .overlays_dict :
950
951
name = "%s%d" % (name , len (self .overlays_dict ) + 1 )
951
952
self .overlays_dict [name ] = ol
@@ -959,7 +960,7 @@ def add_data(self, array, min=None, max=None, thresh=None,
959
960
hemi = None , remove_existing = False , time_label_size = 14 ,
960
961
initial_time = None , scale_factor = None , vector_alpha = None ,
961
962
mid = None , center = None , transparent = False , verbose = None ,
962
- ** kwargs ):
963
+ ** mlab_kws ):
963
964
"""Display data from a numpy array on the surface.
964
965
965
966
This provides a similar interface to
@@ -1037,7 +1038,8 @@ def add_data(self, array, min=None, max=None, thresh=None,
1037
1038
vector-valued data. If None (default), ``alpha`` is used.
1038
1039
verbose : bool, str, int, or None
1039
1040
If not None, override default verbose level (see surfer.verbose).
1040
- kwargs: other mayavi surface arguments.
1041
+ **mlab_kws: All additional keyword arguments are passed to the
1042
+ `mlab.pipeline.surface` call.
1041
1043
1042
1044
Notes
1043
1045
-----
@@ -1175,7 +1177,7 @@ def time_label(x):
1175
1177
s , ct , bar , gl = brain ['brain' ].add_data (
1176
1178
array , min , mid , max , thresh , lut , colormap , alpha ,
1177
1179
colorbar , layer_id , smooth_mat , magnitude , magnitude_max ,
1178
- scale_factor , vertices , vector_alpha , ** kwargs )
1180
+ scale_factor , vertices , vector_alpha , ** mlab_kws )
1179
1181
surfs .append (s )
1180
1182
bars .append (bar )
1181
1183
glyphs .append (gl )
@@ -1199,7 +1201,7 @@ def time_label(x):
1199
1201
self ._toggle_render (True , views )
1200
1202
1201
1203
def add_annotation (self , annot , borders = True , alpha = 1 , hemi = None ,
1202
- remove_existing = True , color = None , ** kwargs ):
1204
+ remove_existing = True , color = None , ** mlab_kws ):
1203
1205
"""Add an annotation file.
1204
1206
1205
1207
Parameters
@@ -1226,7 +1228,8 @@ def add_annotation(self, annot, borders=True, alpha=1, hemi=None,
1226
1228
color : matplotlib-style color code
1227
1229
If used, show all annotations in the same (specified) color.
1228
1230
Probably useful only when showing annotation borders.
1229
- kwargs: other mayavi surface arguments.
1231
+ **mlab_kws: All additional keyword arguments are passed to the
1232
+ `mlab.pipeline.surface` call.
1230
1233
"""
1231
1234
hemis = self ._check_hemis (hemi )
1232
1235
@@ -1309,11 +1312,11 @@ def add_annotation(self, annot, borders=True, alpha=1, hemi=None,
1309
1312
if brain ['hemi' ] == hemi :
1310
1313
self .annot_list .append (
1311
1314
brain ['brain' ].add_annotation (annot , ids , cmap ,
1312
- ** kwargs ))
1315
+ ** mlab_kws ))
1313
1316
self ._toggle_render (True , views )
1314
1317
1315
1318
def add_label (self , label , color = None , alpha = 1 , scalar_thresh = None ,
1316
- borders = False , hemi = None , subdir = None , ** kwargs ):
1319
+ borders = False , hemi = None , subdir = None , ** mlab_kws ):
1317
1320
"""Add an ROI label to the image.
1318
1321
1319
1322
Parameters
@@ -1345,7 +1348,8 @@ def add_label(self, label, color=None, alpha=1, scalar_thresh=None,
1345
1348
label directory rather than in the label directory itself (e.g.
1346
1349
for ``$SUBJECTS_DIR/$SUBJECT/label/aparc/lh.cuneus.label``
1347
1350
``brain.add_label('cuneus', subdir='aparc')``).
1348
- kwargs: other mayavi surface arguments.
1351
+ **mlab_kws: All additional keyword arguments are passed to the
1352
+ `mlab.pipeline.surface` call.
1349
1353
Notes
1350
1354
-----
1351
1355
To remove previously added labels, run Brain.remove_labels().
@@ -1426,7 +1430,7 @@ def add_label(self, label, color=None, alpha=1, scalar_thresh=None,
1426
1430
for brain in self .brains :
1427
1431
if brain .hemi == hemi :
1428
1432
array_id , surf = brain .add_label (label , label_name , color ,
1429
- alpha , ** kwargs )
1433
+ alpha , ** mlab_kws )
1430
1434
surfaces .append (surf )
1431
1435
array_ids .append ((brain , array_id ))
1432
1436
self ._label_dicts [label_name ] = {'surfaces' : surfaces ,
@@ -1536,7 +1540,7 @@ def remove_labels(self, labels=None, hemi=None):
1536
1540
1537
1541
def add_morphometry (self , measure , grayscale = False , hemi = None ,
1538
1542
remove_existing = True , colormap = None ,
1539
- min = None , max = None , colorbar = True , ** kwargs ):
1543
+ min = None , max = None , colorbar = True , ** mlab_kws ):
1540
1544
"""Add a morphometry overlay to the image.
1541
1545
1542
1546
Parameters
@@ -1558,7 +1562,8 @@ def add_morphometry(self, measure, grayscale=False, hemi=None,
1558
1562
of the data is used.
1559
1563
colorbar : bool
1560
1564
If True, show a colorbar corresponding to the overlay data.
1561
- kwargs: other mayavi surface arguments.
1565
+ **mlab_kws: All additional keyword arguments are passed to the
1566
+ `mlab.pipeline.surface` call.
1562
1567
"""
1563
1568
hemis = self ._check_hemis (hemi )
1564
1569
morph_files = []
@@ -1620,12 +1625,12 @@ def add_morphometry(self, measure, grayscale=False, hemi=None,
1620
1625
if brain .hemi == hemi :
1621
1626
self .morphometry_list .append (brain .add_morphometry (
1622
1627
morph_data , colormap , measure , min , max , colorbar ,
1623
- ** kwargs ))
1628
+ ** mlab_kws ))
1624
1629
self ._toggle_render (True , views )
1625
1630
1626
1631
def add_foci (self , coords , coords_as_verts = False , map_surface = None ,
1627
1632
scale_factor = 1 , color = "white" , alpha = 1 , name = None ,
1628
- hemi = None , ** kwargs ):
1633
+ hemi = None , ** mlab_kws ):
1629
1634
"""Add spherical foci, possibly mapping to displayed surf.
1630
1635
1631
1636
The foci spheres can be displayed at the coordinates given, or
@@ -1655,7 +1660,8 @@ def add_foci(self, coords, coords_as_verts=False, map_surface=None,
1655
1660
If None, it is assumed to belong to the hemipshere being
1656
1661
shown. If two hemispheres are being shown, an error will
1657
1662
be thrown.
1658
- kwargs: other mayavi point3d arguments.
1663
+ **mlab_kws: All additional keyword arguments are passed to the
1664
+ `mlab.point3d` call.
1659
1665
"""
1660
1666
from matplotlib .colors import colorConverter
1661
1667
hemi = self ._check_hemi (hemi )
@@ -1692,14 +1698,14 @@ def add_foci(self, coords, coords_as_verts=False, map_surface=None,
1692
1698
if brain ['hemi' ] == hemi :
1693
1699
fl .append (brain ['brain' ].add_foci (foci_coords , scale_factor ,
1694
1700
color , alpha , name ,
1695
- ** kwargs ))
1701
+ ** mlab_kws ))
1696
1702
self .foci_dict [name ] = fl
1697
1703
self ._toggle_render (True , views )
1698
1704
1699
1705
def add_contour_overlay (self , source , min = None , max = None ,
1700
1706
n_contours = 7 , line_width = 1.5 , colormap = "YlOrRd_r" ,
1701
1707
hemi = None , remove_existing = True , colorbar = True ,
1702
- ** kwargs ):
1708
+ ** mlab_kws ):
1703
1709
"""Add a topographic contour overlay of the positive data.
1704
1710
1705
1711
Note: This visualization will look best when using the "low_contrast"
@@ -1729,7 +1735,8 @@ def add_contour_overlay(self, source, min=None, max=None,
1729
1735
If there is an existing contour overlay, remove it before plotting.
1730
1736
colorbar : bool
1731
1737
If True, show the colorbar for the scalar value.
1732
- kwargs: other mayavi surface arguments.
1738
+ **mlab_kws: All additional keyword arguments are passed to the
1739
+ `mlab.pipeline.surface` call.
1733
1740
"""
1734
1741
hemi = self ._check_hemi (hemi )
1735
1742
@@ -1756,11 +1763,12 @@ def add_contour_overlay(self, source, min=None, max=None,
1756
1763
if brain .hemi == hemi :
1757
1764
self .contour_list .append (brain .add_contour_overlay (
1758
1765
scalar_data , min , max , n_contours , line_width , lut ,
1759
- colorbar , ** kwargs ))
1766
+ colorbar , ** mlab_kws ))
1760
1767
self ._toggle_render (True , views )
1761
1768
1762
1769
def add_text (self , x , y , text , name , color = None , opacity = 1.0 ,
1763
- row = - 1 , col = - 1 , font_size = None , justification = None , ** kwargs ):
1770
+ row = - 1 , col = - 1 , font_size = None , justification = None ,
1771
+ ** mlab_kws ):
1764
1772
""" Add a text to the visualization
1765
1773
1766
1774
Parameters
@@ -1783,13 +1791,14 @@ def add_text(self, x, y, text, name, color=None, opacity=1.0,
1783
1791
Row index of which brain to use
1784
1792
col : int
1785
1793
Column index of which brain to use
1786
- kwargs: other mayavi text3d arguments.
1794
+ mlab_kws: All additional keyword arguments are passed to the
1795
+ `mlab.text` call.
1787
1796
"""
1788
1797
if name in self .texts_dict :
1789
1798
self .texts_dict [name ]['text' ].remove ()
1790
1799
text = self .brain_matrix [row , col ].add_text (x , y , text ,
1791
1800
name , color , opacity ,
1792
- ** kwargs )
1801
+ ** mlab_kws )
1793
1802
self .texts_dict [name ] = dict (row = row , col = col , text = text )
1794
1803
if font_size is not None :
1795
1804
text .property .font_size = font_size
@@ -3206,7 +3215,7 @@ def _remove_vector_data(self, glyphs):
3206
3215
if glyphs is not None :
3207
3216
glyphs .parent .parent .remove ()
3208
3217
3209
- def add_overlay (self , old , ** kwargs ):
3218
+ def add_overlay (self , old , ** mlab_kws ):
3210
3219
"""Add an overlay to the overlay dict from a file or array"""
3211
3220
array_id , mesh = self ._add_scalar_data (old .mlab_data )
3212
3221
@@ -3216,7 +3225,7 @@ def add_overlay(self, old, **kwargs):
3216
3225
pos = mlab .pipeline .surface (
3217
3226
pos_thresh , colormap = "YlOrRd" , figure = self ._f ,
3218
3227
vmin = old .pos_lims [1 ], vmax = old .pos_lims [2 ],
3219
- reset_zoom = False , ** kwargs )
3228
+ reset_zoom = False , ** mlab_kws )
3220
3229
pos .actor .property .backface_culling = False
3221
3230
pos_bar = mlab .scalarbar (pos , nb_labels = 5 )
3222
3231
pos_bar .reverse_lut = True
@@ -3232,7 +3241,7 @@ def add_overlay(self, old, **kwargs):
3232
3241
neg = mlab .pipeline .surface (
3233
3242
neg_thresh , colormap = "PuBu" , figure = self ._f ,
3234
3243
vmin = old .neg_lims [1 ], vmax = old .neg_lims [2 ],
3235
- reset_zoom = False , ** kwargs )
3244
+ reset_zoom = False , ** mlab_kws )
3236
3245
neg .actor .property .backface_culling = False
3237
3246
neg_bar = mlab .scalarbar (neg , nb_labels = 5 )
3238
3247
neg_bar .scalar_bar_representation .position = (0.05 , 0.01 )
@@ -3246,7 +3255,7 @@ def add_overlay(self, old, **kwargs):
3246
3255
@verbose
3247
3256
def add_data (self , array , fmin , fmid , fmax , thresh , lut , colormap , alpha ,
3248
3257
colorbar , layer_id , smooth_mat , magnitude , magnitude_max ,
3249
- scale_factor , vertices , vector_alpha , ** kwargs ):
3258
+ scale_factor , vertices , vector_alpha , ** mlab_kws ):
3250
3259
"""Add data to the brain"""
3251
3260
# Calculate initial data to plot
3252
3261
if array .ndim == 1 :
@@ -3289,7 +3298,7 @@ def add_data(self, array, fmin, fmid, fmax, thresh, lut, colormap, alpha,
3289
3298
surf = mlab .pipeline .surface (
3290
3299
pipe , colormap = colormap , vmin = fmin , vmax = fmax ,
3291
3300
opacity = float (alpha ), figure = self ._f , reset_zoom = False ,
3292
- ** kwargs )
3301
+ ** mlab_kws )
3293
3302
surf .actor .property .backface_culling = False
3294
3303
3295
3304
# apply look up table if given
@@ -3314,13 +3323,13 @@ def add_data(self, array, fmin, fmid, fmax, thresh, lut, colormap, alpha,
3314
3323
scale_factor_norm = scale_factor_norm )
3315
3324
return surf , orig_ctable , bar , glyphs
3316
3325
3317
- def add_annotation (self , annot , ids , cmap , ** kwargs ):
3326
+ def add_annotation (self , annot , ids , cmap , ** mlab_kws ):
3318
3327
"""Add an annotation file"""
3319
3328
# Add scalar values to dataset
3320
3329
array_id , pipe = self ._add_scalar_data (ids )
3321
3330
with warnings .catch_warnings (record = True ):
3322
3331
surf = mlab .pipeline .surface (pipe , name = annot , figure = self ._f ,
3323
- reset_zoom = False , ** kwargs )
3332
+ reset_zoom = False , ** mlab_kws )
3324
3333
surf .actor .property .backface_culling = False
3325
3334
3326
3335
# Set the color table
@@ -3331,13 +3340,13 @@ def add_annotation(self, annot, ids, cmap, **kwargs):
3331
3340
return dict (surface = surf , name = annot , colormap = cmap , brain = self ,
3332
3341
array_id = array_id )
3333
3342
3334
- def add_label (self , label , label_name , color , alpha , ** kwargs ):
3343
+ def add_label (self , label , label_name , color , alpha , ** mlab_kws ):
3335
3344
"""Add an ROI label to the image"""
3336
3345
from matplotlib .colors import colorConverter
3337
3346
array_id , pipe = self ._add_scalar_data (label )
3338
3347
with warnings .catch_warnings (record = True ):
3339
3348
surf = mlab .pipeline .surface (pipe , name = label_name , figure = self ._f ,
3340
- reset_zoom = False , ** kwargs )
3349
+ reset_zoom = False , ** mlab_kws )
3341
3350
surf .actor .property .backface_culling = False
3342
3351
color = colorConverter .to_rgba (color , alpha )
3343
3352
cmap = np .array ([(0 , 0 , 0 , 0 ,), color ])
@@ -3349,13 +3358,13 @@ def add_label(self, label, label_name, color, alpha, **kwargs):
3349
3358
return array_id , surf
3350
3359
3351
3360
def add_morphometry (self , morph_data , colormap , measure ,
3352
- min , max , colorbar , ** kwargs ):
3361
+ min , max , colorbar , ** mlab_kws ):
3353
3362
"""Add a morphometry overlay to the image"""
3354
3363
array_id , pipe = self ._add_scalar_data (morph_data )
3355
3364
with warnings .catch_warnings (record = True ):
3356
3365
surf = mlab .pipeline .surface (
3357
3366
pipe , colormap = colormap , vmin = min , vmax = max , name = measure ,
3358
- figure = self ._f , reset_zoom = False , ** kwargs )
3367
+ figure = self ._f , reset_zoom = False , ** mlab_kws )
3359
3368
3360
3369
# Get the colorbar
3361
3370
if colorbar :
@@ -3370,27 +3379,27 @@ def add_morphometry(self, morph_data, colormap, measure,
3370
3379
array_id = array_id )
3371
3380
3372
3381
def add_foci (self , foci_coords , scale_factor , color , alpha , name ,
3373
- ** kwargs ):
3382
+ ** mlab_kws ):
3374
3383
"""Add spherical foci, possibly mapping to displayed surf"""
3375
3384
# Create the visualization
3376
3385
with warnings .catch_warnings (record = True ): # traits
3377
3386
points = mlab .points3d (
3378
3387
foci_coords [:, 0 ], foci_coords [:, 1 ], foci_coords [:, 2 ],
3379
3388
np .ones (foci_coords .shape [0 ]), name = name , figure = self ._f ,
3380
3389
scale_factor = (10. * scale_factor ), color = color , opacity = alpha ,
3381
- reset_zoom = False , ** kwargs )
3390
+ reset_zoom = False , ** mlab_kws )
3382
3391
return points
3383
3392
3384
3393
def add_contour_overlay (self , scalar_data , min = None , max = None ,
3385
3394
n_contours = 7 , line_width = 1.5 , lut = None ,
3386
- colorbar = True , ** kwargs ):
3395
+ colorbar = True , ** mlab_kws ):
3387
3396
"""Add a topographic contour overlay of the positive data"""
3388
3397
array_id , pipe = self ._add_scalar_data (scalar_data )
3389
3398
with warnings .catch_warnings (record = True ):
3390
3399
thresh = threshold_filter (pipe , low = min )
3391
3400
surf = mlab .pipeline .contour_surface (
3392
3401
thresh , contours = n_contours , line_width = line_width ,
3393
- reset_zoom = False , ** kwargs )
3402
+ reset_zoom = False , ** mlab_kws )
3394
3403
if lut is not None :
3395
3404
l_m = surf .module_manager .scalar_lut_manager
3396
3405
l_m .load_lut_from_list (lut / 255. )
@@ -3408,12 +3417,12 @@ def add_contour_overlay(self, scalar_data, min=None, max=None,
3408
3417
# Set up a dict attribute with pointers at important things
3409
3418
return dict (surface = surf , colorbar = bar , brain = self , array_id = array_id )
3410
3419
3411
- def add_text (self , x , y , text , name , color = None , opacity = 1.0 , ** kwargs ):
3420
+ def add_text (self , x , y , text , name , color = None , opacity = 1.0 , ** mlab_kws ):
3412
3421
""" Add a text to the visualization"""
3413
3422
color = self ._fg_color if color is None else color
3414
3423
with warnings .catch_warnings (record = True ):
3415
3424
text = mlab .text (x , y , text , name = name , color = color ,
3416
- opacity = opacity , figure = self ._f , ** kwargs )
3425
+ opacity = opacity , figure = self ._f , ** mlab_kws )
3417
3426
return text
3418
3427
3419
3428
def remove_data (self , layer_id ):
0 commit comments