Hoping for some aesthetic assistance with a brain image. I am trying to create an image with a semi-transparent background for part of the overlay image and non-transparent for the rest of the overlay. Is there a way to do this with the AFNI viewer? (I know you can control the transparency of the overlay as a whole, but I just want to do part of it). I am attaching an example image, where I would like the grey color to be semi-transparent.
Hi, Thanks for getting back to me so quickly. I have a network mask (in grey) and the colored areas show voxels that are significant for a contrast within the network. We want to show which areas of the brain are included in the network referenced against the results of the statistical test. My colleague tells me there may be a way to do this in photoshop so I might migrate the images over there if it doesn’t work out to do them directly in AFNI.
Actually, we do have something that might suit what you want…
Have you tried the “alpha” and “boxed” features in the GUI? This refers to the ‘A’ and ‘B’ button at the top of the GUI near the “Thr” button. It’s described a bit in this youtube video (give it a minute or two of preamble from this time point… sorry, seemed to make more sense that way…): https://youtu.be/VT77zJ0zGnA?list=PL_CD549H9kgqwHr0EDtvAU8hylsOj30OK&t=982
Show a localization cluster in gray and transparent
Show a statistic in color, differently transparent
The AFNI GUI is mostly limited to a single overlay dataset, but here are some workarounds.
Below threshold reduced opacity. At the top of the overlay bar, you can choose to show sub-threshold data with reduced opacity relative to the threshold and above data. That will allow showing the localization cluster as more transparent if you make a dataset that is a hybrid of your datasets.
set beta = func_slim+orig’[1]’
set tstat = func_slim+orig’[2]’
set localclust = quickmask+orig
set tstat_thr = 3.5
set newlocal_val = 0.5
In the AFNI GUI set the threshold just above the newlocal_val used above, and click on the button labeled ‘A’ above the Overlay color bar. You can also click ‘B’ for the box edges. You can experiment with the different color scales too by right-clicking on the color bar and selecting a new color scale. Also explore the paned color bars by clicking on the double asterisks below the color bar and try 20 color panes. Set the pane that corresponds to the values around 0.5 here to set a different color. This combination method is limited in that beta values at or below newlocal_val can’t be shown. To get around that, you could add or multiply all the values to make the supra-threshold voxels higher, so a beta of 3 might show up as 4 just by adding 1.
Make the cluster an atlas. One of the few exceptions to not allowing for multiple overlays is that an atlas can be shown as another layer. You just have to convert your cluster ROI to an atlas and set an environment variable to tell AFNI to use that atlas. The datasets need to be marked as all being in a standard space too.
make a simple label table to use for the atlas (here for two regions named act and deact where act=1, deact=2)
cat act_deact.txt
1 act
2 deact
turn the mask dataset into an atlas
@Atlasize -dset act_deact+tlrc. -atlas_name act_deact -atlas_description “activation or deactivation”
-atlas_type S -space MNI -lab_file act_deact.txt 1 0
In the AFNI GUI, right-click on any image viewer and select “Atlas colors”. The region will
Simulate opacity in anatomical underlay (grayscale usually)
set anat = anat+orig
set graylev = 3dBrickStat -percentile 75 75 0 -non-zero $anat
set opacity = 0.4444
3dresample -prefix lc_anat.nii.gz -master “$anat” -input $localclust -overwrite
3dcalc -a “$anat” -b lc_anat.nii.gz -expr “a*(1-$opacity)+step(b)$opacity${graylev[2]}”
-prefix lc_anat.gray.nii.gz -overwrite
Now just make the anatomical-cluster hybrid dataset the underlay. The cluster mask will show up as a “translucent” region, and the overlay controls are the usual.
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.