nipy / PySurfer

Cortical neuroimaging visualization in Python
https://pysurfer.github.io/
BSD 3-Clause "New" or "Revised" License
239 stars 98 forks source link

ADD: first draft of plot_custom_colours script #239

Closed LauraGwilliams closed 6 years ago

LauraGwilliams commented 6 years ago

Hi @larsoner,

I have (finally - I'm sorry) put together a draft of the script that allows for plotting custom rgba values. Any feedback is appreciated!

Thanks, Laura

Closes #228

agramfort commented 6 years ago

@LauraGwilliams can you see why travis complains?

mwaskom commented 6 years ago

I'm not sure the failures are related to this PR (looks like upstream dependency issues?) but once they're sorted out I think this is still going to be broken because pysurfer doesn't install MNE or its sample data during the CI build.

I also think including the MEG-related steps of upsampling/smoothing/etc. adds a lot of complexity to the example, which is already demonstrating something that's much more complex than any of our other scripts.

Could I please request dropping the MNE imports and simplifying the example substantially? Reading in one of our full-resolution fMRI-derived example files will skip a lot of code that seems orthogonal to adding an independent alpha channel. I'd suggest something obvious like reading in lh.sig.nii.gz and setting the alpha baed on one of the (normalized) x/y/z coordinates, or maybe using the (absolute and normalized) lh.alt_sig.nii.gz image.

larsoner commented 6 years ago

Could I please request dropping the MNE imports and simplifying the example substantially? Reading in one of our full-resolution fMRI-derived example files will skip a lot of code that seems orthogonal to adding an independent alpha channel. I'd suggest something obvious like reading in lh.sig.nii.gz and setting the alpha baed on one of the (normalized) x/y/z coordinates, or maybe using the (absolute and normalized) lh.alt_sig.nii.gz image.

Agreed. Really anything for demonstration purposes would work, even setting the color of the brain based on the Z coordinate value (higher is hotter!) or something.

LauraGwilliams commented 6 years ago

OK, no problem! Is there a simple way of loading the x, y, z + triangles from a nii.gz file, such that the rest of the code can stay pretty much the same? I'm having trouble googling the answer to this.

Thank you!

larsoner commented 6 years ago

http://nipy.org/nibabel/reference/nibabel.freesurfer.html#nibabel.freesurfer.io.read_geometry

on e.g. SUBJECTS_DIR/subject/surf/lh.white for white left hemi

mwaskom commented 6 years ago

The lh.white file is about 5Gb, which isn't huge, but we should avoid adding something that size to the code repository if possible. It should be sufficient to build a path using the $SUBJECTS_DIR environment variable, because anyone who is using pysurfer will have this file (and it will exist on travis because we use the basic fsaverage files to run tests).

Once the PR is finalized, I think you'll need to do a rebase so that the checked-in and then removed data file doesn't end up in master. Let us know if you need help with that.

mwaskom commented 6 years ago

A related question for @larsoner, @agramfort : this example is revealing that several useful attributes of the Brain attribute (the mlab figure and the geometry) are private. This keeps the public namespace from getting too cluttered, but using them would make this (and similar) applications even easier. Exposing them should probably go in a different PR, but seems like a good idea?

larsoner commented 6 years ago

e.g. brain.geo['lh'].coords is already public, that could be used. But sure making the figures public is reasonable. We can tell them not to modify them or things might break.

mwaskom commented 6 years ago

e.g. brain.geo['lh'].coords is already public, that could be used.

I'm not sure I knew about that! I'm not sure it's used in any examples ... might be good to add here.

LauraGwilliams commented 6 years ago

I don't understand what Travis is complaining about -- am I trying to import something that's not allowed?

larsoner commented 6 years ago

Fixed in #240 which has now been merged. If you rebase you should get meaningful feedback.

Also feel free to use brain.geo['lh'].coords instead of manually loading the coordinates, it will simplify things a little bit.

LauraGwilliams commented 6 years ago

OK! Is there a way of extracting the triangles from brain.geo, too? I can only find the x, y, z...

larsoner commented 6 years ago

brain.geo['lh'].faces

larsoner commented 6 years ago

Output looks a bit weird but I think it's just a depth rendering / opacity thing:

https://118-1551431-gh.circle-artifacts.com/0/html/auto_examples/plot_custom_colours.html

If you make it opaque it might look better?

Flake errors:

https://travis-ci.org/nipy/PySurfer/jobs/386205300#L1174

larsoner commented 6 years ago

Also let's go with colors instead of colours in the filename for consistency :)

agramfort commented 6 years ago

thx @LauraGwilliams !

LauraGwilliams commented 6 years ago

Thank you for all your help with this!! :)

mwaskom commented 5 years ago

Thanks again for contributing this @LauraGwilliams! I just had the opportunity to make one of these figures and it was very easy with your completed example!

LauraGwilliams commented 5 years ago

Ah, great, I'm happy to hear @mwaskom! :D