missing +tlrc warp dataset

Hi,
I have created my specific age template using ants and then registered T1 to this template with @animal_warper command. However, I failed running afni_proc.py with the following errors:


The code I used with afni_proc.py was:

set dsets_NL_warp = (/data/home/bnu006/UW-Madison_Rhesus_MRI/preprocess/data_13_aw/sub-2210/sub-2210_anat_warp2std_nsu.nii.gz \
                    /data/home/bnu006/UW-Madison_Rhesus_MRI/preprocess/data_13_aw/sub-2210/sub-2210_anat_composite_linear_to_template.1D \
                   /data/home/bnu006/UW-Madison_Rhesus_MRI/preprocess/data_13_aw/sub-2210/sub-2210_anat_shft_WARP.nii.gz                )  

afni_proc.py                                                                \
    -subj_id                  sub-2210                                      \
    -blocks                   tshift align tlrc volreg blur mask scale regress   \
    -dsets                    /data/home/bnu006/UW-Madison_Rhesus_MRI/preprocess/try_one/sub-2210/func/sub-2210_task-rest_bold.nii.gz      \
    -copy_anat                /data/home/bnu006/UW-Madison_Rhesus_MRI/preprocess/data_13_aw/sub-2210/sub-2210_anat_nsu.nii.gz    \
    -anat_has_skull           no                                            \
    -anat_uniform_method      none                                          \
    -radial_correlate_blocks  tcat volreg  regress                                 \
    -radial_correlate_opts    -sphere_rad 14                                \
    -tcat_remove_first_trs    10                                     \
    -volreg_align_to          MIN_OUTLIER                                   \
    -volreg_align_e2a                                                       \
    -volreg_warp_master       /data/home/bnu006/UW-Madison_Rhesus_MRI/preprocess/data_age4_basic/template/template_age4.nii.gz        \
    -volreg_tlrc_warp                                                       \
    -volreg_compute_tsnr      yes                                           \
    -align_opts_aea           -cost nmi   -epi_strip 3dSkullStrip    -skullstrip_opts -monkey                       \
                              -check_flip    -feature_size 0.5                               \
    -align_unifize_epi        local                             \
    -tlrc_base                /data/home/bnu006/UW-Madison_Rhesus_MRI/preprocess/data_age4_basic/template/template_age4.nii.gz                                   \
    -tlrc_NL_warp                                                           \
    -tlrc_NL_warped_dsets     ${dsets_NL_warp}                              \
    -blur_size                2.5                                             \
    -regress_motion_per_run                                                 \
    -regress_apply_mot_types  demean deriv                                  \
    -regress_polort           2                                             \
    -regress_bandpass         0.01 0.1                                      \
    -regress_est_blur_errts                                                 \
    -regress_est_blur_epits                                                 \
    -regress_run_clustsim     no                                            \
    -html_review_style        pythonic 

AFNI version info (afni -ver): Precompiled binary linux_centos_7_64: Feb 28 2024 (Version AFNI_24.0.09 'Caracalla')

Thanks,
Ruilin

Hi, Ruilin-

Hm, that's weird. Would you mind please emailing me the full output.proc.* file (capture terminal text) from running that subject?

--pt

Hi, ptaylor

I have send you the full output.proc.*flie.

Best regards,
Ruilin

Hi, Ruilin-

Thanks for sending that. I should have noticed earlier that your template is not one I recognize, and it is called:

template_age4.nii.gz

When we (and hopefully others) distribute templates, they have some part of their header that designates them as being in standard space. In BRIK/HEAD, we use a spacename and view pair of attributes; in NIFTI, we use sform_code and qform_code. More discussion of these are here.

BRIK/HEAD dsets that are marked as being in a standard space have +tlrc as part of their prefix. I think the issue here is is that the sform_code and qform_code values in the dataset you are using as a template aren't appropriately set, to mark it as being in a standard space. What is the output of:
What is the output of:

nifti_tool \
    -disp_hdr -field qform_code -field sform_code \
    -infiles template_age4.nii.gz```

? For a non-MNI and non-Talairach-Tournoux standard space, the value for each of those header keys should be 5, but I don't think it will be here.

Therefore, when afni_proc.py copies the input dataset that should be the anatomical dataset warped to a standard space (sub-2210_anat_warp2std_nsu.nii.gz here), that dataset also doesn't have a qform_code or sform_code to tell AFNI it is in a standard space, so then it is treated as being in original/native space and gets a +orig extension, and hence the actual filename in the results directory doesn't match what the script expects, and hence the failure mode.

--pt

It is possible to work through and adjust header information to update things to run here---and the template dataset you are using should definitely be updated to simplify processing other subjects---but it is better to verify first that this is actually what is happening.

--pt

Hi,ptaylor
Thanks for your reply. The output of the nifti_tool command showed that my specific template is not in a stansard space. In the following steps, should I also use the nifti_tool to adjust header information of my specific template?

Best regards,
Ruilin

Hi, ptaylor
I have run the following code and the sform_code and qform_code values for my modified template are 5. I will try to run afni_proc.py again.

nifti_tool -mod_hdr -mod_field qform_code 5 -mod_field sform_code 5 -prefix Template_Standard_Age4.nii -infiles template_age4.nii


Thanks again for your help.
Best regards,
Ruilin

Hi, Ruilin-

Yes, you should set the template to be marked in the header as being in standard space. Again, for non-MNI and non-Talairach-Tournoux space (and since your pipeline is using @animal_warper, I believe that is safely the case!), then you can set it as follows, first noting:

  • I wouldn't overwrite the template dset, but create a new one, just in case something goes weird with resetting header stuff.
  • The input dset (here, DSET_IN) must be uncompressed/unzipped before running this (so, gunzip ...)
  • It is probably good to also make sure there are no header extensions in the file, so remove any possible ones.
# remove any "extras"/extensions
nifti_tool \
    -strip_extras \
    -infiles DSET_IN \
    -prefix __tmp_dset.nii

# set [qs]form_code values
nifti_tool \
    -mod_hdr -mod_field qform_code 5 -mod_field sform_code 5 \
    -infiles __tmp_dset.nii \
    -prefix DSET_OUT

After this, verify that you are in standard space happily with:

nifti_tool \
    -disp_hdr -field qform_code -field sform_code \
    -infiles DSET_OUT

3dinfo -space -av_space DSET_OUT

... whether the first should show 5 for both qform_code and sform_code values, and the latter should show TLRC and +tlrc (and both just generically mean "standard space" here, not TT space specifically).

For the two dsets in the ${dsets_NL_warp} variable that were already processed, you should be able to do the same thing---both of those are actually in standard space. You can also re-run @animal_warper on that anatomical using the updated template, too, so more header info is preserved. I don't think this workflow will use any of the AFNI extension header info that is stripped away.

--pt