New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] Allow setting vmin
in plot_glass_brain
and plot_stat_map
#3993
Conversation
👋 @michellewang Thanks for creating a PR! Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft. Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.
For new features:
For bug fixes:
We will review it as quick as possible, feel free to ping us with questions if needed. |
Codecov Report
@@ Coverage Diff @@
## main #3993 +/- ##
==========================================
- Coverage 91.65% 91.59% -0.06%
==========================================
Files 145 145
Lines 16222 16238 +16
Branches 3370 3376 +6
==========================================
+ Hits 14869 14874 +5
- Misses 810 817 +7
- Partials 543 547 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
vmin
argument to plot_glass_brain
and plot_stat_map
vmin
in plot_glass_brain
and plot_stat_map
Thx @michellewang for working on this! The example plots look great! Will give a more thorough review soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall all, looks pretty good! Can you explain the refactoring concerning the plotting of absolute values?
Yes, I had to move the thresholding because it needs to happen after we take the absolute value of the data (which happens in I'll remove the lines with |
Also: are there any tests for slicers and |
Slicers are tested in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall ! Thx !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Can you consider codecov complaints ?
nilearn/plotting/tests/test_img_plotting/test_plot_glass_brain.py
Outdated
Show resolved
Hide resolved
nilearn/plotting/tests/test_img_plotting/test_plot_glass_brain.py
Outdated
Show resolved
Hide resolved
Not sure why that is happening. I checked the report and the added code is fully covered and the codecov/patch report is 100% so I think it's ok. Seems like there is a small decrease on the project level but this seems to come from indirect changes. I think @michellewang you can just make the changes from the last review and this should be good to go. |
6999ba5
to
58f717d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI something went wrong with the merge so I redid it. This PR LGTM, thanks @michellewang!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx.
if threshold is not None: | ||
data = _safe_get_data(img, ensure_finite=True) | ||
if threshold == 0: | ||
data = np.ma.masked_equal(data, 0, copy=False) | ||
else: | ||
data = np.ma.masked_inside( | ||
data, -threshold, threshold, copy=False | ||
) | ||
img = new_img_like(img, data, img.affine) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- removing this causes a regression [BUG] plot_roi cannot handle cmap with only 1 level #4255
Changes proposed in this pull request:
plot_glass_brain
use itsvmin
argument instead of silently ignoring it_get_colorbar_and_data_ranges
, which changes the behaviour ofplot_stat_map
to also allowvmin
to be set (instead of throwing an error)symmetric_cbar
, since the colorbar will no longer be restricted to(-vmax, vmax)
,(0, vmax)
,(-vmax, 0)
, and the colormap range will also change depending onvmin
/vmax
symmetric_data_range
argument from_get_colorbar_and_data_ranges
, which was added in [ENH] addvmin
argument toplotting.plot_img_on_surf
#3873 to preserve the old behaviour in these functions. We can still get the symmetric data range behaviour if:symmetric_cbar
isTrue
, orsymmetric_cbar
is'auto'
,vmin
orvmax
isNone
, and the data has both positive and negative values_get_colorbar_and_data_ranges
to have clearer expected resultsexamples/01_plotting/plot_demo_glass_brain_extensive.py
Example
plot_glass_brain
calls withvmin
:Example
plot_stat_map
calls withvmin
: