I am running an afni_proc.py resting-state pipeline on data previously aligned using FSL (omitting the tlrc block). The pipeline completes all preprocessing but consistently crashes at the 3dpc step of the regression block when trying to read the imported ventricle mask.
Grid alignment:3dinfo -same_grid confirms the fMRI data and masks are a perfect match (returns 1 1).
File permissions: Verified both eroded .nii masks have 664 (read/write) permissions on the cluster.
Space mismatch: The internal import seems to read the .nii masks as standard space (generating mask_import_vent+tlrc.HEAD/.BRIK in the Results folder), but the generated proc script hardcodes 3dpc to look for mask_import_vent+orig.
Workarounds attempted: I tried exporting AFNI_NIFTI_VIEW=orig to force the NIfTI import space. I also tried manually creating both +orig and +tlrc.HEAD/.BRIK versions of the masks in the directory prior to running the script to see if it would pick them up. None of these resolved the 3dpc crash.
Is there a specific way to format these masks or a flag I am missing to ensure afni_proc.py correctly links them to 3dpc in the expected coordinate space when skipping the tlrc block?
Can you check that AFNI_NIFTI_VIEW=orig in your ~/.afnirc file? That is a safer place to set it than the shell, since it should apply to everything (though the shell overrides it).
What are the actual qform/sform_code values? Here is one command, but the datasets may be in different directories, so you may need to adjust it or run multiple nifti_tool commands.
To be sure, have the time series been motion corrected already? Is everything actually in standard space already? I would not expect you to include the volregg (or tshift) block if that were the case, but rather -regress_motion_file.
to answer your second question, I reviewed my FSL script, and while I did use flirt to align the data to the standard ENIGMA EPI template, I actually have not performed slice-timing correction or motion correction yet. I only used FSL to run topup distortion correction and then linear registration to the template.
Given that my functional data is technically already sitting in standard ENIGMA space (but is missing the MNI header codes) and needs motion correction, what is the best way to proceed? Should I use 3drefit to change the qform/sform codes of my functional rsfMRI_final data to 4 so that afni_proc.py processes the entire pipeline (including volreg and 3dpc) in +tlrc space?
Sure, you can use 3drefit to claim the functional data is in MNI space via
3drefit -space MNI rsfMRI1/2_final.nii.gz
However there is another question here. Any transformation adds blur to
the data (the voxels move and so values need to be interpolated). This
analysis path seems to transform the data 3 times: using topup, linear
regstration to the EPI template (no NL?) and then for motion correction.
These transformations should be concatenated and applied as one, so that
there is no repeated interpolation. This is how afni_proc.py works for
example, possibly including many transformations, more than one of which
might be non-linear (distortion and NL reg to a template).
Do you currently concatenate these transformation?
Your point about repeated interpolation is a critical one that I need to address. Right now, I am not concatenating these transformations. I am applying applytopup (distortion correction), then flirt -applyxfm (linear registration to the ENIGMA EPI template), and then feeding that resampled data into afni_proc.py, which would then apply motion correction (volreg) and blur the data a third time. I want to fix this pipeline so it handles transformations properly without degrading the data. do you have any other ideas here?
Thanks again for the guidance!
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.