Closed dlevitas closed 3 years ago
I assume you are running the latest stable release and that in the Preferences window you have selected the "Quality: Better" (assuming your hardware supports these features). You can try the demo script below, which illustrates several methods to show subcortical information. The script below is based on the Scripting/Python/subcortical menu item, but adds two additional rotations which illustrate the Xray sliders.
import gl
gl.resetdefaults()
kframesperrotation = 180
gl.meshload('BrainMesh_ICBM152_smoothed.lh.mz3')
gl.meshcurv()
gl.overlayload('CIT168.mz3')
gl.azimuthelevation(250, 35)
gl.meshhemisphere(-1)
for i in range(0, kframesperrotation * 7):
rot = (i / kframesperrotation)
if ((i % kframesperrotation) == 0):
shader = 'Default'
if rot == 0:
shader = 'hidecurves'
elif rot == 1:
shader = 'outline'
elif rot == 2:
shader = 'wire'
elif rot == 3:
shader = 'squares'
elif rot == 4:
shader = 'xGaps'
else :
shader = 'MatCap'
gl.shadername(shader)
print('shader: ' + shader)
azimuth = round((i * 360.0/kframesperrotation) % 360)
xrayObj= 1.0
if (rot == 5):
xrayObj = abs(180 - azimuth) / 180
xrayOver= 0.0
if (rot == 6):
xrayOver = 1.0 - abs(180 - azimuth) / 180
gl. shaderxray(xrayObj, xrayOver);
gl.azimuthelevation(int(azimuth), 35);
gl.wait(20)
#if (azimuth == 270):
# gl.savebmp(str(rot)+'.png')
Thanks for this illustrative code! I've modified it a bit, but I'm unable to quite get it to do what I'd like. I was hoping to generate something like this image or along the lines of fsleyes, where you can adjust the opacity of the underlay and overlay separately. It's not clear to me how to script that functionality into surf-ice. Currently, adjusting the xray slider (or most of the slides for that matter) acts on both the underlay and overlay.
I can not replicate your experience. If I run the script below, I get the image shown. Manually adjusting the left Xray slider makes the cortical image less/more transparent. Manually adjusting the right slider makes the subcortical objects more/less visible without changing the opacity of the cortex. These two sliders can be controlled by the shaderxray function in a script.
import gl
gl.resetdefaults()
gl.meshload('BrainMesh_ICBM152_smoothed.lh.mz3')
gl.meshcurv()
gl.overlayload('CIT168.mz3')
gl.meshhemisphere(-1)
gl.shadername('Default')
gl.shaderxray(1.0, 0.5);
Ah, I see. The issue for me was that the overlay was a nifti (.nii.gz) file. Using the nii_nii2objMesh
function I was able to "meshify" it and now it appears as a separate object (i.e. not on the underlay mesh surface), which allows me to work the x-ray slider the way I'd intended.
Thanks again for the assistance.
You can set the opacity for color layers using the "Opacity" slider in the "Overlays" menu. Note that a single mesh can have several layers painted on it, and you can set each layer's opacity independently. To adjust this in a script, you use the overlayopacity()
function where the first argument identifies the layer, and the second is the opacity in the range 0 (transparent) to 100 (translucent). The Scripting/Python/Help will list all functions and their arguments. The script below makes the overlay translucent (50%):
import gl
gl.resetdefaults()
gl.meshload('BrainMesh_ICBM152.rh.mz3')
gl.overlayload('motor_4t95vol.nii.gz')
gl.overlayminmax(1,2,12)
gl.overlayopacity(1,50)
That's good to know. I've been using the point-and-click method thus far, but my goal is to switch to scripting the desired surf-ice behavior.
Using the newest version of surf-ice, I've loaded the mni152_209.curv file, and overlaid a NIFTI file containing an subcortical ROI that I eroded. I tried following these steps to better show the subcortical structure, but all it does is adjust the dimness of both files, such that it never reveals the subcortical structure unless I adjust the depth slider. So far, I haven't been able to use the X-ray slider as specified in the documentation.