Help transfering individual functions to afni_proc.py

AFNI version info (afni -ver): Version AFNI_24.2.01 'Macrinus'

Hello,

I'd like to move my previous pre- processing protocol to afni_proc.py, if possible. Below are my current functions. Ideally, I do not want it to do any auto-masking as I've found that our application requires us to manually segment our areas of interest.

Let me know any other information I can provide to help clarify.

3dDespike \
-overwrite \
-nomask \
-localedit \
-cut 2.5 5 \
-ignore 2 \
-prefix $AnimalID/$FolderID/${AnimalID}_${FolderID}.DS.Box \
$AnimalID/$FolderID/${AnimalID}_${FolderID}.Box+orig

align_epi_anat.py \
-overwrite \
-epi $AnimalID/$FolderID/${AnimalID}_${FolderID}.DS.Box+orig \
-anat $AnimalID/$FolderID/${AnimalID}_${FolderID}.Box.Mean+orig \
-epi2anat \
-epi_base "$NBASE0" \
-epi_strip None \
-volreg_method 3dvolreg \
-volreg_base median \
-volreg_opts  "-heptic -weight COPY_tempab2D+orig'[0]'" \
-anat_has_skull no \
-output_dir "$AnimalID/$FolderID/" \
-cost ls

# have not validated this below function works. Just want to give an idea that I'd like to also include this kind of regressing protocol
#
afni_proc.py                                  \
-subj_id                 $AnimalID  \
-dsets                    $AnimalID/$FolderID/${AnimalID}_${FolderID}.DS.Box_al+orig \
-blocks                  regress \
-anat_follower_ROI mMask  epi   $AnimalID/$FolderID/MMASK_${AnimalID}_${FolderID}.Box.Mean+orig \
-regress_ROI       mMask

Any help is greatly appreciated!

Hello,

While the option order does not matter, let me set up a command that specifies the EPI (and any related into), the anat (and related), then the -blocks and block options. Changes that will be included:

  • include a scale block
  • assume 2 pre-steady state TRs (-ignore 2 suggests it)
  • align EPI to MIN_OUTLIER rather than median or $NBASE0
  • I do not currently think there is a way to apply 3dvolreg -weight
    (such a thing could possibly be added)
  • regression will include motion (you could consider censoring)
  • some additional QC will be added

This is tcsh syntax, so you may need to translate.

set anat = $AnimalID/$FolderID/${AnimalID}_${FolderID}.Box.Mean+orig
set epis = ( $AnimalID/$FolderID/${AnimalID}_${FolderID}.Box+orig )
set ROI  = $AnimalID/$FolderID/MMASK_${AnimalID}_$FolderID.Box.Mean+orig

afni_proc.py                                                           \
    -subj_id                  $AnimalID                                \
    -dsets                    $epis                                    \
    -copy_anat                $anat                                    \
    -anat_has_skull           no                                       \
    -anat_follower_ROI        mMask epi $ROI                           \
    -blocks                   despike align volreg mask scale regress  \
    -radial_correlate_blocks  tcat regress                             \
    -tcat_remove_first_trs    2                                        \
    -despike_opts_3dDes       -nomask -localedit -cut 2.5 5 -ignore 2  \
    -align_epi_strip_method   None                                     \
    -align_opts_aea           -cost ls                                 \
    -volreg_interp            -heptic                                  \
    -volreg_align_to          MIN_OUTLIER                              \
    -mask_epi_anat            yes                                      \
    -regress_motion_per_run                                            \
    -regress_ROI              mMask                                    \
    -regress_est_blur_errts                                            \
    -html_review_style        pythonic

Ponder that a bit, give it a try, and we can go from there.

  • rick

Thanks so much for this Rick. I will give it a try.

An initial ponder leads me to the question:

  • If we realize our application does need the weight for optimal co-registration, is there a way to break up the afni_proc.py command to do essentially the same thing overall, but keeping use of 'align_epi_anat' instead?
    EDIT: And using the a 1D file of motion parameters for the regress_motion part?

Currently I convert the motion parameters as follows:

1d_tool.py \
-overwrite \
-infile $AnimalID/$FolderID/dfile_VolReg.1D \
-volreg2allineate \
-write $AnimalID/$FolderID/dfile_VolReg_aff12.1D

Because you are leaving the EPI in original space, there is no harm in breaking the process into pieces, one up through volreg, one after.

Or, you could pass the needed files (.BRIK, .HEAD or .nii.gz) via -copy_files, and edit the proc script to use that file for a volreg weight.

Additionally, you could get me to add such an option to the program. I won't guarantee doing that right away, but it seems like it would be reasonable to add. But note that using an external weight volume probably means you should be using an external registration base (which aligns with the weight) via -volreg_base_dset.

  • rick