Best way/tutorial to make activation brain images using AFNI commands

Summary of what happened:

Hello folks,

I am working on a bunch of analysis on a new sequence and would like to compare sensitivity to detection on several measures.
So it would be very interesting to be able to concatenate images with additional data written on the images.

So far, I’ve managed to plot the data, but I would like to add the thresholds and color bar values beneath the images .

I would love to understand how can I script something to make images like such

I have found some new improvements by ptaylor, but I cannot find a reliable way to produce these images.

So far, code below can produce images like displayed below :

Can anybody help/guide me ?

Command used (and if a helper script was used, a link to the helper script or the command generated):

    @chauffeur_afni                                                 \
            -ulay ${background}                                     \
            -ulay_range "2%" "98%"                                  \
            -olay ${tempFolder}/meanInputDataSet+tlrc               \
            -func_range_perc_nz 1                                   \
            -set_subbricks 0 0 0                                    \
            -box_focus_slices ${tempFolder}/meanInputDataSet+tlrc   \
            -cbar "Reds_and_Blues_Inv"                              \
            -pbar_saveim       ${tempFolder}/color_bar              \
            -opacity 4                                              \
            -prefix  $tempFolder/tempPlots                          \
            -thr_olay 0                                             \
            -save_ftype JPEG                                        \
            -montx 9 -monty 1                                       \
            -montgap 3                                              \
            -set_xhairs OFF                                         \
            -pbar_posonly                                           \
            -label_mode 1 -label_size 3     


colorbar_tool.py -in_cbar ${tempFolder}/color_bar.jpg \
            -in_json ${tempFolder}/color_bar.json \
            -prefix ${tempFolder}/test1.jpg

2dcat                                  \
        -gap 5                             \
        -gap_col 66 184 254                \
        -nx 1                              \
        -ny 4                              \
        -prefix ${output_prefix}           \
        $tempFolder/tempPlots*jpg ${tempFolder}/test1.jpg

Version:

I run Ubuntu 22.04.4 LTS
AFNI Version AFNI_25.2.16 ‘Gordian I’
And Python 3.10.12
I use tcsh scripts and am trying to create a .sh functions to plot the said images

Screenshots / relevant information:


Hi-

The command used to make the image you pointed to (the full F-stat shown over the MNI template, with transparent thresholding on) in one of the AFNI Bootcamp data processing examples is this:

@chauffeur_afni                                                              \
    -ulay              MNI152_2009_template.nii.gz                           \
    -box_focus_slices  MNI152_2009_template.nii.gz                           \
    -olay              stats.FT+tlrc.HEAD                                    \
    -cbar              Plasma                                                \
    -pbar_posonly                                                            \
    -ulay_range        0% 120%                                               \
    -func_range        270.089661                                            \
    -thr_olay          25.314201                                             \
    -olay_alpha        Yes                                                   \
    -olay_boxed        Yes                                                   \
    -set_subbricks     0 0 0                                                 \
    -opacity           9                                                     \
    -pbar_saveim       "QC_FT/media/qc_07_vstat_Full_Fstat.pbar.jpg"         \
    -pbar_comm_range   "99%ile in mask"                                      \
    -pbar_comm_thr     "90%ile in mask, alpha+boxed on"                      \
    -pbar_thr_alpha    Yes                                                   \
    -prefix            "QC_FT/media/qc_07_vstat_Full_Fstat"                  \
    -save_ftype        JPEG                                                  \
    -blowup            2                                                     \
    -montx             7                                                     \
    -monty             1                                                     \
    -montgap           1                                                     \
    -montcolor         black                                                 \
    -set_xhairs        OFF                                                   \
    -label_mode        1                                                     \
    -label_size        4                                                     \
    -no_cor                                                                  \
    -cmd2script        run_qc_07_vstat_Full_Fstat.tcsh                       \
    -c2s_text          'APQC, vstat: Full_Fstat'                             \
    -c2s_mont_1x1                                                            \
    -do_clean

You can adjust the paths from there, as well as likely the func_range and thr_olay, which come from percentiles within the dset. There are some additional bells-and-whistles there (like the -c2s_* and cmd2script options), but I left those in for no deep reason.

As a sidenote, I got that by running:

apqc_make_tcsh.py -subj_dir . -uvar_json out.ss_review_uvars.json -do_log

… where the “-do_log” option is the important one to log all commands run.

The image shown in the above post actually comes from a fairly different command, a wrapper for @chauffeur_afni called @djunct_edgy_align_check.

–pt

1 Like

Also, I’ll note that this thread was also opened up here, and is continuing on that thread.

1 Like