Closed eurunuela closed 10 months ago
Just to check if this is a regression, can you quickly test with less recent versions of Nilearn if you have the same problem?
Just to check if this is a regression, can you quickly test with less recent versions of Nilearn if you have the same problem?
I have tried with 0.8, 0.10 and the dev version 😅
OK defo not a regression then. Or at least not a recent one.
I wonder if it is related to #3944 in any way.
Possibly. Will try to write a tiny regression test for it.
I can send you my file via Mattermost if you want @Remi-Gau!
na that's fine the test will have to be added to the test suite so it should only rely on data we can easily generate on the fly
Just to check: if you format the tick of the color bar to show more decimals does it make more sense?
See below
import numpy as np
from nilearn import plotting
from nilearn.conftest import _rng
from nilearn.surface.tests._testing import generate_surf
def _generate_data_test_surf_roi():
"""generate mash, roi map filled with 1 and -1 values, and parcellation"""
mesh = generate_surf()
roi_map = np.ones(mesh[0].shape[0])
roi_idx = _rng().randint(0, mesh[0].shape[0], size=10)
roi_map[roi_idx] = -1
parcellation = _rng().uniform(size=mesh[0].shape[0])
return mesh, roi_map, parcellation
mesh, roi_map, parcellation = _generate_data_test_surf_roi()
plotting.plot_surf_roi(
mesh,
roi_map=roi_map,
engine="matplotlib",
cmap="coolwarm",
colorbar=True,
vmin=-1.5,
vmax=1,
view="lateral",
cbar_tick_format="%.2g", # to make sure the values of ticks of the cbar are properly dsiplayed
)
plotting.show()
@ymzayek am realizing that in many cases the dummy data we use to test the plotting functions do not include any negative values.
this may be worth checking that our tests can handle those as well, no?
@Remi-Gau hm ok yes we should definitely check that. Are you referring to specific fixtures or internal testing data generators or all of it?
Concerning this issue, as pointed out in https://github.com/nilearn/nilearn/issues/4082#issuecomment-1780916405 seems to me like a formatting issue and not a bug. @eurunuela can you add cbar_tick_format="%.2g"
parameter to plot_surf_roi in your code and let us know what happens?
Concerning this issue, as pointed out in https://github.com/nilearn/nilearn/issues/4082#issuecomment-1780916405 seems to me like a formatting issue and not a bug. @eurunuela can you add cbar_tick_format="%.2g" parameter to plot_surf_roi in your code and let us know what happens?
Yes! That fixes the issue. It's quite odd though that the colorbar would show a minimum of 0. Thank you so much @Remi-Gau & @ymzayek!
Edit: But since the values are below 1, I guess it makes sense it only showed the 0.
Are you referring to specific fixtures or internal testing data generators or all of it?
Not checked them all but in nilearn/plotting/tests/test_surf_plotting.py
This one is function that genrates only 0 and 1: https://github.com/nilearn/nilearn/blob/5d32855dc6af30aad0aa3b20d6a650dddff1231f/nilearn/plotting/tests/test_surf_plotting.py#L705C1-L711C39
The img_3d_mni
fixture only contains positive values:
https://github.com/nilearn/nilearn/blob/5d32855dc6af30aad0aa3b20d6a650dddff1231f/nilearn/plotting/tests/test_surf_plotting.py#L817C1-L832C1
Yeah, it seems like you probably want to add a negative decimals example to your tests.
Yes we should have some second versions of those minimal fixtures with negative values. @Remi-Gau I suggest to open an issue detailing this and we can close this one if @eurunuela your reported issue is resolved.
My issue is resolved. Thank you!
I will let @Remi-Gau close this when he opens the issue for the tests.
plot_surf_roi is for showing atlas region indices, so it is meant to deal with positive integers only. we should probably raise an error when negative or floating-point values are passed to this function
from the documentation
The value at each vertex one inside the ROI and zero inside ROI, or an integer giving the label number for atlases.
I'll reopen this then. It makes sense to raise an error but I'm wondering about the use case of @eurunuela
I'd rather we open another one because the existing discussion about the colorbar distracts from the actual issue
Sure! I was misled by the name change. Closing again and will let you open it :)
Is there an existing issue for this?
Operating system
Operating system version
For example one of the following:
Python version
nilearn version
0.10.3.dev40+g0fa9ba3c
(from main) as of 07:56:43 UTC October 26th, 2023.Expected behavior
The map should have negative values.
vmax
was set to 0.3, andvmin
to -0.3.Current behavior & error messages
This is what I got:
Steps and code to reproduce bug