diff --git a/setup.cfg b/setup.cfg index 9bc24df..b869886 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,4 +12,6 @@ filterwarnings = ignore:.*ufunc size changed.*:RuntimeWarning ignore:Using or importing the ABCs:DeprecationWarning ignore:the imp module is deprecated in favour of importlib:DeprecationWarning + ignore:.*trait handler has been deprecated.*:DeprecationWarning + ignore:.*rich_compare.*metadata.*deprecated.*:DeprecationWarning ignore:Matplotlib is building the font cache using fc-list. This may take a moment.:UserWarning diff --git a/surfer/tests/test_viz.py b/surfer/tests/test_viz.py index 5bb6b18..206d1f2 100644 --- a/surfer/tests/test_viz.py +++ b/surfer/tests/test_viz.py @@ -214,10 +214,14 @@ def test_data(): def test_data_limits(): """Test handling of data limits.""" _set_backend() - brain = Brain(*std_args) - surf_data = np.zeros(163842) + brain = Brain('fsaverage', 'both', 'inflated') + surf_data = np.linspace(0, 1, 163842) pytest.raises(ValueError, brain.add_data, surf_data, 0, 0) - brain.add_data(surf_data, 0, 1) + brain.add_data(surf_data, 0, 1, hemi='lh') + assert brain.data_dict['lh']['fmax'] == 1. + brain.add_data(surf_data, 0, 0.5, hemi='rh') + assert brain.data_dict['lh']['fmax'] == 1. # unmodified + assert brain.data_dict['rh']['fmax'] == 0.5 brain.close() diff --git a/surfer/viz.py b/surfer/viz.py index 2b46ff1..846d3e5 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -1200,7 +1200,7 @@ def time_label(x): self._data_dicts[hemi].append(data) self.scale_data_colormap(min, mid, max, transparent, center, alpha, - data) + data, hemi=hemi) if initial_time_index is not None: self.set_data_time_index(initial_time_index) @@ -1951,7 +1951,8 @@ def _brain_color(self): @verbose def scale_data_colormap(self, fmin, fmid, fmax, transparent, - center=None, alpha=1.0, data=None, verbose=None): + center=None, alpha=1.0, data=None, + hemi=None, verbose=None): """Scale the data colormap. The colormap may be sequential or divergent. When the colormap is @@ -1994,15 +1995,19 @@ def scale_data_colormap(self, fmin, fmid, fmax, transparent, The data entry for which to scale the colormap. If None, will use the data dict from either the left or right hemisphere (in that order). + hemi : str | None + If None, all hemispheres will be scaled. verbose : bool, str, int, or None If not None, override default verbose level (see surfer.verbose). """ divergent = center is not None + hemis = self._check_hemis(hemi) + del hemi # Get the original colormap if data is None: - for h in ['lh', 'rh']: - data = self.data_dict[h] + for hemi in hemis: + data = self.data_dict[hemi] if data is not None: break table = data["orig_ctable"].copy() @@ -2015,14 +2020,15 @@ def scale_data_colormap(self, fmin, fmid, fmax, transparent, views = self._toggle_render(False) # Use the new colormap - for hemi in ['lh', 'rh']: + for hemi in hemis: data = self.data_dict[hemi] if data is not None: for surf in data['surfaces']: cmap = surf.module_manager.scalar_lut_manager cmap.load_lut_from_list(lut / 255.) if divergent: - cmap.data_range = np.array([center-fmax, center+fmax]) + cmap.data_range = np.array( + [center - fmax, center + fmax]) else: cmap.data_range = np.array([fmin, fmax]) @@ -2050,7 +2056,7 @@ def scale_data_colormap(self, fmin, fmid, fmax, transparent, l_m.load_lut_from_list(lut / 255.) if divergent: l_m.data_range = np.array( - [center-fmax, center+fmax]) + [center - fmax, center + fmax]) else: l_m.data_range = np.array([fmin, fmax])