open-discussion > Change overlay transparency
Showing 1-2 of 2 posts
Display:
Results per page:
Jul 2, 2018  12:07 PM | nicobia
Change overlay transparency
Hi all,

I am new to MRIcroGL and I think it's a great software. However, I am facing a problem at the moment. I'd like to add 3 different overlays to the 'mni152_2009bet' image and I'd like the first two to have a transparency of 50% (so that It would be possible to see the brain underneath), while I'd like the third and last overlay to have 0% transparency so that it's not possible to see the tissue underneath.
I've tried to do it manually and also with a script, but I've failed. Could you please tell me how to do it?

Thanks,

Nico
Aug 1, 2018  08:08 PM | Chris Rorden
RE: Change overlay transparency
You will want to open the scripting window and use the function
  overlaylayertransparencyonbackground()
the implementation of this function has changed a little bit, but the attached image is generated with v1.0.20180622 using this script

begin
resetdefaults;
backcolor(255, 255, 255);
loadimage('mni152_2009_256');
//1st overlay, 50% = translucent
overlayload('motor');
overlayminmax(1, 2.6, 2.6);
overlaylayertransparencyonbackground(1, 50);
//2nd overlay, 50% = translucent
overlayload('motor');
overlayminmax(2, -2.6, -2.6);
overlaylayertransparencyonbackground(2, 50);
//3rd overlay, 0% = opaque
overlayload('motor');
overlayminmax(3, -6, -6);
overlaylayertransparencyonbackground(3, 0);
//display
mosaic('A H -0.2 -24 -16 32 50 60 S X R 0');
end.

or if you prefer Python:

import gl
gl.resetdefaults()
gl.backcolor(255, 255, 255)
gl.loadimage('mni152_2009_256')
#1st overlay, 50% = translucent
gl.overlayload('motor')
gl.overlayminmax(1, 2.6, 2.6)
gl.overlaylayertransparencyonbackground(1, 50)
#2nd overlay, 50% = translucent
gl.overlayload('motor')
gl.overlayminmax(2, -2.6, -2.6)
gl.overlaylayertransparencyonbackground(2, 50)
#3rd overlay, 0% = opaque
gl.overlayload('motor')
gl.overlayminmax(3, -6, -6)
gl.overlaylayertransparencyonbackground(3, 0)
#display
gl.mosaic('A H -0.2 -24 -16 32 50 60 S X R 0')
Attachment: overlay.png