Can't SPM12 perform motion correction on 4D nifti files directly?

Dear everyone,

I have some questions about SPM.

First, can spm only perform motion correction on multiple 3D nii files? Can’t SPM12 perform motion correction on 4D nifit files directly?

Second, why can’t multiple 3D nii be correctly converted into a 4D file after motion correction? Also need to manually enter the TR value?

Third, the mean file after motion correction should be the average value of the original fMRI calculated, is my understanding correct? Should 3dStats be used in AFNI?

Do you know the solution? Thank you very much.

It can work on 4D images too:

here is an extract of a batch that I ran on a 4D image:

matlabbatch{2}.spm.spatial.realign.estwrite.eoptions.weight = {''};
matlabbatch{2}.spm.spatial.realign.estwrite.roptions.which = [0 1];
matlabbatch{2}.spm.spatial.realign.estwrite.data = {{'/home/remi/github/bidspm/demos/MoAE/outputs/derivatives/bidspm-preproc/sub-01/func/sub-01_task-auditory_bold.nii'}};

SPM should give you the same “format” that it got as input: 4D files in → 4D files out. 3D files in → 3D files out. If you want to convert to 3Ds to 4Ds then you should indeed use the “3D to 4D File Conversion” utility (batch → SPM → Util → 3D to 4D File Conversion) and indeed this step requires you to input the TR value.
Though making the 3D to 4D conversion might be better done at the very beginning of your pipeline.

SPM will provide you a single mean image across all the runs you provided as input for the realign step.
It will not provide you with one mean image per run.

If you want to get a mean image per run on top of the mean image across runs, you can then use your favorite tool to do that. Both AFNI and SPM have tooling to do that.

1 Like

Small note here - that AFNI command should be 3dTstat to compute a mean or other statistic across a 4D dataset.

Thank you for your reply. It helps me a lot. :smiling_face:
Wishing you the best.

Thanks for your reminding. :smiling_face:
Wishing you the best.