Closed ctw closed 8 years ago
Using a new alpha transparency keyword for the Brain constructor might make this feature more accessible and I'm happy to change the implementation accordingly if that's preferred.
I think this would be my preference, but others can comment. It's also possible that opacity
would be a more obvious parameter name.
Also one weird thing about implementing it through the curvature overlay is that I would think in most cases when you want a semi-transparent cortical mesh you don't want to be showing curvature (it will only complicate things).
I agree that it's a bit annoying that one can only specify alpha when curv is True in the current implementation (although by specifying sufficiently large absolute values for vmin and vmax one can effectively eliminate the contrast). Will change to use a keyword argument unless others object. It seems like "alpha" is the standard keyword argument for transparency (e.g., in add_data
, add_annotation
, add_label
, and add_foci
), that's why I chose it over opacity
.
+1 for keyword
On further reflection, I'd like to refactor the interface to Brain
a bit more as follows:
I would like to deprecate the curv
keyword in favor of allowing the cortex keyword to accept colors (in addition to the currently allowed inputs). If a color is specified, a solid brain (without the curvature) is drawn in that color. This would add the new functionality of allowing the user to specify the color a solid brain is drawn in and eliminate one keyword.
To summarize I propose the following changes:
alpha
keyword to specify transparency of the brain surface.cortex
as is, but also allow specification of a color (rather than color map) to produce a solid brain surface (without curvature) in that color. If cortex
is set to None
the same output is produced as if curv
is set to False
in the current interface.curv
for backward compatibility, but set the default to None
and throw a warning that it is deprecated and will be removed in a future version if it is changed from the default value.Any thoughts?
no objection
I've made the proposed changes. Please let me know if you have questions and/or suggestions for improvements.
Please make sure that you update the pysurfer
script to reflect this changes and also that you add a note to the CHANGES
file.
You will also want to look at the example scripts and make sure that none of them are using curv
. Then you should probably add an example script to show a semi-transparent brain (perhaps demonstrating how to add subcortical foci). It would also be good to update at least one other example script to cover the new functionality for specifying the curvature values.
I've made the suggested changes. None of the existing example scripts were affected by the changes, but I've added a new one where alpha transparency is specified and a color is passed to cortex instead of a colormap.
Thanks! Would you mind showing the output of the example script here in the thread so I don't need to pull down your changes and build the docs?
I guess one thing to think about (though it goes against my earlier concerns that the cortex=
parameter is too complicated: instead of (or complementing) the (colormap, min, max, reverse)
tuple, a much better API might just be a pair of colors giving the color of sulci and gyri. It would be easy to take that pair and generate a colormap with our existing code. Does anyone have thoughts about this option?
I'm having trouble building the docs, at least partly, it seems, because I don't have freesurfer installed. Is there another way?
I like the option of being able to pass two colors to cortex, but the subsequent call to mlab.pipeline.surface expects the colormap to be specified by a string, so getting this to work would seem to require some refactoring.
I like the option of being able to pass two colors to cortex, but the subsequent call to mlab.pipeline.surface expects the colormap to be specified by a string, so getting this to work would seem to require some refactoring.
I think you can take a look in Brain.add_data
to see how custom colormaps are set there.
Otherwise the arguments look reasonable to me
I've added the option to pass a list of colors as argument for cortex as suggested by @mwaskom.
Thanks @Eric89GXL -- fixed now!
Looks like there are a number of un-covered relevant lines, can you write some simple tests that at least touch them? Can't really test the output but it can at least make sure some inputs get parsed.
Otherwise LGTM, +1 for merge. Example looks cool.
Ahh good I see "small fix" in the commit message to justify my nitpick :)
PEP8 line length
@mwaskom feel free to merge if you're happy, too
@mwaskom any chance this can be merged?
Hi, sorry. I started my postdoc last month and also just adopted a dog so I'm dropping things left and right. But if this looks good to @Eric89GXL it looks good to me.
I have added the option to specify alpha transparency for Brain binarized curvature rendering. This can be useful when plotting foci in internal structures that are otherwise obscured by the brain surface. I had considered adding an "alpha" keyword to the Brain interface, but opted instead to allow for alpha transparency to be specified in the cortex keyword. I've implemented the chance in a way that should ensure backward compatibility with code specifying the cortex keyword as a 4-tuple or string (in these cases alpha defaults to 1.0). Using a new alpha transparency keyword for the Brain constructor might make this feature more accessible and I'm happy to change the implementation accordingly if that's preferred.