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
Passing negative values as threshold for plotting #4340
Comments
@bthirion said: It's unclear to me whether the threshold has "one-tail" or "two-tail" behavior. The doc implies that is it two-tail, but we cold have cases where a one-tail behavior is expected ? |
That was why I was testing this. Less common but visualizing "deactivations" only may be something users want to do. I'd be in favor of doing this in another PR after #4338 (even it means reverting it) just to make sure that we first align doc and behavior with the minimum amount of changes to the code. |
@bthirion I created a separate issue to make discussions easier. |
In relation to #4338 (comment)
Tried to see what the plotting behavior is at the moment: top row the image is unthresholded before plotting, bottom row it is threshold is one tail thresholded at -1 import matplotlib.pyplot as plt
from nilearn import datasets, plotting,
from nilearn.image import threshold_img
stat_img = datasets.load_sample_motor_activation_image()
thresholded_img = threshold_img(
stat_img,
threshold=-1,
cluster_threshold=0,
two_sided=False,
copy=True,
)
fig, axes = plt.subplots(
2,
2,
figsize=(20, 10),
)
for i, image in enumerate([stat_img, thresholded_img]):
for j ,threshold in enumerate([-1, 1]):
txt = "unthresholded"
if image == thresholded_img:
txt = "thresholded at -1"
plotting.plot_stat_map(
image,
colorbar=True,
threshold=threshold,
symmetric_cbar=False,
cmap="black_red",
title=f"image {txt}; plotting threshold: {threshold}",
axes = axes[i,j]
)
plt.show() OK so we do want to make sure that people can plot things like in the bottom left (only see things above a negative threshold). As #4338 goes it would prevent this and for users to only be able to get what's in the bottom right. At the same time, the top left is very unclear as to what one would expect to see. |
To me it makes sense: it means that the plotting threshold is a property of the colorbar, not of the image. |
So this would be "just" a color bar bug for you? That seems fair. |
Can you clarify what the bug is in the above example ? |
bottom left (image thresholded at -1; plotting threshold: -1)The doc says:
So I would not expect to see anything between -1 and 1. I understand that some people may want to see values that are > -1, but I would not expect the code to be able to do that given the doc. top left (image unthresholded; plotting threshold: -1)
|
OK, so when the threshold is negative, there another behavior that the one documented. We need to decide whether we are please with it. In any case, we need to revise the doc. |
Note passing a negative values as threshold is ignored and does not throw warnings:
gives
Where as I would expect the same as for
threshold = 0.5
given that the threshold is supposed to act on absolute value according to the doc.Originally posted by @Remi-Gau in #4296 (comment)
The text was updated successfully, but these errors were encountered: