Skip to content

Commit

Permalink
Add check for vmin, vmax in plot_surf_roi (nilearn#2052)
Browse files Browse the repository at this point in the history
* added check for vmin, vmax

Passed vmin, vmax values were being overwritten by default values. Added check to use default vmin, vmax if no parameters are passed

* remove commented out code

* unit test for plot_surf_roi

* add plot_surf_roi fixes to whats_new
  • Loading branch information
boredStats authored and kchawla-pi committed Oct 8, 2019
1 parent e0ae31c commit 2ead4d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Fixes
- :func:`nilearn.plotting.view_surf` now accepts surface data provided as a file
path.
- :func:`nilearn.plotting.plot_matrix` providing labels=None, False, or an empty list now correctly disables labels.
- :func:`nilearn.plotting.plot_surf_roi` now takes vmin, vmax parameters
- :func:`nilearn.datasets.fetch_surf_nki_enhanced` is now downloading the correct
left and right functional surface data for each subject
- :func:`nilearn.datasets.fetch_atlas_schaefer_2018` now downloads from release
Expand Down
5 changes: 4 additions & 1 deletion nilearn/plotting/surf_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,10 @@ def plot_surf_roi(surf_mesh, roi_map, bg_map=None,
# messages in case of wrong inputs

roi = load_surf_data(roi_map)
vmin, vmax = np.min(roi), 1 + np.max(roi)
if vmin is None:
vmin = np.min(roi)
if vmax is None:
vmax = 1 + np.max(roi)

mesh = load_surf_mesh(surf_mesh)

Expand Down
8 changes: 8 additions & 0 deletions nilearn/plotting/tests/test_surf_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ def test_plot_surf_roi():
# plot roi
plot_surf_roi(mesh, roi_map=roi_map)
plot_surf_roi(mesh, roi_map=roi_map, colorbar=True)
# change vmin, vmax
img = plot_surf_roi(mesh, roi_map=roi_map,
vmin=1.2, vmax=8.9, colorbar=True)
cbar = img.axes[-1]
cbar_vmin = float(cbar.get_yticklabels()[0].get_text())
cbar_vmax = float(cbar.get_yticklabels()[-1].get_text())
assert cbar_vmin == 1.2
assert cbar_vmax == 8.9

# plot parcellation
plot_surf_roi(mesh, roi_map=parcellation)
Expand Down

0 comments on commit 2ead4d0

Please sign in to comment.