** already in tlrc space: -volreg_tlrc_* is not allowed

Hello,

I’m new to AFNI and want to run the preprocessing afni_proc.py.
I cannot figure out why it has problems with volreg.

The error message is below:

++ applying anaticor without label, using 3dSeg mask
– applying input view as +tlrc
– will use min outlier volume as motion base
** already in tlrc space: -volreg_tlrc_* is not allowed
** invalid block : volreg

** failed command (create_blocks):

afni_proc.py -subj_id 1002002 -out_dir
/group/…/1002002_processed -script
/home/…/scriptss/1002002/1002002 -scr_overwrite -dsets
/group/…/1002002_V001_DMSRun1.nii -blocks
despike tshift align tlrc volreg mask blur regress -copy_anat
/group/northoff/share/sswarper_ang/1002002/anatSS.1002002.nii
-anat_has_skull no -align_opts_aea -cost lpc+ZZ -big_move
-volreg_align_e2a -volreg_align_to MIN_OUTLIER -volreg_tlrc_warp
-tlrc_base MNI152_2009_template_SSW.nii.gz -tlrc_NL_warp
-tlrc_NL_warped_dsets
/group/northoff/share/sswarper_ang/1002002/anatQQ.1002002.nii
/group/northoff/share/sswarper_ang/1002002/anatQQ.1002002.aff12.1D
/group/northoff/share/sswarper_ang/1002002/anatQQ.1002002_WARP.nii
-volreg_post_vr_allin yes -volreg_pvra_base_index MIN_OUTLIER
-mask_segment_anat yes -mask_segment_erode yes -regress_anaticor
-regress_ROI WMe CSFe -regress_apply_mot_types demean deriv
-regress_motion_per_run -regress_censor_motion 0.25
-regress_censor_outliers 0.1 -blur_size 6.0 -regress_est_blur_epits
-regress_est_blur_errts -html_review_style pythonic -execute

Thank you very much,
Angelika

Hi, Angelika-

Indeed, your input EPI should be in native space, not a standard space, before processing starts.

There are 2 ways it might appear to be in standard space:

  1. It is actually in standard space.
  2. It is a NIFTI file, and it has an qform_code and/or sform_code value in its header that is the dreaded “ambiguous space” one that was somehow allowed in the NIFTI standard. From here, we can see what allowed [qs]form_code values there are (and a new one exists now, code=5, which represents “other” templates than those in code=3,4):

Name 	Code 	Description
unknown 	0 	Arbitrary coordinates. Use Method 1.
scanner_anat 	1 	Scanner-based anatomical coordinates.
aligned_anat 	2 	Coordinates aligned to another file, or to the “truth” (with an arbitrary coordinate center).
talairach 	3 	Coordinates aligned to the Talairach space.
mni_152 	4 	Coordinates aligned to the mni space.

The dreaded ambiguous coding is code=2; if your NIFTI dataset has that, AFNI has to choose whether to consider that in ‘original’ or ‘standard’ space, which is controlled with an environment variable AFNI_NIFTI_VIEW.

So, first let’s check what the [qs]form_code values are in your dataset, to see if we are in case #1 or case #2 from above. What is the output of the following, where DSET_EPI is your input EPI time series dataset (/group/…/1002002_V001_DMSRun1.nii)?


nifti_tool -disp_hdr -field qform_code -field sform_code -infiles DSET_EPI

–pt

ps: for reference, here is your afni_proc.py command spaced out, ~one option per line:


afni_proc.py                                                                 \
    -subj_id                  1002002                                        \
    -out_dir                  /group/.../1002002_processed                   \
    -script                   /home/.../scriptss/1002002/1002002             \
    -scr_overwrite                                                           \
    -dsets                    /group/.../1002002_V001_DMSRun1.nii            \
    -blocks                   despike tshift align tlrc volreg mask blur     \
                              regress                                        \
    -copy_anat                /group/northoff/share/sswarper_ang/1002002/anatSS.1002002.nii \
    -anat_has_skull           no                                             \
    -align_opts_aea                                                          \
    -cost                     lpc+ZZ                                         \
    -big_move                                                                \
    -volreg_align_e2a                                                        \
    -volreg_align_to          MIN_OUTLIER                                    \
    -volreg_tlrc_warp                                                        \
    -tlrc_base                MNI152_2009_template_SSW.nii.gz                \
    -tlrc_NL_warp                                                            \
    -tlrc_NL_warped_dsets     /group/northoff/share/sswarper_ang/1002002/anatQQ.1002002.nii \
                              /group/northoff/share/sswarper_ang/1002002/anatQQ.1002002.aff12.1D \
                              /group/northoff/share/sswarper_ang/1002002/anatQQ.1002002_WARP.nii \
    -volreg_post_vr_allin     yes                                            \
    -volreg_pvra_base_index   MIN_OUTLIER                                    \
    -mask_segment_anat        yes                                            \
    -mask_segment_erode       yes                                            \
    -regress_anaticor                                                        \
    -regress_ROI              WMe CSFe                                       \
    -regress_apply_mot_types  demean deriv                                   \
    -regress_motion_per_run                                                  \
    -regress_censor_motion    0.25                                           \
    -regress_censor_outliers  0.1                                            \
    -blur_size                6.0                                            \
    -regress_est_blur_epits                                                  \
    -regress_est_blur_errts                                                  \
    -html_review_style        pythonic                                       \
    -execute

Hi Angelika,

EDIT: Oh my, Paul has gotten me back… maybe this post is moot.

Different software has created NIFTI datasets with different intentions in the sform/qform_code fields, making a value of 2 there ambiguous. It is generally applied incorrectly even.

To be sure, what is the output of:

nifti_tool -infiles 1002002_V001_DMSRun1.nii -disp_hdr -field sform_code -field qform_code

If those fields are equal to 2 AND if the EPI has not been registered to anything (in which case they should not be 2), then set the AFNI_NIFTI_VIEW environment variable to orig. This can be done in your $HOME/.afnirc file, in your shell environment or just in the script, as you prefer. For example, edit your ~/.afnirc file to have a line like:

AFNI_NIFTI_VIEW = orig

Please let me know how that goes.

Thanks,

  • rick

Hi Rick,

Thanks so much for your reply.

Both code lines seems to work:


nifti_tool -disp_hdr -field qform_code -field sform_code -infiles 1002002_V001_DMSRun1.nii   

N-1 header file ‘1002002_V001_DMSRun1.nii’, num_fields = 2
name offset nvals values


qform_code 252 1 1
sform_code 254 1 2

Thanks again for your help!
Angelika


nifti_tool -infiles 1002002_V001_DMSRun1.nii -disp_hdr -field sform_code -field qform_code

N-1 header file ‘1002002_V001_DMSRun1.nii’, num_fields = 2
name offset nvals values


sform_code 254 1 2
qform_code 252 1 1

Hi Angelika,

Indeed, you can see that the sform_code values are shown as 2, which is the ambiguous or likely incorrect case.
Try setting AFNI_NIFTI_VIEW = orig either in your environment or in your ~/.afnirc file. Then test by running ‘3dinfo’ on the NIFTI input and verify that without the variable, the space is +tlrc, but with it, the space is +orig.

For example, even before setting the variable in a more permanent place, consider:

3dinfo -av_space 1002002_V001_DMSRun1.nii
3dinfo -DAFNI_NIFTI_VIEW=orig -av_space 1002002_V001_DMSRun1.nii
  • rick

Hi Rick,

thanks so much for your reply.

Unfortunately, I’m using AFNI on a common server of our institute and I cannot easily change the /.afnirc file.
Would there be the possibility of including something in the afni_proc.py?

Thank you so much for your help,
Angelika

Hi Angelika,

The .afnirc file is in your home directory, ~/.afnirc or equivalently $HOME/.afnirc.
Alternatively, you can set that using an environment variable, though your ~/.afnirc file is probably a better place to do it.

To be sure, do you have a $HOME/.afnirc file?

Note that if you run the system check, it will suggest how to copy one to your $HOME directory in the final “please fix” section (IF you do not already have such a file):

afni_system_check.py -check_all
  • rick

Thank you so much for your help.

I added the afnirc file in home and the line in the file - it worked!!!

That is great news, thanks for the update!

  • rick