why the data after pre-processing were NOT good?







I think there be must something wrong,How can i solve this problems.

Hi-

Thanks for posting QC report images. Could you also please copy+paste your afni_proc.py command here? That will help explain the processing you undertook. It will also make it easier to suggest fix attempts.

The EPI-anatomical alignment failed, for one. This probably is related to poor initial EPI-anatomical overlap ("Initial overlap..." at the bottom of your first page).

I think also anatomical-template alignment did not go well. I can't read the coordinates of the input anatomical, so I can't tell if that is because it is not well centered, but that might be one reason.

--pt

Hi- Thanks for helping.
1.This is the afni_proc.py

The dataset that used is from there

Noticed that the MRI data, for the privacy ,the subjects facial information was processed;does this will effect the Preprocessing??
1719472495708

Can't wait to hear back from you.

Hi,PT
I think that's why the EPI-anatomical alignment failed,But what should i do to solve this.

Hi-

Thanks for posting those pieces of information.

Firstly, using a defaced anatomical shouldn't affect this. We typically process defaced (or sometimes refaced) datasets.

We have a fair number of examples in the afni_proc.py help file for starting.

I am guessing that that data is task FMRI data from the name (Flanker task, specifically), but there are no stimulus timing file information provided, so it will just be processed as rest. Also, you are not using nonlinear alignment to template space---the processing will be quicker, but not detailed alignment to template space. Both of these factors can be fine for quick processing, particularly for getting to check the data and for QC, but might mean this processing is not optimal for final work, just to note.

Actually for just simple processing (like rest, and with affine alignment to template), you might find it helpful to use our "simple" afni_proc.py wrapper command, ap_run_simple_rest.tcsh. The options for blurring and censoring are internally chosen as some representative values, and you just need to provide the input EPI datasets and optionally the anatomical. You could use it with your data like:

ap_run_simple_rest.tcsh \
    -subjid ${subj} \
    -run_proc                 \
    -run_ap           \
    -anat  ${top_dir}/sub-01_t1w.nii.gz         \
    -epi {top_dir}/sub-01_task-flanker_run-1_bold.nii.gz

That will create the full afni_proc.py command and run it. You can look at that afni_proc.py script and see some of the different options being applied---the align block options it uses are probably going to be helpful for your data, for example:

-align_unifize_epi        local                                  \
-align_opts_aea           -giant_move -cost lpc+ZZ               \
                          -check_flip                            \

See here for more details on that and afni_proc.py options:

--pt

Hi,thanks for patient explanation,and apologize for asking more.

The problem was still there;even i use "simple" afni_proc.py wrapper command, ap_run_simple_rest.tcsh or add stimulus timing file information.

As you can see the two images below,first picture's EPI-anatomical overlap was Good,But second they were far apart,So is there anyway that I can handle this?
Data in the first picture is from AFNI_Dataset6,second is from Flanker Dataset

Best regards

Can you please show the results of the APQC HTML for various alignments after you ran the ap_run_simple_rest.tcsh command? That would be helpful for me to understand more.

-pt

That's all the screenshots of APQC HTML.








Best regards

Thanks for posting that.

Looking at this closely, believe it or not, I think the EPI-anatomical alignment is working (ve2a). The issue is that the anatomical is so far away from the template, that that final application is distorting things and chopping off part of the datasets.

Can you do the following to "recenter" the coordinates of your anatomical (well, copy it first and recenter that):

# copy anatomical
3dcopy sub-01_t1w.nii.gz sub-01_t1w_NEW.nii.gz

# recenter coords: find dset center of mass, and set (x,y,z)=(0,0,0) there.
3dCM -set 0 0 0 sub-01_t1w_NEW.nii.gz

Then, use sub-01_t1w_NEW.nii.gz in your processing:

ap_run_simple_rest.tcsh \
    -subjid ${subj} \
    -run_proc                 \
    -run_ap           \
    -anat  ${top_dir}/sub-01_t1w_NEW.nii.gz         \
    -epi {top_dir}/sub-01_task-flanker_run-1_bold.nii.gz

I am hoping that the EPI dset coords don't need to be recentered so much, I can't read the numbers.

--pt

OMG,:sob:
I can't run this command 3dCM -set 0 0 0 sub-01_t1w_NEW.nii.gz

Weird, it worked for me fine. I don't really see how that is possible, there is no "-mask .." option being used.

Can you please copy+paste the output of:

afni_system_check.py -check_all

?

thanks,
pt




Hi-

Thanks for posting that (note that in general, copy+pasting terminal text, rather than images of it, might be easier to do and to read).

There doesn't seem to be a systematic problem there (some minor things to improve, see below). I'm using Ubuntu 20.04 myself, and don't have that problem. It's pretty mysterious. You could try updating your local AFNI version, seeing if that helps:

@update.afni.binaries -d

... but I would be surprised if that changed anything here.

What is the output of these two commands (please copy+paste text, for readability):

3dinfo sub-01_T1w_NEW.nii.gz

and

nifti_tool -disp_hdr -infiles sub-01_T1w_NEW.nii.gz

?

Finally, a couple background things from the output there, in the "please fix" section at the end, that you should probably do to complete your AFNI setup:

  • copy+paste this into a terminal, to set up your SUMA default environment variables:
      suma -update_env
    
  • copy+paste this into a terminal, to have tab-autocompletion for typing options in the terminal:
      apsearch -update_all_afni_help
    

As a quick follow-up, I downloaded that dataset from OpenNeuro now, and ran the commands from above, and both went fine:

$ 3dcopy sub-01_T1w.nii.gz sub-01_T1w_NEW.nii.gz 
++ 3dcopy: AFNI version=AFNI_24.1.19 (Jun 18 2024) [64-bit]

$ 3dCM -set 0 0 0 sub-01_T1w_NEW.nii.gz 
86.4405  4.18703  -11.3877
++ OUT PREF: sub-01_T1w_NEW.nii.gz
*+ WARNING: Over-writing dataset ./sub-01_T1w_NEW.nii.gz
++ Wrote new dataset: ./sub-01_T1w_NEW.nii.gz

So, I don't see an inherent problem within the dataset headers. (Indeed, annoyingly, the anatomical's center of mass is very far from (x,y,z)=(0,0,0), so it should be recentered, which we are doing in the main commands here.)

Please try updating your AFNI, and see if that gives better behavior.

--pt

Also, as a follow-up, I re-typed the command you showed initially on that downloaded data. There are several things in that afni_proc.py command that I would change, but things looked OK when I ran it. That is, the alignment looked ok for both ve2a and va2t (again, not great, because of other minor options that should be added, but not catastrophically weird)---even when I used the input anatomical dataset with un-adjusted center of mass:

The command I ran:

#!/bin/tcsh

set subj    = sub-01
set gname   = QC
set top_dir = $PWD

set sdir    = ${top_dir}/${subj}

afni_proc.py                                                                 \
    -subj_id                 ${subj}                                         \
    -script                  proc.${subj}                                    \
    -scr_overwrite                                                           \
    -blocks                  tshift align tlrc volreg blur mask scale        \
                             regress                                         \
    -copy_anat               ${sdir}/anat/${subj}_T1w.nii.gz                 \
    -dsets                   ${sdir}/func/${subj}_task-flanker_run-1_bold.nii.gz \
    -tcat_remove_first_trs   0                                               \
    -align_opts_aea          -giant_move                                     \
    -tlrc_base               MNI152_2009_template.nii.gz                     \
    -volreg_align_to         MIN_OUTLIER                                     \
    -volreg_tlrc_warp                                                        \
    -blur_size               4.0                                             \
    -regress_censor_motion   0.3                                             \
    -regress_motion_per_run                                                  \
    -regress_est_blur_epits                                                  \
    -regress_est_blur_errts

These were run again on my Ubuntu 20.04.

--pt

Sincerely, I cannot express enough how much your help means to me.
Thanks soooooooo much.

Thanks so much,the problem is solved with your help :grinning:

Cool, I'm glad to hear that. In the end, what was the core of the problem or adjustment that was most helpful here?

I will again note that in terms of this specific processing command, there are several things I would update in this afni_proc.py script, even as a preliminary investigation. In AFNI, we now have the ap_run_simple_rest.tcsh script, which I think is useful as a guide for that. I ran:

# define variable for paths
set subj    = sub-01
set top_dir = $PWD
# subject-level dir
set sdir    = ${top_dir}/${subj}

# run 'simple' AP command (using the recentered anatomical)
ap_run_simple_rest.tcsh                                          \
    -run_ap                                                      \
    -run_proc                                                    \
    -subjid ${subj}                                              \
    -anat   ${sdir}/anat/${subj}_T1w_NEW.nii.gz                  \
    -epi    ${sdir}/func/${subj}_task-flanker_run-1_bold.nii.gz 

... and this created the following afni_proc.py command:

afni_proc.py                                                                 \
    -subj_id                  sub-01                                         \
    -blocks                   tshift align tlrc volreg mask blur scale       \
                              regress                                        \
    -radial_correlate_blocks  tcat volreg regress                            \
    -copy_anat                /home/ptaylor/PROJECTS/ajahn_data/ds000102-download/sub-01/anat/sub-01_T1w_NEW.nii.gz \
    -dsets                    /home/ptaylor/PROJECTS/ajahn_data/ds000102-download/sub-01/func/sub-01_task-flanker_run-1_bold.nii.gz \
    -tcat_remove_first_trs    2                                              \
    -align_unifize_epi        local                                          \
    -align_opts_aea           -cost lpc+ZZ                                   \
                              -giant_move                                    \
                              -check_flip                                    \
    -tlrc_base                MNI152_2009_template_SSW.nii.gz                \
    -volreg_align_to          MIN_OUTLIER                                    \
    -volreg_align_e2a                                                        \
    -volreg_tlrc_warp                                                        \
    -volreg_compute_tsnr      yes                                            \
    -mask_epi_anat            yes                                            \
    -blur_size                6                                              \
    -regress_censor_motion    0.25                                           \
    -regress_censor_outliers  0.05                                           \
    -regress_motion_per_run                                                  \
    -regress_apply_mot_types  demean deriv                                   \
    -regress_est_blur_epits                                                  \
    -regress_est_blur_errts                                                  \
    -regress_make_ideal_sum   sum_ideal.1D                                   \
    -html_review_style        pythonic

To help point out similarities and differences between two afni_proc.py commands, Rick has included clever functionality. You can provide a full set of options, then add -compare_opts_vs_opts, and then provide another complete set of options, and get a table of differences. Here, this can look like running:

set subj    = sub-01
set top_dir = $PWD
set sdir    = ${top_dir}/${subj}

# run AP to compare newer/current set of opts (first list) with original/target set (after `-compare_opts_vs_opts`)
afni_proc.py                                                                 \
    -subj_id                  sub-01                                         \
    -blocks                   tshift align tlrc volreg mask blur scale       \
                              regress                                        \
    -radial_correlate_blocks  tcat volreg regress                            \
    -copy_anat                /home/ptaylor/PROJECTS/ajahn_data/ds000102-download/sub-01/anat/sub-01_T1w_NEW.nii.gz \
    -dsets                    /home/ptaylor/PROJECTS/ajahn_data/ds000102-download/sub-01/func/sub-01_task-flanker_run-1_bold.nii.gz \
    -tcat_remove_first_trs    2                                              \
    -align_unifize_epi        local                                          \
    -align_opts_aea           -cost lpc+ZZ                                   \
                              -giant_move                                    \
                              -check_flip                                    \
    -tlrc_base                MNI152_2009_template_SSW.nii.gz                \
    -volreg_align_to          MIN_OUTLIER                                    \
    -volreg_align_e2a                                                        \
    -volreg_tlrc_warp                                                        \
    -volreg_compute_tsnr      yes                                            \
    -mask_epi_anat            yes                                            \
    -blur_size                6                                              \
    -regress_censor_motion    0.25                                           \
    -regress_censor_outliers  0.05                                           \
    -regress_motion_per_run                                                  \
    -regress_apply_mot_types  demean deriv                                   \
    -regress_est_blur_epits                                                  \
    -regress_est_blur_errts                                                  \
    -regress_make_ideal_sum   sum_ideal.1D                                   \
    -html_review_style        pythonic \
    -compare_opts_vs_opts \
      -subj_id                 ${subj}                                         \
      -script                  proc.${subj}                                    \
      -scr_overwrite                                                           \
      -blocks                  tshift align tlrc volreg blur mask scale        \
                               regress                                         \
      -copy_anat               ${sdir}/anat/${subj}_T1w.nii.gz                 \
      -dsets                   ${sdir}/func/${subj}_task-flanker_run-1_bold.nii.gz \
      -tcat_remove_first_trs   0                                               \
      -align_opts_aea          -giant_move                                     \
      -tlrc_base               MNI152_2009_template.nii.gz                     \
      -volreg_align_to         MIN_OUTLIER                                     \
      -volreg_tlrc_warp                                                        \
      -blur_size               4.0                                             \
      -regress_censor_motion   0.3                                             \
      -regress_motion_per_run                                                  \
      -regress_est_blur_epits                                                  \
      -regress_est_blur_errts

The output looks like this ("extra" means that the first/"current" AP command contains those opts while the second/"target" doesn't; "missing" options rae those in the second/target but not the first/current):

===========================================================================
==== comparing (current) 'command_1' vs (target) 'command_2'
     (for more detail, consider "-verb 2")

==========  missing option(s) : 2
   -script                   proc.sub-01
   -scr_overwrite            

==========  extra option(s) : 9
   -radial_correlate_blocks  tcat volreg regress
   -align_unifize_epi        local
   -volreg_align_e2a         
   -volreg_compute_tsnr      yes
   -mask_epi_anat            yes
   -regress_censor_outliers  0.05
   -regress_apply_mot_types  demean deriv
   -regress_make_ideal_sum   sum_ideal.1D
   -html_review_style        pythonic

==========  differing option(s) : 7
   -blocks                 
      current  : tshift align tlrc volreg mask blur scale regr ...
      target   : tshift align tlrc volreg blur mask scale regr ...

   -copy_anat                (verb=1; skipping details)

   -tcat_remove_first_trs  
      current  : 2
      target   : 0

   -align_opts_aea         
      current  : -cost lpc+ZZ -giant_move -check_flip
      target   : -giant_move

   -tlrc_base              
      current  : MNI152_2009_template_SSW.nii.gz
      target   : MNI152_2009_template.nii.gz

   -blur_size              
      current  : 6
      target   : 4.0

   -regress_censor_motion  
      current  : 0.25
      target   : 0.3

==========  fewer applied option(s) : 0

==========  more applied option(s) : 0

The difference in blur_size, censor_motion limits and tcat_remove_first_trs are probably not really important here, but some of the align_opts_aea differences are useful to note (for QC and potentially alignment quality). Many of the "extra options" are useful to consider for QC considerations, too.

--pt