Last active
December 13, 2019 04:17
-
-
Save danlurie/691d0cea1b2c74b227e11d32147e9823 to your computer and use it in GitHub Desktop.
Python Surface Plotting
Hi! I think there are two things going on here:
The sign of the diffusion embedding gradient is arbitrary, and will randomly flip each time the algorithm is run (unless you set a random seed).I forgot that the notebook doesn't actually do the embedding. Not sure what's happening; I'll need to look into it as well.- I would need to dig a bit, but it looks like
plot_surf
has changed how it handles (exactly) zero values (which are areas of the surface mesh for which there is no data). In my gist, they show up as grey, whereas for you they're showing up as the middle color of the colormap. The latter is the behavior I also currently see innilearn
. A quick way to fix this (based again on the fact that the gradient sign and values are arbitrary), is:
from sklearn import preprocessing
scaler = preprocessing.MinMaxScaler(feature_range=(0.00001, 1)
ed_scaled = scaler.fit_transform(ed.reshape(-1, 1))[:, 0]
Then, when plotting: use vmin=0, vmax=1.0, threshold=0.00001
. This will avoid coloring the empty areas.
Didn't expect feedback to happen this quick!
For replication I (first flipped the sign of ed
then) applied the scaler.
ed = -np.loadtxt('./ _insert_appropriate_location_ /LG400_Med.txt')
scaler = preprocessing.MinMaxScaler(feature_range=(0.00001, 1))
ed_scaled = scaler.fit_transform(ed.reshape(-1, 1))[:, 0]
Now, the result shows as below:
I think it is (sort of) finally replicated well! (Used data from LG400_Med.txt on your gist)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I tried to reproduce this notebook, the colors are exactly opposite of what's shown here.
Plotting with -X[idx] instead of X[idx] seems to give exactly the same output as one shown here,
so either nilearn(or other packages) slightly changed its behavior, or the notebook is not actually the final run result.
Maybe worth checking out?
Edit: Also (when values of X is sign-reversed) in the second(medial) plot,

the corpus callosum region shows as dark green not gray.