@@ -1270,9 +1270,12 @@ def add_annotation(self, annot, borders=True, alpha=1, hemi=None,
1270
1270
# (tksurfer doesn't use the alpha channel, so sometimes this
1271
1271
# is set weirdly. For our purposes, it should always be 0.
1272
1272
# Unless this sometimes causes problems?
1273
- cmap [np .where (cmap [:, 4 ] == 0 ), 3 ] = 0
1274
- if np .any (labels == 0 ) and not np .any (cmap [:, - 1 ] == 0 ):
1275
- cmap = np .vstack ((cmap , np .zeros (5 , int )))
1273
+ cmap [:, 3 ] = 255
1274
+ bgcolor = self ._brain_color
1275
+ bgcolor [- 1 ] = 0
1276
+ cmap [np .where (cmap [:, 4 ] <= 0 ), :4 ] = bgcolor
1277
+ if np .any (labels == 0 ) and not np .any (cmap [:, - 1 ] <= 0 ):
1278
+ cmap = np .vstack ((cmap , np .concatenate ([bgcolor , [0 ]])))
1276
1279
1277
1280
# Set label ids sensibly
1278
1281
order = np .argsort (cmap [:, - 1 ])
@@ -1885,6 +1888,21 @@ def set_surf(self, surf):
1885
1888
if brain ._f .scene is not None :
1886
1889
brain ._f .scene .reset_zoom ()
1887
1890
1891
+ @property
1892
+ def _brain_color (self ):
1893
+ geo_actor = self ._brain_list [0 ]['brain' ]._geo_surf .actor
1894
+ if self ._brain_list [0 ]['brain' ]._using_lut :
1895
+ bgcolor = np .mean (
1896
+ self ._brain_list [0 ]['brain' ]._geo_surf .module_manager
1897
+ .scalar_lut_manager .lut .table .to_array (), axis = 0 )
1898
+ else :
1899
+ bgcolor = geo_actor .property .color
1900
+ if len (bgcolor ) == 3 :
1901
+ bgcolor = bgcolor + (1 ,)
1902
+ bgcolor = 255 * np .array (bgcolor )
1903
+ bgcolor [- 1 ] *= geo_actor .property .opacity
1904
+ return bgcolor
1905
+
1888
1906
@verbose
1889
1907
def scale_data_colormap (self , fmin , fmid , fmax , transparent ,
1890
1908
center = None , alpha = 1.0 , verbose = None ):
@@ -1942,17 +1960,7 @@ def scale_data_colormap(self, fmin, fmid, fmax, transparent,
1942
1960
center , alpha )
1943
1961
1944
1962
# Get the effective background color as 255-based 4-element array
1945
- geo_actor = self ._brain_list [0 ]['brain' ]._geo_surf .actor
1946
- if self ._brain_list [0 ]['brain' ]._using_lut :
1947
- bgcolor = np .mean (
1948
- self ._brain_list [0 ]['brain' ]._geo_surf .module_manager
1949
- .scalar_lut_manager .lut .table .to_array (), axis = 0 )
1950
- else :
1951
- bgcolor = geo_actor .property .color
1952
- if len (bgcolor ) == 3 :
1953
- bgcolor = bgcolor + (1 ,)
1954
- bgcolor = 255 * np .array (bgcolor )
1955
- bgcolor [- 1 ] *= geo_actor .property .opacity
1963
+ bgcolor = self ._brain_color
1956
1964
1957
1965
views = self ._toggle_render (False )
1958
1966
# Use the new colormap
0 commit comments