How to set opacity in batch

Dear All ,

I am using the following to check coregistration between anatomical and functional image for 300 subjects. I am trying to change the opacity of the overlay functional image.This is usually achieved via the GUI interface by changing the value of the 6th arrow on the right hand side of the image with values ranging from 9 to 0.
By specifying opacity=4 in OPEN_WINDOW I don’t get the level of transparency which I would like to achieve and the functional image is completely opaque. How can I proceed to obtain image where functional image overlaid is transparent?

afni -com ‘OPEN_WINDOW A.sagittalimage opacity=4’ -com ‘SET_XHAIRS A.OFF’ -com “SWITCH_UNDERLAY brainmask.nii” -com “SWITCH_OVERLAY functional.nii.gz” -com “SAVE_JPEG A.sagittalimage $basedir/Sagittal/Coreg_${sub}.jpg” -com “QUIT”

Thanks,
Matilde

Can you post an image of what you get? I just tried that command on my computer, and the saved sagittal image did appear translucent.

Also, can I point out the @chauffeur_afni program that might help make snapshots more easily?
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/programs/@chauffeur_afni_sphx.html#ahelp-chauffeur-afni
It basically wraps around a lot of AFNI driving functionality, and you can ~easily specify montages, overlay ranges, thresholding, slice location as ijk or xyz, labels, colorbars, etc.

–pt

tttt.jpg

Thanks for swift reply! I saw @chauffeur_afni but would be great if I got things working with the current script, I am also confused on why it is not working. See attached for the image I got.
Matilde

I think the order matters of the commands-- try moving the opacity sending to later:


afni \
     -com "SWITCH_UNDERLAY brainmask.nii"                                 \
     -com "SWITCH_OVERLAY functional.nii.gz"                              \
     -com 'SET_XHAIRS A.OFF'                                              \
     -com 'OPEN_WINDOW A.sagittalimage opacity=4'                         \
     -com "SAVE_JPEG A.sagittalimage $basedir/Sagittal/Coreg_${sub}.jpg"  \
     -com "QUIT" 

… I usually load the datasets first, as above, then do the other types of commands.

–pt

Also, I will note again the benefits of @chauffeur:

  • it makes images in all 3 planes (axi, sag, cor) with one command
  • it runs in a virtual environment, so the GUI doesn’t open up on your screen-- meaning you can run it on remote systems
  • I think there is less syntax to worry about…

To do exactly what you are doing, you could run:


@chauffeur_afni \
-ulay  brainmask.nii             \
       -olay  functional.nii.gz    \
        -set_xhairs OFF                   \
        -prefix test2 \
        -opacity 4 \
        -cbar "Spectrum:red_to_blue" \
        -montx 1 \
        -monty 1 \
        -save_ftype JPEG

–pt

Thanks, unfortunately this does not fix the problem. But I am able to have the mont option working , which I believe works via the same mechanism as opacity
for example
afni
-com “SWITCH_UNDERLAY brainmask.nii”
-com “SWITCH_OVERLAY functional.nii.gz”
-com ‘SET_XHAIRS A.OFF’
-com ‘OPEN_WINDOW A.sagittalimage mont=6x6:3’
-com “SAVE_JPEG A.sagittalimage $basedir/Sagittal/Coreg_${sub}.jpg”
-com “QUIT”

I appreciate the @chaffeur afni but I am running on a server where old versionof afni is installed and don’t have much room for updating versions etc at the moment. (Version AFNI_2011_12_21_1014 [[Precompiled binary linux-xorg7_64: Jan 15 2014]]

I temporarily sorted by changing afni environment with
export AFNI_DEFAULT_OPACITY=4
in this way the following command

afni
-com “SWITCH_UNDERLAY brainmask.nii”
-com “SWITCH_OVERLAY functional.nii.gz”
-com ‘SET_XHAIRS A.OFF’
-com ‘OPEN_WINDOW A.sagittalimage mont=6x6:3’
-com “SAVE_JPEG A.sagittalimage $basedir/Sagittal/Coreg_${sub}.jpg”
-com “QUIT”

generates an image where the overlay is transparent, however not clear why opacity=4 does not work

Ummm, 2014 is a lifetime ago. I would have to strongly recommend updating AFNI on that server!!

I don’t know why opacity is not working as it should… It could be something related to that specific version (either the year or that year with the linux-xorg binaries), in which case it won’t be resolvable.

Do you have another computer with a more uptodate AFNI on it to try to use? You could download the data and try that?

–pt