@@ -768,7 +768,7 @@ def add_data(self, array, min=None, max=None, thresh=None,
768
768
colormap = "RdBu_r" , alpha = 1 ,
769
769
vertices = None , smoothing_steps = 20 , time = None ,
770
770
time_label = "time index=%d" , colorbar = True ,
771
- hemi = None ):
771
+ hemi = None , remove_existing = True ):
772
772
"""Display data from a numpy array on the surface.
773
773
774
774
This provides a similar interface to add_overlay, but it displays
@@ -817,6 +817,8 @@ def add_data(self, array, min=None, max=None, thresh=None,
817
817
If None, it is assumed to belong to the hemipshere being
818
818
shown. If two hemispheres are being shown, an error will
819
819
be thrown.
820
+ remove_existing : bool
821
+ Remove surface added by previous "add_data" call.
820
822
"""
821
823
hemi = self ._check_hemi (hemi )
822
824
@@ -895,6 +897,11 @@ def add_data(self, array, min=None, max=None, thresh=None,
895
897
data ['surfaces' ] = surfs
896
898
data ['colorbars' ] = bars
897
899
data ['orig_ctable' ] = ct
900
+
901
+ if remove_existing and self .data_dict [hemi ] is not None :
902
+ for surf in self .data_dict [hemi ]['surfaces' ]:
903
+ surf .parent .parent .remove ()
904
+
898
905
self .data_dict [hemi ] = data
899
906
900
907
def add_annotation (self , annot , borders = True , alpha = 1 , hemi = None ,
0 commit comments