-
Notifications
You must be signed in to change notification settings - Fork 100
Conjunction Map: overlap not working for brain with both hemispheres #281
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
Comments
Any suggestions please ? |
I think I can confirm this one, but I don't understand it yet. Here is a self-contained example: b = Brain("fsaverage", "both", "white", cortex=None, background="black")
b.show_view("dor")
n = 163842
for hemi in ["lh", "rh"]:
for colormap in ["Reds", "Blues"]:
data = np.random.randn(n)
b.add_data(data, min=0, max=1, thresh=0, colormap=colormap, colorbar=False, hemi=hemi) With PySurfer 0.9.0, this renders: Watching the plot appear, it's clear that the right hemisphere has two separate overlays but they both appear with the |
Hm, this issue is very flaky and didn't persist across a notebook kernel restart. |
Doh, forgot that I had activated the master branch to start a bisect before restarting the kernel. So whatever this is, it seems fixed on master. |
@mattvan83 it also looks like your original example runs fine on master. |
@mwaskom ok I will test it. So what do you call master, the last release of PySurfer? |
“Master” means the current status of the master branch on this github repository. It implies a newer version of the library than what pip or conda give you by default, although you can use pip to install it pretty easily (I’m not sure if that’s true for conda as well). By the way @larsoner we haven’t released in a while and may want to do that after we sort out the other issues that @mattvan83 has run into. |
I tried with the master (0.10.dev0) and it still didn't work. Please find the exact code and raw data I used attached:
Do you have any idea? |
Sorry with the attached file. |
Can you please specify what "it didn't work" means? |
Can you please tell me what happens when you run the self-contained example I posted in this thread? It's really a lot easier to work with simple examples that don't require downloading external data, if possible. |
Unfortunately, I can confirm that there is still a major bug in import os
import numpy as np
import nibabel as nib
import matplotlib.pyplot as plt
from surfer import Brain
b = Brain("fsaverage", "both", "white", background="black")
b.show_view("dorsal")
screenshots = []
colormaps = iter(["Reds", "Blues", "Purples", "Greens"])
for hemi in ["lh", "rh"]:
coords, _ = nib.freesurfer.read_geometry(
os.path.join(os.environ["SUBJECTS_DIR"], f"fsaverage/surf/{hemi}.white")
)
for sign in [-1, +1]:
colormap = next(colormaps)
b.add_data(np.sign(coords[:, 1]) == sign,
colormap=colormap, min=0, max=2, thresh=.5,
colorbar=False, verbose=False, hemi=hemi)
screenshots.append(b.screenshot())
b.close()
f, axes = plt.subplots(1, len(screenshots), figsize=(len(screenshots) * 3, 3))
for ax, img in zip(axes, screenshots):
ax.imshow(img)
ax.set_axis_off()
f.tight_layout()
f.savefig("add_data_bug.png") You can see that adding data on the right hemisphere is changing the properties of the last data array added to the left hemisphere. I suspect that it has to do with |
Unfortunately I don't remember -- I always have to re-learn what those loops are doing when I look at them, too :( |
Any trick to subvert the problem? This is pretty common when mapping on the cortical surface overlap between two patterns. |
Plenty of tricks. The issue arises when you're not plotting the same set of arrays on the left and right hemispheres. If you can work around having to conditionally add overlays depending on whether they pass the threshold (a constraint imposed by mayavi that i find annoying), you won't see the issue. One idea would be to use the fact that adding So instead of In a quick test, this produces a figure that looks right. |
@mwaskom do you think we should just release now? We can take up |
No, I think this issue is a blocker because it produces incorrect figures. |
@mwaskom pushed a release to PyPi and updated docs, would you be up for sending a release email (if you think it's necessary/useful) whenever there's time? |
Dear PySurfer,
I tried to save different brain views of data overlap inspired from the example below:
Buth when comparing the different views' results I realized that conjunction map was not working correctly in some of the cases on the views with both hemispheres. Indeed, you can see that on the right hemisphere views conjunction map is well noticeable in purple colour, whereas on the views with both hemipsheres the conjunction map is not visible in the right hemisphere.
Please find below the code I used and attached the raw data and images resulting:
Could anyone help me with this problem?
Best,
Matthieu
ConjunctionOverlays.zip
The text was updated successfully, but these errors were encountered: