-
Notifications
You must be signed in to change notification settings - Fork 23
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
Possible to save image with transparent background? #41
Comments
Nice! Didn't now that :) Unfortunately I am using a python script to generate my plots, is there also a way to implement this in my script? |
Your preferences are stored between sessions, so you can set it once with the user interface and the scripts should use the current setting. |
Interesting, this is actually the case for me. Still the image get's generated with the white background when I run my python script within the script editor of Surf Ice: import gl
gl.resetdefaults()
# load default brain
gl.meshload('BrainMesh_ICBM152.mz3')
# make brain look pinkish
gl.meshcolor(210, 148, 148)
# overlay roi image
gl.overlayload('input/to/rois.nii.gz')
# choose color for ROIS by playing around with the name of
# the colorscale, and the second and third argument of overlayminmax
gl.overlaycolorname(1,'electric-blue')
gl.overlayminmax(1,0.01,1.8)
# show left or right side of the brain
gl.viewsagittal(0)
# To get the left hemisphere only:
gl.clipazimuthelevation(0.5,90,0)
# save plot
gl.bmpzoom(1)
gl.savebmp('/output/path/rois.png') |
I am unable to replicate. I notice that your are running Surfice with software emulation (Mesa 23.0.4). Why don't you try this with a computer that has hardware accelerated graphics. import gl
gl.resetdefaults()
gl.azimuthelevation(70, 15)
gl.meshload('BrainMesh_ICBM152.rh.mz3')
gl.overlayload('motor_4t95vol.nii.gz')
gl.overlayminmax(1,2,12)
gl.overlayload('motor_4t95vol.nii.gz')
gl.overlayminmax(2,-1,-2)
gl.colorbarvisible(1)
gl.overlaytransparencyonbackground(25)
gl.meshcurv()
gl.backcolor(255,0,0)
gl.savebmp('rois.png') |
I can recreate your working example on a local machine with an Nvidia GPU. I am using surfice on a virtual machine that does not have a graphics card. Also, surfice is used here as an environment module (https://modules.readthedocs.io/en/latest/index.html). I wonder what is causing the problem here, the fact that the VM has no GPU or because of the deployment. I'm currently guessing the former, because even with environment modules my settings should be stored in my local home directory on my virtual machine (you can also see this in the stdout):
Can you replicate the "bug" (missing transparency although it is turned on) when using a machine without a GPU? |
Feature Request
Hi! Thanks for much for this wonderful visualization toolbox! I wonder if it's also possible to save my image with a transparent background?
Right now I am using python scripting and my script ends with
gl.savebmp('filename.png')
. This will generate .png file that contains my brain image with a white square background. Would be nice to set the white background to transparent :)Version
The text was updated successfully, but these errors were encountered: