normalization of resting data to MNI152 template

Dear AFNI experts,

I’m trying to extract the ALFF values from the resting data of Schizophrenia patients. When I’m checking the data quality, I found that the normalization has not happened properly as it intended to be. Below I have attached the codes along with the pictures of overlay of MNI152 template with RSFC file.

#here is the afni proc file

afni_proc.py -subj_id INSP004
-blocks despike tshift align tlrc volreg blur mask regress
-copy_anat INSP004_SurfVol.nii
-anat_follower_ROI aaseg anat aparc.a2009s+aseg.nii
-anat_follower_ROI aeseg epi aparc.a2009s+aseg.nii
-anat_follower_ROI FSvent epi 001_vent.nii
-anat_follower_ROI FSWe epi 002_wm.nii
-anat_follower_erode FSvent FSWe
-dsets INSPRest.nii
-tcat_remove_first_trs 3
-tlrc_base MNI152_T1_2009c+tlrc
-tlrc_NL_warp
-volreg_align_to MIN_OUTLIER
-volreg_align_e2a
-regress_ROI_PC FSvent 3
-regress_anaticor_fast
-regress_anaticor_label FSWe
-regress_bandpass 0.01 0.1
-regress_apply_mot_types demean deriv
-regress_RSFC
-regress_est_blur_epits
-regress_est_blur_errts
-regress_run_clustsim no

Please suggest me the possible ways to correct it.

Any help would be appreciated in this regard

Thanks

  • Korann

Hi, Korann-

A few things there.

What is your AFNI version (“afni -ver”)? If it is quite recent, then you should get a directory called QC_[something] (in your case, probably QC_INSP004) that would have a full report of quality control (QC) blocks from your afni_proc.py processing. This is described in detail here:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/tutorials/apqc_html/main_toc.html
It will show you individual alignment step results (EPI to anat, and anat to template), and you can get a sense of what piece might be running amok.

For aligning to MNI 152, we have been recommending that people use @SSwarper as a pre-afni_proc.py step generally. Basically, you provide your raw anatomical volume, and this program will do bth the skullstripping and estimation of a nonlinear warp to standard space. You then provide the results of its hard work to afni_proc.py. If you read its help file, then you will see how to do both steps:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/programs/@SSwarper_sphx.html#ahelp-sswarper


@SSwarper          \
        -input    ANAT_VOL_WITH_SKULL      \
        -base   MNI152_2009_template_SSW.nii.gz        \
        -subid  INSP004        \
       -odir   SOMEWHERE       \

There will be some snapshot/JPGs created automatically by that program to show you how the alignment (and skullstripping) both look.

… and then your afni_proc.py command would contain some lines like the following (just grabbed this from @SSwarper’s help file, where ${subj} is the subj ID and ${tpath} is the path to the reference MNI vol)


    -volreg_tlrc_warp -tlrc_base $tpath/MNI152_2009_template_SSW.nii.gz              \
     -tlrc_NL_warp                                               \
      -tlrc_NL_warped_dsets                                       \
         anatQQ.${subj}.nii                                       \
         anatQQ.${subj}.aff12.1D                                  \
         anatQQ.${subj}_WARP.nii

That is how afni_proc.py gets the results of @SSwarper.

While I see that you are not censoring data, I will note for future reference that, f you do start censoring your data, you should read this thread about how best to calculate RSFC params:
https://afni.nimh.nih.gov/afni/community/board/read.php?1,160759,160759#msg-160759
Basically, censoring complicates things- as does bandpassing, to some degree (and to some degree of freedom, but that’s a separate note).

–pt

Thanks, Paul for the detailed explanation.

I’m using Version AFNI_18.0.05.

I followed your steps for aligning the anatomical image to the standard template. But it threw an error in the warping. Below I have given the afni proc file for the same along with the error message.

#########afni_proc #############

afni_proc.py -subj_id 004
-blocks despike tshift align tlrc volreg blur mask scale regress
-copy_anat 004_SurfVol.nii
-anat_follower_ROI aaseg anat aparc.a2009s+aseg.nii
-anat_follower_ROI aeseg epi aparc.a2009s+aseg.nii
-anat_follower_ROI FSvent epi 001_vent.nii
-anat_follower_ROI FSWe epi 002_wm.nii
-anat_follower_erode FSvent FSWe
-dsets Rest.nii
-tcat_remove_first_trs 3
( -tlrc_base MNI152_T1_2009c+tlrc
-tlrc_NL_warp
-volreg_align_to MIN_OUTLIER
-volreg_align_e2a \ ) (you want me to remove these steps since the warping is happening in the below steps )
-volreg_tlrc_warp -tlrc_base /home/naren123/abin/MNI152_2009_template_SSW.nii.gz
-tlrc_NL_warp
-tlrc_NL_warped_dsets
anatQQ.-base.nii
anatQQ.-base.aff12.1D
anatQQ.-base_WARP.nii
-regress_ROI_PC FSvent 3
-regress_anaticor_fast
-regress_anaticor_label FSWe
-regress_bandpass 0.01 0.1
-regress_apply_mot_types demean deriv
-regress_RSFC
-regress_est_blur_epits
-regress_est_blur_errts
-regress_run_clustsim no
##########ends here #####

################## error while executing the commands #######################

cat_matvec -ONELINE anatQQ.-base_WARP.nii anatQQ.-base.aff12.1D

Fatal Signal 11 (SIGSEGV) received
mri_read_double_ascii
THD_read_dvecmat
cat_matvec
Bottom of Debug Stack
** AFNI version = AFNI_18.0.05 Compile date = Jan 13 2018
** [[Precompiled binary linux_ubuntu_16_64: Jan 13 2018]]
** Program Death **
** If you report this crash to the AFNI message board,
** please copy the error messages EXACTLY, and give
** the command line you used to run the program, and
** any other information needed to repeat the problem.
** You may later be asked to upload data to help debug.

############### command line message ends here ###############

For more clarity, I have attached the procedure file also.

############### proc file ###############

warp the volreg base EPI dataset to make a final version

cat_matvec -ONELINE
anatQQ.-base.aff12.1D
CSRI004_SurfVol_al_junk_mat.aff12.1D -I > mat.basewarp.aff12.1D

3dNwarpApply -master anatQQ.-base+tlrc -dxyz 3.5
-source vr_base_min_outlier+orig
-nwarp “anatQQ.-base_WARP.nii mat.basewarp.aff12.1D”
-prefix final_epi_vr_base_min_outlier

create an anat_final dataset, aligned with stats

3dcopy anatQQ.-base+tlrc anat_final.$subj

record final registration costs

3dAllineate -base final_epi_vr_base_min_outlier+tlrc -allcostX
-input anat_final.$subj+tlrc |& tee out.allcostX.txt

-----------------------------------------

warp anat follower datasets (affine)

catenate all transformations

cat_matvec -ONELINE
anatQQ.-base_WARP.nii
anatQQ.-base.aff12.1D > warp.all.anat.aff12 (here it threw an error)

################ ends here #################

Secondly, as you mentioned rightly regarding the censoring and RSFC, we have decided not to include censoring since we are using bandpass.
It would be good if you incorporate ‘3dLombScargle’ and ‘3dAmpToRSFC’ soon in the afni_proc file.

Thanks & regards
-Korann

Hi, Korann-

I’m a little confused by what your actual afni_proc.py command was that, running, gave you an error message. Could you please copy+paste just that? You can separately include the lines you have removed, if you wish. Note that you will need to include:


-tlrc_base MNI152_2009_template_SSW.nii.gz                   \
-tlrc_NL_warp                                                \
-tlrc_NL_warped_dsets  \
 anatQQ.-base.nii \
anatQQ.-base.aff12.1D \
anatQQ.-base_WARP.nii 

. It looked like you might have been excluding the “-tlrc_base” option, but I’m not certain by that notation.

NB: when you include code, you can surround it with

 ... 

markers, and it will appear in the yellow/separated field, that makes it a bit easier to read; you can highlight your code segment, and then click the button at the top of the message field that looks like a little white envelope, which, when hovered over, displays “Formatted code”.

–pt

Thanks, Paul for the suggestion.

Here is the afni_proc code for preprocessing.


afni_proc.py -subj_id 004 \
	-blocks despike tshift align tlrc volreg blur mask scale regress \
	-copy_anat 004_SurfVol.nii \
	-anat_follower_ROI aaseg anat aparc.a2009s+aseg.nii \
	-anat_follower_ROI aeseg epi aparc.a2009s+aseg.nii \
	-anat_follower_ROI FSvent epi 001_vent.nii \
	-anat_follower_ROI FSWe epi 002_wm.nii \
	-anat_follower_erode FSvent FSWe \
	-dsets Rest.nii \
	-tcat_remove_first_trs 3 \
	-volreg_align_to MIN_OUTLIER \
	-volreg_align_e2a \
	-volreg_tlrc_warp  \
        -tlrc_base MNI152_2009_template_SSW.nii.gz \
	-tlrc_NL_warp \
      	-tlrc_NL_warped_dsets \
         	anatQQ.-base.nii \
         	anatQQ.-base.aff12.1D \
         	anatQQ.-base_WARP.nii \
	-regress_ROI_PC FSvent 3 \
	-regress_anaticor_fast \
	-regress_anaticor_label FSWe \
        -regress_bandpass 0.01 0.1 \
	-regress_apply_mot_types demean deriv \
	-regress_RSFC \
	-regress_est_blur_epits \
	-regress_est_blur_errts \
	-regress_run_clustsim no

And below is the error message copied from the terminal for the above proc file.


cat_matvec -ONELINE anatQQ.-base_WARP.nii anatQQ.-base.aff12.1D

Fatal Signal 11 (SIGSEGV) received
    mri_read_double_ascii
   THD_read_dvecmat
  cat_matvec
 Bottom of Debug Stack
** AFNI version = AFNI_18.0.05  Compile date = Jan 13 2018
** [[Precompiled binary linux_ubuntu_16_64: Jan 13 2018]]
** Program Death **
** If you report this crash to the AFNI message board,
** please copy the error messages EXACTLY, and give
** the command line you used to run the program, and
** any other information needed to repeat the problem.
** You may later be asked to upload data to help debug.
** Crash log is appended to file /home/naren123/.afni.crashlog

Plz, correct me if I’m following any wrong step.

Thanks
-Korann

Hi, Korann-

Well, indeed, cat_matvec shouldn’t be trying to combine 1D text file with a volumetric data set…

One thing is that you should pass skullstripped anat with “copy_anat”, and then tell afni_proc.py that you have already skullstripped the brain:


-copy_anat anatSS.${subj}.nii
-anat_has_skull no

where ${subj} stands for where your subject ID would be. You can still pass your anatomical that has a skull as a follower, with:


-anat_follower     anat_w_skull anat 004_SurfVol.nii     

This is also a pretty common line to put in, so that in case the anat and EPI dsets are far apart, they should have less troubles:


-align_opts_aea -giant_move -cost lpc+ZZ -check_flip

One other question: can you please copy+paste your @SSwarper command? I am concerned that since “-base” is in the place where your subject ID would be that something might have gone amiss with that…

-pt

I don’t think that will all work with an AFNI version from a year ago. In particular the naming convention difference between @SSwarper and auto_warp.py was problematic.

Would it be possible to update your AFNI version?

  • rick

Thanks, Paul for the continuous assistance.

@SSwarper code for your reference


@SSwarper CSRI-004-1-Structural.nii -base   MNI152_2009_template_SSW.nii.gz -subid  CSRI004

I followed your steps and the issue remains the same. Here is the modified code


afni_proc.py -subj_id CSRI004 \
	-blocks despike tshift align tlrc volreg blur mask scale regress \
	-copy_anat anatSS.-base.nii \
	-anat_has_skull no \
	-anat_follower anat_w_skull anat CSRI004_SurfVol.nii \
	-anat_follower_ROI aaseg anat aparc.a2009s+aseg.nii \
	-anat_follower_ROI aeseg epi aparc.a2009s+aseg.nii \
	-anat_follower_ROI FSvent epi 001_vent.nii \
	-anat_follower_ROI FSWe epi 002_wm.nii \
	-anat_follower_erode FSvent FSWe \
	-dsets CSRI-004-2-Rest.nii \
	-tcat_remove_first_trs 3 \
	-volreg_tlrc_warp -tlrc_base /home/naren123/abin/MNI152_2009_template_SSW.nii.gz \
	-align_opts_aea -giant_move -cost lpc+ZZ -check_flip \
	-tlrc_NL_warp \
      	-tlrc_NL_warped_dsets \
         	anatQQ.-base.nii \
         	anatQQ.-base.aff12.1D \
         	anatQQ.-base_WARP.nii \
	-volreg_align_to MIN_OUTLIER \
	-volreg_align_e2a \
	-regress_ROI_PC FSvent 3 \
	-regress_anaticor_fast \
	-regress_anaticor_label FSWe \
	-regress_bandpass 0.01 0.1 \
	-regress_apply_mot_types demean deriv \
	-regress_RSFC \
	-regress_est_blur_epits \
	-regress_est_blur_errts \
	-regress_run_clustsim no

Waiting for your comments.

Thanks
-Vittal

Sure Rick will update the AFNI to it’s the newest version.

I Hope that the new AFNI version will sort our issue.

Thank you Rick

Regards
-Korann

Hi, Korann/Vittal-

This syntax doesn’t look quite right; I think it is missing a “-input …” option name. I think this is what you would want (and just spaced one per line, for readability):


@SSwarper          \
        -input  CSRI-004-1-Structural.nii       \
        -base   MNI152_2009_template_SSW.nii.gz        \
        -subid  CSRI004        \

Note that in this modern form, then your output files won’t have the “-base” in it. I see now why the “-base” appears in the name-- as Rick rightly pointed out, your AFNI version was quite old, and the syntax of @SSwarper had been updated since then (going from just listing a few files to have option flag names, for greater generalized usage). So, instead of:


-copy_anat anatSS.-base.nii \
...
-tlrc_NL_warped_dsets \
    anatQQ.-base.nii \
    anatQQ.-base.aff12.1D \
    anatQQ.-base_WARP.nii \

it would probably be more like:


-copy_anat anatSS.CSRI004.nii \
...
-tlrc_NL_warped_dsets \
    anatQQ.CSRI004.nii \
    anatQQ.CSRI004.aff12.1D \
    anatQQ.CSRI004_WARP.nii \

(or, you could use a variable name instead of “CSRI004”, for generalized application).

Also, in your @SSwarper command call, this file is your input:


CSRI-004-1-Structural.nii

but in your afni_proc.py command, this file is a follower:


-anat_follower anat_w_skull anat CSRI004_SurfVol.nii \

. I would have thought those should be the same files?

–pt

Thanks, Paul for assisting on a regular basis.

After updating AFNI to a new version, now things are fine. One sincere suggestion from my side is that why don’t you people incorporate @SSwarper along with afni proc in example 11 and since eg. 11 does not do the intended job properly. So it would be helpful for others if you could club @SSwarper and example 11 together.

I also attached the normalization results after using the @SSwarper function along with codes.


@SSwarper          \
        -input  SubjID-Structural.nii       \
        -base   MNI152_2009_template_SSW.nii.gz        \
        -subid  SubjID \


afni_proc.py -subj_id SubjID \
	-blocks despike tshift align tlrc volreg blur mask scale regress \
	-copy_anat anatSS.SubjID.nii \
	-anat_has_skull no \
	-anat_follower anat_w_skull anat SubjID_SurfVol.nii \
	-anat_follower_ROI aaseg anat aparc.a2009s+aseg.nii \
	-anat_follower_ROI aeseg epi aparc.a2009s+aseg.nii \
	-anat_follower_ROI FSvent epi 001_vent.nii \
	-anat_follower_ROI FSWe epi 002_wm.nii \
	-anat_follower_erode FSvent FSWe \
	-dsets Rest.nii \
	-tcat_remove_first_trs 3 \
	-align_opts_aea -giant_move -cost lpc+ZZ -check_flip \
	-volreg_tlrc_warp -tlrc_base /home/naren123/abin/MNI152_2009_template_SSW.nii.gz \
	-tlrc_NL_warp \
      	-tlrc_NL_warped_dsets \
         	anatQQ.SubjID.nii \
         	anatQQ.SubjID.aff12.1D \
         	anatQQ.SubjID_WARP.nii \
	-volreg_align_to MIN_OUTLIER \
	-volreg_align_e2a \
	-volreg_tlrc_warp \
	-mask_epi_anat yes \
	-regress_motion_per_run \
	-regress_ROI_PC FSvent 3 \
	-regress_make_corr_vols aeseg FSvent \
	-regress_anaticor_fast \
	-regress_anaticor_label FSWe \
	-regress_bandpass 0.01 0.1 \
	-regress_apply_mot_types demean deriv \
	-regress_RSFC \
	-regress_est_blur_epits \
	-regress_est_blur_errts \
	-regress_run_clustsim no

Thanks, Rick for helping at the right time.

Regards
-Korann

Hi, Korann-

Great, glad that worked out.

Indeed, the @SSwarper tool that Bob wrote is pretty new, and we are trying to integrate it more into documentation as we have used it and grown more comfortable using it. It is a challenge to keep uptodate with recommendations and new programs. Actually, pretty soon we intend to put more processing examples online. And we would recommend that all AFNI users stay uptodate with developments/news in the AFNI world by signing up for the AFNI Digest (a ~weekly or monthly email mailing of updates, fixes and other information), as described here:
https://afni.nimh.nih.gov/afni/community/board/read.php?1,154890

–pt