show spherical ROIs on a surface background

Hi AFNI team,
I am trying to show some spherical ROIs on a surface background by a simple command:


suma -spec MNI_N27 -vol ROI_FigShow.nii.gz

While I do can see my ROI balls as shown in the 1st attaching jpg, there are dark boarders surrounding each of the balls and the colors in each ball are inhomogeneous. Therefore, I tried again to convert my volume balls to surface for display:


IsoSurface -overwrite -isorois -mergerois+dsets -o surf_sphere.gii -input ROI_FigShow.nii.gz -Tsmooth 0.3 60
suma -onestate -i surf_sphere*.gii -spec MNI_N27

But now I don’t see any ROI balls, and the color control panel for these balls are missing (the 2nd attaching jpg). As I don’t work much with suma, I am not sure if I have done anything wrong so seeking help here.

Thanks a lot!

Untitled-2.jpg

Howdy-

I think that Daniel G, who wrote this doc page, probably has you covered with SUMA+sphere advice:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/tutorials/rois_corr_vis/suma_spheres.html
Actually, from your choice of IsoSurface options, I wondered if you were following the first example there already? But for the question of uniform coloring, consider perhaps this specific example on the page:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/tutorials/rois_corr_vis/suma_spheres.html#make-isosurfaces-of-the-volumetric-rois
or some others.

–pt

Hi Paul,
That page and that particular example were actually what I have been following. I was able to replicate displays shown on that page, but that page always uses a volume background, which I don’t want. I want a surface background like shown in the picture of my previous post.

Thank you again for your help!

Hi, Zhihao-

OK, but there are two issues you raised:

  1. the background being volumetric slices from using

suma [....] -vol ${templ_full}

  1. the displaced ROIs/spheres not being uniform color, from using 3dUndump and

suma [....] -vol vol_sphere+tlrc

To solve both of these, I am choosing the “NIDO” object example from the demo page, and adapting it to display in MNI space (in the MNI 152 space, where surfaces are available for download here: https://afni.nimh.nih.gov/pub/dist/tgz/suma_MNI152_2009.tgz). I ran the following script, based on the demotcsh script from the above webpage (note that I made the input $templ the SurfVol in that suma_ directory; I also put the supplementary sphere_coords.1D
and ROI*cmap files into that directory, to be able to run the demo):


#!/bin/tcsh

# script:  demo_suma_spheres.tcsh
# ver   :  1.0
# date  :  Feb 7, 2019
# author:  DR Glen (NIMH, SSCC)
#
# Several methods for showing spheres in SUMA.
#
# ======================================================================

# -------------------- Defining initial files --------------------------

# Start with a list of center coords and a chosen dset space
set sphere_coords = sphere_coords.1D
set templ         = MNI152_2009_SurfVol.nii #MNI152_T1_2009c+tlrc
set templ_full    = `@FindAfniDsetPath "${templ}"`/${templ}

# Create a set of colors from SUMA's colormap.  This one was created
# by clicking the 'w' key over the ROI_256 color map color bar.
set sphere_colors = ROI_i256.1D.cmap

# -------------------- Preliminary steps ------------------------------

# Count how many spheres
set nsphere = `1dcat ${sphere_coords} | wc -l`
set lastrow = `ccalc -int -expr "${nsphere}-1"`

# Make some labels for each sphere.  Here, just a number (~counting or
# indexing).
count -digits 3 -col 1 ${nsphere} > vol_sphere_labels.1D

# Combine the labels with the coordinates
1dcat ${sphere_coords} vol_sphere_labels.1D > vol_sphere_coords_labeled.1D

# -------------------- Make volumes -----------------------------------

# Create spheres in a volume (from which we will make surfaces)
3dUndump                                  \
    -master ${templ_full}                 \
    -srad 3.5                             \
    -prefix vol_sphere                    \
    -datum byte                           \
    -overwrite                            \
    -xyz                                  \
    -orient RAI                           \
    vol_sphere_coords_labeled.1D


# ------------------ NIML Displayable Objects (Nidos) --------------------

# Pre-clean (e.g., if re-running demo).
set ccc = `\ls nido_*`
if ( "$#ccc" != "0" ) then
    \rm ${ccc}
endif

# Nidos are displayable and removable in suma, but they are not
# selectable, so you can't interact with these objects.
set sphere_do = nido_sphere.1D.do

# This is a technical label needed for the top of the file.
echo "#spheres" > $sphere_do

# Need unused alpha column for color.
1deval -a ${sphere_coords}'[0]' -expr '1' > nido_alpha.1D

# Need radius column.
1deval -a ${sphere_coords}'[0]' -expr '3.5' > nido_radius.1D

# Also, need mesh points filled code column.
1deval -a ${sphere_coords}'[0]' -expr '2' > nido_filled.1D

1dcat                                                 \
    ${sphere_coords} ${sphere_colors}"{0..$lastrow}"  \
    nido_alpha.1D                                     \
    nido_radius.1D                                    \
    nido_filled.1D  >> $sphere_do


echo "++++ Visualize results"

suma -niml -spec MNI152_2009_both.spec -sv ${templ_full} &
sleep 2
DriveSuma                                          \
    -echo_edu                                      \
    -com viewer_cont -load_do $sphere_do

… and then could turn down the opacity of the surface meshes by hitting ‘o’ a couple times, and attached are snapshots of the resulting images.

Does that accomplish both of your goals?

–pt

Thank you very much Paul, your code does work for me!
I have 3 more questions:
(1) What’s the orientation code (LPI, RAI?) in your “sphere_coords.1D” file? I am trying to display my ROI balls against the background of MNI_N27 surface so coded my coordinates in LPI orientation, but they are far off the intended locations in the display.
(2) How does this “Nidos” way differ from the “isosurfaces” way on showing ROIs in suma? Why does the “isosurfaces” way not work in this case?
(3) What if one wants to show spheres and activation blobs (irregular shape in a volume dataset) together and against a background of surface? Now it seems to me that “suma -niml” with “Nidos” can work for spheres and “suma -vol” can work for blobs (but with the issue of color homogeneity). How would you approach it? Is there an example page for that?

Hi, Zhihao-

Re. #1: AFNI default is RAI (=DICOM) coords. So, your x and y coords would need to be minus-ized. If your input file is 3 columns (for x, y and z coord values), then a cheating way to flip the sign of the x- and y-coords would be to use 1dDW_grad_o_mat++:


1dDW_Grad_o_Mat++ \
   -flip_x \
   -flip_y \
   -in_col_vec COORDS_LPI.1D \
   -out_col_vec COORDS_RAI.1D

Re. #2: I played around a bit with suma/DriveSuma, and the following shoudl work for showing isosurfaces, after running the online to make the ico_combined.gii surface:


suma   -niml \
      -onestate \
      -i std.60.lh.smoothwm.gii -i std.60.rh.smoothwm.gii \
      -i ico_combined.gii \
      -sv  ${templ_full} &

DriveSuma \
    -com surf_cont -load_dset ico_combined.niml.dset \
    -surf_label ico_combined.gii \
    -switch_cmap ROI_i32

I used this to make the SUMA window in the attached visualization. NB: to turn down the opacity of the brain hemispheres only (and not the sphere surfaces), I right-clicked on each brain surface and hit “ctrl+o” a couple times.

Re. #3: this could be done with the answer to #2; in fact, in the FATCAT_DEMO dataset in the Bootcamp data (also available separately with @Install_FATCAT_DEMO), the visualization script Do_09_VISdti_SUMA_visual_ex2.tcsh shows an example of viewing “lumpy” or irregular surfaces (from GM ROIs) along with a surface mesh-- it is the example starting line 64 there, which is excerpted here (one woudl have to run the full demo by executing the Do_00*.tcsh script therein to generate the data to view it):


SET1:
#Looking at the default mode connections
afni -npb $sport -niml -yesplugouts -layout demo_layout \
                          *.HEAD DTI/*.HEAD  &
suma  -npb $sport -niml \
      -onestate \
      -i SUMA/std.60.lh.smoothwm.gii -i SUMA/std.60.rh.smoothwm.gii \
      -i Net_000.gii     \
      -sv mprage+orig \
      -vol mprage+orig. \
      -tract DTI/o.NETS_AND_000.niml.tract &
DriveSuma -npb $sport \
            -com viewer_cont -key 't' -key '.' \
            -com surf_cont -view_surf_cont y
DriveSuma -npb $sport \
            -com surf_cont -surf_label Net_000.gii \
            -load_dset Net_000.cols.niml.dset   \
            -switch_cmap ROI_i32 -Dim 0.3

In fact, to make the above visualization, I borrowed liberally from this same example script.

–pt

Adding on a bit here to Paul’s examples.

  1. According to the help, the 3dUndump -master option sets the xyz format for the orientation, overriding the -orient option. We had discussed changing that behavior, but that issue slipped under the radar. The workaround here is to use 3dresample or 3daxialize to set a master dataset to have the orientation you would like to use the coordinates or make the coordinates match the orientation of the master dataset.
  2. NIML DO (displayable objects) are not clickable in suma, so I usually don’t use these. But they are drivable in interesting ways like you can add and remove NIDOs on the fly.
  3. Volume rendering in suma. This turns out to be fairly memory intensive, so it’s limited to only one or two datasets at a time. You can reduce some of the memory constraints by autoboxing and/or combining the spheres and masks in a single dataset.